From 860991d4a534d575f3d03e5bbdc62bd62bbd48af Mon Sep 17 00:00:00 2001 From: Michael Oliver Date: Wed, 20 Aug 2025 08:06:04 -0700 Subject: [PATCH] Updating the app-engine-exec-wrapper shell script to stop replacing the "/workspace" when including volumes from the container When the application image comes from a custom build pack, loading all volumes from the container results in "/workspace" being overwritten. This results in the application files no longer being available, which can cause commands to fail (like running rake tasks in CloudBuild or via the `appengine:exec` rake task through the `appengine` gem). I modified the app engine exec wrapper's execute shell script to replace the `--volumes-from` flag with a series of `-v` flags, allowing us to filter out any volumes from the container that would overwrite the "/workspace" path. This allows other volumes that contain useful helpers to continue to mount on the image, while also not losing the application files. --- app-engine-exec-wrapper/execute.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app-engine-exec-wrapper/execute.sh b/app-engine-exec-wrapper/execute.sh index 71adb1d..3bdee38 100755 --- a/app-engine-exec-wrapper/execute.sh +++ b/app-engine-exec-wrapper/execute.sh @@ -81,6 +81,17 @@ if [ -z "$CONTAINER" ]; then exit 1 fi +VOLUMES=$(docker inspect "$CONTAINER" | + awk ' + /"Source":/ { gsub(/"|,/, "", $2); source=$2 } + /"Destination":/ { + gsub(/"|,/, "", $2); + dest=$2; + if (dest != "/workspace") + printf("-v %s:%s ", source, dest); + } + ') + if [ -n "$PRE_PULL" ]; then echo echo "---------- INSTALL IMAGE ----------" @@ -111,7 +122,7 @@ echo echo "---------- EXECUTE COMMAND ----------" echo "$@" -docker run --rm ${ENTRYPOINT} --volumes-from=${CONTAINER} --network=${CONTAINER_NETWORK} "${ENV_PARAMS[@]}" ${IMAGE} "$@" +docker run --rm ${ENTRYPOINT} ${VOLUMES} --network=${CONTAINER_NETWORK} "${ENV_PARAMS[@]}" ${IMAGE} "$@" echo echo "---------- CLEANUP ----------"