Skip to content

Fix Railway Docker builds on Node 26#79

Merged
dwene merged 1 commit into
mainfrom
codex/fix-railway-node-26-yarn
Jul 1, 2026
Merged

Fix Railway Docker builds on Node 26#79
dwene merged 1 commit into
mainfrom
codex/fix-railway-node-26-yarn

Conversation

@dwene

@dwene dwene commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • install and activate Corepack/Yarn 4.9.1 in both Node 26 Docker base stages
  • run Medusa production migrations before starting the container so existing Railway data gets Medusa's tax-region provider migration

Verification

  • docker build -f apps/storefront/Dockerfile .
  • docker build -f apps/medusa/Dockerfile .

Notes

Railway storefront build failed at RUN yarn install with /bin/sh: yarn: not found after moving to node:26-alpine. The Node 26 Alpine image also lacks corepack, so the Dockerfiles install Corepack with npm before activating the repo-pinned Yarn version.

Summary by CodeRabbit

  • Chores
    • Updated container setup to use Corepack with a pinned Yarn 4.9.1 version for more consistent builds.
    • Adjusted the production startup flow so database migrations run automatically before the app launches.

@medusajs

medusajs Bot commented Jul 1, 2026

Copy link
Copy Markdown
Name Backend Status Storefront Status Preview Link Last Updated
Medusa Starter 🟡 Provisioning - - / - Wed, 01 Jul 2026 03:53:41 GMT

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Both the Medusa and storefront Dockerfiles' base stages are updated to install, enable, and activate Corepack with yarn@4.9.1. Additionally, the Medusa runner stage's startup command now runs yarn migrate:prod before yarn start:prod.

Changes

Dockerfile Toolchain and Startup Updates

Layer / File(s) Summary
Corepack/Yarn setup in base images
apps/medusa/Dockerfile, apps/storefront/Dockerfile
Base stages now install Corepack globally, enable it, and prepare/activate yarn@4.9.1 for subsequent build steps.
Medusa runner startup command
apps/medusa/Dockerfile
Runner CMD now runs yarn migrate:prod before yarn start:prod, instead of starting the server directly.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Related PRs: None identified.

Suggested labels: docker, infrastructure

Suggested reviewers: None identified.

🐰 Corepack awakens, yarn pinned tight,
Migrations run first before the launch takes flight,
Two Dockerfiles updated, toolchains aligned,
A tidy little hop for builds refined.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: fixing Railway Docker builds for Node 26.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-railway-node-26-yarn

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/medusa/Dockerfile (1)

4-4: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Pin Corepack to a fixed version. npm install -g corepack fetches whatever is latest from npm during each build, so this image can drift even though yarn@4.9.1 is fixed. Use an explicit Corepack version instead, for example corepack@0.35.0.

🤖 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 4, The Dockerfile setup is installing
Corepack without a fixed version, which makes builds drift over time. Update the
RUN step in the Dockerfile to install an explicit Corepack version instead of
relying on the latest from npm, while keeping the existing corepack enable and
corepack prepare yarn@4.9.1 --activate flow intact.
🤖 Prompt for all review comments with 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.

Inline comments:
In `@apps/medusa/Dockerfile`:
- 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.

---

Nitpick comments:
In `@apps/medusa/Dockerfile`:
- Line 4: The Dockerfile setup is installing Corepack without a fixed version,
which makes builds drift over time. Update the RUN step in the Dockerfile to
install an explicit Corepack version instead of relying on the latest from npm,
while keeping the existing corepack enable and corepack prepare yarn@4.9.1
--activate flow intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 094b9bf0-4bd1-40e1-82dd-40c37367e2fc

📥 Commits

Reviewing files that changed from the base of the PR and between 6e666bc and 12f8433.

📒 Files selected for processing (2)
  • apps/medusa/Dockerfile
  • apps/storefront/Dockerfile

Comment thread apps/medusa/Dockerfile
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.

@dwene dwene merged commit 9bf5888 into main Jul 1, 2026
4 checks passed
@dwene dwene deleted the codex/fix-railway-node-26-yarn branch July 1, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant