10 months ago
1. Marketing Site (Astro Static)
Goal: Deploy apps/marketing as a static site with cleanUrls support (for Astro View Transitions).
Problem: Build succeeds, but runtime fails with:
./node_modules/.bin/serve: No such file or directory
What we tried:
- Setting Root Directory to apps/marketing
- Build command: cd ../.. && bun install && cd apps/marketing && bun run build && bun add serve
- Start command: ./node_modules/.bin/serve dist -l $PORT -c serve.json
The serve package isn't available at runtime even though we install it during build. It seems node_modules isn't copied to the runtime container.
serve.json (for cleanUrls):
{"cleanUrls": true}
Questions:
1. What's the recommended way to serve Astro static sites with cleanUrls on Railway?
2. Does Railway have built-in static file serving we should use instead?
3. How do we ensure dependencies installed during build are available at runtime?
---
2. Go API (Fiber)
Current setup: Deployed via DigitalOcean App Platform, but we'd prefer Railway for unified infrastructure.
Questions:
1. What's the recommended setup for a Go Fiber API?
2. Any special configuration for PostgreSQL connection pooling?
---
3. Admin Dashboard (React SPA)
Stack: TanStack Start (Vite + React 19)
Questions:
1. What's the best way to deploy a Vite React SPA?
2. Should we use static deployment or a Node.js server?
---
Environment
- Package manager: Bun
- Node version needed: 20+
- Monorepo with workspace dependencies
Project ID
f323ae81-3886-4d04-af92-91dda7d9a182 (bountiful-optimism)
---
Would you be able to help us configure these services correctly? We're happy to schedule a call if that would be easier.
Thank you!
1 Reply
10 months ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open Railway • 10 months ago
4 hours ago
Hi @itaides — your Astro build succeeds. The Start Command then looks for ./node_modules/.bin/serve. That error alone doesn't tell us whether Railway omitted dependencies. Bun can hoist them to the workspace root, and the start command resolves paths from its own working directory. I'd deploy the same repo as three Railway services and fix marketing first.
1. Astro marketing site
Yes, Railway can serve the built site. For a shared Bun workspace, keep the repository root as the marketing service's Root Directory so the builder sees the root manifest, lockfile and shared packages. With apps/marketing as Root Directory, cd ../.. cannot recover files Railway excluded.
For the Railpack builder, use these settings on the marketing service only:
- Build Command:
cd apps/marketing && bun run build - Service variable:
RAILPACK_SPA_OUTPUT_DIR=apps/marketing/dist - Start Command: clear the existing override so Railpack starts Caddy.
Commit the workspace manifests and Bun lockfile. Remove bun add serve from the build. If shared packages need compilation first, use the root script that builds those dependencies before marketing. A local check is bun install --frozen-lockfile && (cd apps/marketing && bun run build). Check that the expected pages actually exist under apps/marketing/dist.
Astro's default directory output turns about.astro into about/index.html, so /about/ works without serve.json. For a multipage site, Railpack honors index_fallback: false in a Staticfile at the build root. This preserves real 404s. A repo-root Staticfile is shared by services built there, so give the admin its own routing configuration if it needs an SPA fallback. Open a nested URL directly and refresh it. Both should load. An invented URL should return 404.
If you keep a JavaScript server, add serve locally to the marketing workspace's production dependencies, commit the manifest and lockfile, and invoke it through that workspace's start script. The static Caddy deployment above only needs the build output at runtime.
2. Go Fiber API and PostgreSQL
If Fiber has its own independent Go module, set the API service's Root Directory to the folder containing its go.mod. Railpack builds and starts the binary. For a layout such as cmd/server/main.go, set RAILPACK_GO_BIN=server if detection picks the wrong command. If the API imports sibling modules via go.work, build from the workspace root with the Go provider and set RAILPACK_GO_WORKSPACE_MODULE to the API module directory.
Have Fiber listen on Railway's port, e.g. app.Listen("0.0.0.0:" + os.Getenv("PORT")), and handle the returned error. Set Railway's Healthcheck Path to an endpoint such as /ready that returns 200 when the API can serve traffic. Test it on the generated Railway domain before switching traffic from DigitalOcean.
If Postgres is on Railway in the same environment, put DATABASE_URL=${{Postgres.DATABASE_URL}} on the API service, replacing Postgres with the actual service name. Create one pgxpool.Pool per API process, reuse it in handlers, and close it on shutdown. Use a short timeout for a readiness Ping. Budget MaxConns across all live replicas, including old and new replicas during a rollout, and reserve connections for migrations and other clients. Two live processes capped at ten each can use twenty connections.
3. TanStack Start admin
If the admin uses SSR, server functions or server-side sessions, use a server deployment. With the Nitro Node preset, build the admin workspace and start node .output/server/index.mjs from that directory. For example, if the dashboard is apps/admin, its root-relative start command is node apps/admin/.output/server/index.mjs. Pin a supported Node version that satisfies your actual dependencies using RAILPACK_NODE_VERSION. Bun still handles installation.
If Fiber handles all backend work and the admin is entirely client-side, set tanstackStart({ spa: { enabled: true } }) in the Vite config. Serve the generated client files and rewrite unmatched UI routes to the generated shell (default /_shell.html). For a plain Vite React SPA, the equivalent fallback is usually /index.html. Serve real assets first and route API requests separately. Browser code needs a public HTTPS API URL or a same-origin proxy. Railway private hostnames are for service-to-service calls. Verify a direct refresh on a nested admin route, then check that an API request returns JSON rather than the HTML shell.
References
https://docs.railway.com/deployments/monorepo
https://railpack.com/languages/node
https://railpack.com/languages/golang
https://pkg.go.dev/github.com/jackc/pgx/v5/pgxpool
https://railway.com/guides/tanstack-start
https://tanstack.com/start/latest/docs/framework/react/guide/spa-mode
AI-assisted. I checked the documentation. I haven't run your repository.