Repository navigation
build(api): reproducible Railway API image with pnpm --frozen-lockfile - #759
Merged
Merged
Conversation
Add apps/api/Dockerfile (repo-root context, corepack [email protected], pnpm install --frozen-lockfile --filter api..., pnpm deploy --prod). Bump fastify to ^5.12.5 and override find-my-way/fast-uri so the locked build is at least as patched as the current npm-resolved prod. Update docs/RAILWAY.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The production
apiservice (plusretention-cron,alert-rules-evaluator,alert-webhook-worker) builds with Railpack using Root Directory/apps/api. There's no lockfile in that directory, so Railpack falls back to npm. Railway build log, Oct 6 08:30 UTC:npm install→added 193 packages→npm run build. Railway config, read-only:builder: RAILPACK,rootDirectory: /apps/api, no build or start command overrides. As a result:pnpm-lock.yamland the rootpnpm.overridesdon't describe what runs, so Dependabot alerts for the API are misleading.There's no
railway.json/railway.toml/nixpacks.toml/Procfile. The repo-rootDockerfileis the dashboard image and already uses--frozen-lockfile.Change
apps/api/Dockerfilewith the repo root as build context. It usesnode:22-slimplus openssl, pins pnpm 9.15.9 via corepack (matchespackageManager), runspnpm install --frozen-lockfile --filter api..., thenpnpm --filter api build(api-version, prisma generate, tsc) andpnpm --filter api deploy --prod, copiesdist, and runs prisma generate. The runtime is/app, runningnode dist/index.js. The entrypoint and theprisma migrate deploy-before-listen behavior are unchanged. Cron/worker start commands (node dist/jobs/...) work as they are.apps/apifastify^5.8.5→^5.12.5. Root overrides:find-my-way ^9.9.0,fast-uri@3 ^3.1.8,fast-uri@4 ^4.2.1. Without these, the frozen lockfile would downgrade prod from the patched versions npm currently resolves to the vulnerable lockfile versions (fastify GHSA-p68q-wchp-6fh7 and others, find-my-way GHSA-c96f-x56v-gq3h, the fast-uri SSRF/host confusion advisories). The lockfile diff is limited to those packages, plus process-warning 5.1.0 and a deduplicated fast-json-stringify.docs/RAILWAY.mdis updated with the new API settings.Verification (MacBook, Docker linux/amd64)
docker build --platform linux/amd64 -f apps/api/Dockerfile .succeeds.GET /healthreturned 200{"ok":true,"database":"ok"}.node dist/jobs/run-retention.js --dry-runreturned ok.pnpm install --frozen-lockfileis clean,pnpm --filter api buildpasses,pnpm lintpasses, and API tests show 1044 passed / 128 skipped (DB integration tests).Version diff (prod today via npm, inferred → this image)
effectfor a security fix)railway sshapi)Rollout: Railway settings to change (nothing has been changed)
Merging alone changes nothing about how Railway builds, because it stays on Railpack. Per service (
apifirst, thenretention-cron,alert-rules-evaluator,alert-webhook-worker):/apps/api).RAILWAY_DOCKERFILE_PATH=apps/api/Dockerfile. Without it, Railway would pick up the repo-root dashboard Dockerfile.api. Cron/worker services keepnode dist/jobs/..../apps/api/**,/pnpm-lock.yaml,/package.json. The current/apps/api/**would skip lockfile-only changes.pnpm install --frozen-lockfile, thatGET https://api.telemetry-tracker.com/healthis ok, and that the cron runs succeed.Rollback
Switch the service back to Root Directory
/apps/apiand Builder Railpack, deleteRAILWAY_DOCKERFILE_PATH, and redeploy. Or redeploy the last successful deployment. The Dockerfile has no effect while the service uses Railpack.Update after the v1.18.4 sync
Merged the current
develop. Prisma is aligned to 6.19.3. The image was re-verified against a throwaway pg16: migrate deploy and status, API /health 200 with database ok, retention --dry-run ok, the alert-rules-evaluator sweep ok (warns that email isn't configured with dummy env), and alert-webhook-worker --once ok (idle, exit 0). The image includes OpenSSL 3.0, libquery_engine-debian-openssl-3.0.x, all dist/jobs entrypoints, prisma/schema and 50 migrations, and assets/email-logo.png.