Railway's Nixpacks autobuild detects Bun projects fine, but it can't sequence the combination this site needs: prisma generate at build time, Vite + the TanStack Start plugin, a custom server.ts entry, and prisma migrate deploy on boot. A four-stage Dockerfile is simpler than teaching Nixpacks all of that.
The full post walks through the recipe: two parallel bun install stages (one full, one production-only), a build stage that runs prisma generate against a dummy DATABASE_URL, a lean runtime that layers the generated Prisma client on top of deps-prod's node_modules, and an entrypoint that runs migrations before exec-ing into Bun so the container's PID 1 shuts down cleanly on Railway's SIGTERM.
Plus the small Railway-side bits: how to wire the Postgres reference variable, why you should bind explicitly to 0.0.0.0, and the COPY-order detail that determines whether your runtime sees the right Prisma client.
Originally published at andreasbergstrom.dev — read the full post there.
This article was originally published by DEV Community and written by Andreas Bergström.
Read original article on DEV Community