Merge pull request #3449 from dokku/3263-copy-from-image

Only override the `WORKDIR` in copy_from_image if the image is `gliderlabs/herokuish` based
This commit is contained in:
Jose Diaz-Gonzalez authored and GitHub committed 2019-03-11 21:01:21 -04:00
commit 25a65add4a
1 file changed
+18 -9
+18 -9
View File
@@ -275,9 +275,13 @@ get_running_image_tag() {
is_image_herokuish_based() { is_image_herokuish_based() {
declare desc="returns true if app image is based on herokuish" declare desc="returns true if app image is based on herokuish"
# circleci can't support --rm as they run lxc in lxc declare IMAGE="$1"
[[ ! -f "/home/ubuntu/.circlerc" ]] && local DOCKER_ARGS="--rm" local USER_VALUE
docker run "$DOKKU_GLOBAL_RUN_ARGS" --entrypoint="/bin/sh" $DOCKER_ARGS "$@" -c "test -f /exec" &>/dev/null
# due to how the build process works, all herokuish images have the Environment variable USER=herokuishuser
USER_VALUE="$(docker inspect -f '{{range .Config.Env}}{{if eq . "USER=herokuishuser" }}{{println .}}{{end}}{{end}}' "$IMAGE")"
[[ "$USER_VALUE" == "" ]] && return 1
return 0
} }
get_docker_version() { get_docker_version() {
@@ -346,16 +350,21 @@ parse_args() {
copy_from_image() { copy_from_image() {
declare desc="copy file from named image to destination" declare desc="copy file from named image to destination"
local IMAGE="$1" declare IMAGE="$1" SRC_FILE="$2" DST_DIR="$3"
local SRC_FILE="$2" local WORK_DIR=""
local DST_DIR="$3"
verify_app_name "$APP" verify_app_name "$APP"
if verify_image "$IMAGE"; then if verify_image "$IMAGE"; then
if ! is_abs_path "$SRC_FILE"; then if ! is_abs_path "$SRC_FILE"; then
local WORKDIR=$(docker inspect -f '{{.Config.WorkingDir}}' "$IMAGE") if is_image_herokuish_based "$IMAGE"; then
[[ -z "$WORKDIR" ]] && local WORKDIR=/app WORKDIR="/app"
local SRC_FILE="$WORKDIR/$SRC_FILE" else
WORKDIR="$(docker inspect -f '{{.Config.WorkingDir}}' "$IMAGE")"
fi
if [[ -n "$WORKDIR" ]]; then
SRC_FILE="${WORKDIR}/${SRC_FILE}"
fi
fi fi
local CID=$(docker create "$DOKKU_GLOBAL_RUN_ARGS" "$IMAGE") local CID=$(docker create "$DOKKU_GLOBAL_RUN_ARGS" "$IMAGE")
docker cp "$CID:$SRC_FILE" "$DST_DIR" docker cp "$CID:$SRC_FILE" "$DST_DIR"