From 0316e6446f7ff49bccb44826e2090dcefaacb4e5 Mon Sep 17 00:00:00 2001 From: Contentrain Date: Mon, 13 Jul 2026 22:27:53 +0300 Subject: [PATCH] fix(docker): carry the migration runner + SQL lineage in the runtime image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Railway pre-deploy command `node scripts/migrate-postgres.mjs` was failing with MODULE_NOT_FOUND — the runtime stage only copied .output and .contentrain, so scripts/, the postgres/supabase migration SQL, and pg were absent from /app. Copy the standalone runner + verify script + both migration dirs, and install a self-contained pg@8.22.0 (its only non-builtin import) so the pre-deploy command applies migrations before each release serves. --- Dockerfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Dockerfile b/Dockerfile index 5c8f8a01..5aab0038 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,6 +39,19 @@ COPY --from=build /app/.output ./.output # Contentrain content (needed for UI strings via @contentrain/query) COPY --from=build /app/.contentrain ./.contentrain +# Database migration runner + SQL lineage. The managed pair does NOT migrate +# at app start; the Railway pre-deploy command (`node scripts/migrate-postgres.mjs`) +# runs this before the new image serves, so the schema is always applied ahead +# of the release. The app bundles its own pg inside .output; this standalone +# runner lives outside that tree, so it gets a self-contained pg (its only +# non-builtin import, matched to the app's resolved 8.22.0). +COPY --from=build /app/scripts/migrate-postgres.mjs /app/scripts/verify-managed-schema.mjs ./scripts/ +COPY --from=build /app/postgres/migrations ./postgres/migrations +COPY --from=build /app/supabase/migrations ./supabase/migrations +RUN printf '{"name":"studio-migrations","private":true,"type":"module"}\n' > package.json \ + && npm install --no-fund --no-audit pg@8.22.0 \ + && npm cache clean --force + # Git needs a writable home for config ENV HOME=/home/studio ENV NODE_ENV=production