Skip to content

Commit 4ea38d1

Browse files
ABB65Contentrain
andauthored
fix(docker): carry the migration runner + SQL lineage in the runtime image (#149)
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. Co-authored-by: Contentrain <mcp@contentrain.io>
1 parent ce4f660 commit 4ea38d1

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ COPY --from=build /app/.output ./.output
3939
# Contentrain content (needed for UI strings via @contentrain/query)
4040
COPY --from=build /app/.contentrain ./.contentrain
4141

42+
# Database migration runner + SQL lineage. The managed pair does NOT migrate
43+
# at app start; the Railway pre-deploy command (`node scripts/migrate-postgres.mjs`)
44+
# runs this before the new image serves, so the schema is always applied ahead
45+
# of the release. The app bundles its own pg inside .output; this standalone
46+
# runner lives outside that tree, so it gets a self-contained pg (its only
47+
# non-builtin import, matched to the app's resolved 8.22.0).
48+
COPY --from=build /app/scripts/migrate-postgres.mjs /app/scripts/verify-managed-schema.mjs ./scripts/
49+
COPY --from=build /app/postgres/migrations ./postgres/migrations
50+
COPY --from=build /app/supabase/migrations ./supabase/migrations
51+
RUN printf '{"name":"studio-migrations","private":true,"type":"module"}\n' > package.json \
52+
&& npm install --no-fund --no-audit pg@8.22.0 \
53+
&& npm cache clean --force
54+
4255
# Git needs a writable home for config
4356
ENV HOME=/home/studio
4457
ENV NODE_ENV=production

0 commit comments

Comments
 (0)