Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/medusa/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM node:26-alpine AS base

RUN apk update && apk add --no-cache libc6-compat
RUN npm install -g corepack && corepack enable && corepack prepare yarn@4.9.1 --activate

WORKDIR /app

Expand Down Expand Up @@ -41,4 +42,4 @@ WORKDIR /app/server

ENV PORT=80

CMD ["yarn", "start:prod"]
CMD ["sh", "-c", "yarn migrate:prod && yarn start:prod"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Running migrate:prod on every container start risks concurrent migrations on scaled/restarted instances.

If Railway ever runs more than one replica, or restarts the container concurrently (deploy + health-check restart overlap), multiple instances will race to run medusa db:migrate at the same time, which can produce partial/locked schema changes. Consider running migrations as a separate one-off release step (e.g., Railway's pre-deploy/release command) rather than embedding it in the container's steady-state CMD.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/medusa/Dockerfile` at line 45, Running migrations in the container CMD
causes every startup to execute `yarn migrate:prod`, which can race across
scaled or restarted instances. Update the `CMD` in the Dockerfile so the app
only starts `yarn start:prod`, and move `migrate:prod` to a separate one-off
deployment/release step outside the steady-state container startup path.

1 change: 1 addition & 0 deletions apps/storefront/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM node:26-alpine AS base

RUN apk update && apk add --no-cache libc6-compat
RUN npm install -g corepack && corepack enable && corepack prepare yarn@4.9.1 --activate

WORKDIR /app

Expand Down
Loading