fix(deploy): seed docker-compose.yml before any docker compose cmd
Deploy to route.crispygoat.com / deploy (push) Failing after 1m7s

The 'cp -f deploy/docker-compose.yml ...' was sitting AFTER
'docker compose down' in the step. 'docker compose down' reads
and validates the compose file on the server — so the old copy
(with the dead nextjs service and its env_file: ../.env.production
reference) was still being read, and docker compose bailed on the
missing .env.production file before the copy could overwrite it.

Moved the config-file seeding to the top of the step, right after
'mkdir -p $APP_DIR'. Now the new compose file is in place before
either 'docker compose down' or 'docker compose up' runs.
This commit is contained in:
2026-06-06 21:29:21 +00:00
parent e2e56252ec
commit b63d0415ab
+13 -6
View File
@@ -36,6 +36,19 @@ jobs:
APP_DIR=/home/tyler/route-commerce APP_DIR=/home/tyler/route-commerce
mkdir -p $APP_DIR mkdir -p $APP_DIR
# Seed config files into APP_DIR FIRST, before any docker compose
# command. The `docker compose down` below validates the compose
# file (including `env_file` paths) — if the old copy is still
# on the server with a broken `env_file`, the step fails before
# we get a chance to overwrite it.
# - docker-compose.yml: copied UNCONDITIONALLY so deploys pick
# up compose changes. The previous `[ -f ... ] ||` guard
# kept stale copies on the server.
# - .env.example: copied on first deploy only (it's a template;
# the real `.env` is built from it below).
[ -f $APP_DIR/.env.example ] || cp .env.example $APP_DIR/.env.example
cp -f deploy/docker-compose.yml $APP_DIR/docker-compose.yml
# Free the dev-stack port (3001) and the port the previous deploy used # Free the dev-stack port (3001) and the port the previous deploy used
# (so a new deploy can pick it back up if it's the lowest free port) # (so a new deploy can pick it back up if it's the lowest free port)
PREV_PORT=$(cat .postgrest-port 2>/dev/null || echo "") PREV_PORT=$(cat .postgrest-port 2>/dev/null || echo "")
@@ -86,12 +99,6 @@ jobs:
export NEXT_PUBLIC_API_URL="http://localhost:$POSTGREST_HOST_PORT" export NEXT_PUBLIC_API_URL="http://localhost:$POSTGREST_HOST_PORT"
export POSTGREST_HOST_PORT export POSTGREST_HOST_PORT
# Seed config files into APP_DIR. The docker-compose.yml
# is copied UNCONDITIONALLY so deploys pick up compose
# changes (the previous `[ -f ... ] ||` guard kept stale
# copies on the server and masked a broken `env_file` path).
[ -f $APP_DIR/.env.example ] || cp .env.example $APP_DIR/.env.example
cp -f deploy/docker-compose.yml $APP_DIR/docker-compose.yml
cd $APP_DIR cd $APP_DIR
[ -f .env ] || cp .env.example .env [ -f .env ] || cp .env.example .env
# Append production secrets to .env (overriding .env.example defaults) # Append production secrets to .env (overriding .env.example defaults)