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:
JP
2026-08-08 17:06:01 +00:00
parent 2beb2d5d43
commit f3865c7901

View File

@@ -81,7 +81,9 @@ say "Checking .env.production for new variables"
if [ "$BUILD" -eq 1 ]; then
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
if [ "$PUSH" -eq 1 ]; then
@@ -90,8 +92,10 @@ if [ "$PUSH" -eq 1 ]; then
fi
say "Restarting stack"
# --no-build: compose must use the image we just built, not try to rebuild or pull.
"${SSH[@]}" "cd $REMOTE_DIR && sudo -n docker compose -f $COMPOSE_FILE up -d --no-build"
# --no-build: compose must use the image we just built, not rebuild or pull it.
# 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 ──────────────────────────────────────────────────────────
say "Verifying"