From b63d0415ab84bb8cfa0e4a45fb1701e45a1245cf Mon Sep 17 00:00:00 2001 From: default Date: Sat, 6 Jun 2026 21:29:21 +0000 Subject: [PATCH] fix(deploy): seed docker-compose.yml before any docker compose cmd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .gitea/workflows/deploy.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 75f1e85..8a65740 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -36,6 +36,19 @@ jobs: APP_DIR=/home/tyler/route-commerce 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 # (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 "") @@ -86,12 +99,6 @@ jobs: export NEXT_PUBLIC_API_URL="http://localhost:$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 [ -f .env ] || cp .env.example .env # Append production secrets to .env (overriding .env.example defaults)