From 69651c85af2ff758467a49c2464a115e1062780d Mon Sep 17 00:00:00 2001 From: phoenix-server Date: Sat, 29 Aug 2026 21:16:10 -0400 Subject: [PATCH] feat(deploy): bake migrations into relay image, migrate from same image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The relay image shipped without migrations or knexfile, forcing operators to hand-maintain a separate migrate image plus host-mounted migration files — which silently drifts from the code that ships. Bake migrations/ and knexfile.js into the runtime stage and point the prod compose nostream-migrate service at the relay image itself (knex migrate:latest). One artifact, one pull; compose recreates the one-shot migrate container whenever the image digest changes, so migrations re-run on every release with no extra flags. Verified locally: image builds, throwaway postgres, knex applies all 32 migrations, exit 0. --- Dockerfile | 2 ++ deploy/docker-compose.prod.yml | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 29c9f82b..2a40cbfb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,6 +31,8 @@ ADD resources /app/resources COPY --from=build /build/dist . COPY --from=build /build/package.json /build/pnpm-lock.yaml ./ +COPY --from=build /build/migrations ./migrations +COPY --from=build /build/knexfile.js ./knexfile.js RUN corepack enable && corepack prepare pnpm@$PNPM_VERSION --activate && pnpm install --prod --frozen-lockfile --silent diff --git a/deploy/docker-compose.prod.yml b/deploy/docker-compose.prod.yml index 0f70c56b..1631c188 100644 --- a/deploy/docker-compose.prod.yml +++ b/deploy/docker-compose.prod.yml @@ -71,18 +71,17 @@ services: retries: 10 nostream-migrate: - image: nostream-migrate:local + image: ghcr.io/cameri/nostream:main pull_policy: never container_name: nostream-migrate + user: node:node + command: ['node_modules/.bin/knex', 'migrate:latest'] environment: DB_HOST: nostream-db DB_PORT: 5432 DB_USER: ${DB_USER} DB_PASSWORD: ${DB_PASSWORD} DB_NAME: ${DB_NAME} - volumes: - - ./migrations:/code/migrations - - ./knexfile.js:/code/knexfile.js depends_on: nostream-db: condition: service_healthy