Fix deploy: avoid cd into /root as the deploy user
The remote shell runs as drinkadmin, which cannot enter /root even though sudo can operate there, so 'cd $REMOTE_DIR && sudo docker ...' failed at the cd. Pass the build context and compose file as paths instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -81,7 +81,9 @@ say "Checking .env.production for new variables"
|
|||||||
|
|
||||||
if [ "$BUILD" -eq 1 ]; then
|
if [ "$BUILD" -eq 1 ]; then
|
||||||
say "Building image on the LXC (this takes a few minutes)"
|
say "Building image on the LXC (this takes a few minutes)"
|
||||||
"${SSH[@]}" "cd $REMOTE_DIR && sudo -n docker build -t $IMAGE ." || die "image build failed"
|
# Pass the build context as a path rather than cd-ing in: the shell runs as the
|
||||||
|
# deploy user, which cannot enter /root even though sudo can build there.
|
||||||
|
"${SSH[@]}" "sudo -n docker build -t $IMAGE $REMOTE_DIR" || die "image build failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$PUSH" -eq 1 ]; then
|
if [ "$PUSH" -eq 1 ]; then
|
||||||
@@ -90,8 +92,10 @@ if [ "$PUSH" -eq 1 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
say "Restarting stack"
|
say "Restarting stack"
|
||||||
# --no-build: compose must use the image we just built, not try to rebuild or pull.
|
# --no-build: compose must use the image we just built, not rebuild or pull it.
|
||||||
"${SSH[@]}" "cd $REMOTE_DIR && sudo -n docker compose -f $COMPOSE_FILE up -d --no-build"
|
# Compose takes the project directory from the compose file's location, which keeps
|
||||||
|
# the project name "drinktracker" and so reuses the existing containers and volumes.
|
||||||
|
"${SSH[@]}" "sudo -n docker compose -f $REMOTE_DIR/$COMPOSE_FILE up -d --no-build"
|
||||||
|
|
||||||
# ─── Verify ──────────────────────────────────────────────────────────
|
# ─── Verify ──────────────────────────────────────────────────────────
|
||||||
say "Verifying"
|
say "Verifying"
|
||||||
|
|||||||
Reference in New Issue
Block a user