Logo

Sharing Excess

Food Rescue Platform
For Developers

Build & Deploy

This section consolidates how we build images and deploy to Railway, plus local Compose.

Docker images

Client (apps/client/Dockerfile)

  • Build stage: Bun install, compile server once (for Hono exports), vite build with VITE_* args
  • Runtime stage: copy dist, install serve only, run non-root on 5173

Server (apps/server/Dockerfile)

  • Build stage: workspace-filtered Bun install for server, types, db; bun run compile
  • Prod stage: install prod deps only via filters, copy sources, run DB schema generator in packages/db, run non-root on 8080

Docs (apps/docs/Dockerfile)

  • Bun base; install deps; copy selective source; bun run build; bun start

Crons (crons/backup, crons/cleanup)

  • Bun base with prod deps; backup additionally installs PostgreSQL client 16
  • Non-root execution

Railway deployment

  • Each service has a railway.json specifying DOCKERFILE builder and resource profiles
  • Client: staging sleeps, production 2 replicas
  • Server: healthcheck /, timeout 180s, production 3 replicas, multi-region; staging sleeps
  • Docs: similar to client (1 staging, 2 prod replicas)
  • Crons: scheduled with cronSchedule: "0 5 * * *", restart policy NEVER

Environment variables are managed per-service and per-environment within Railway.

docker-compose (docker-compose.yml)

  • Services: server (8080), client (5173), docs (3000), backup-cron
  • Client build args pass VITE_* envs; client depends on server
  • Usage:
    • Build: bun build
    • Run: bun start

CI/CD and branches

  • Staging deployments on staging branch
  • Production deployments on main branch
  • Database schema pushes must be run manually with root scripts (db_push:<env>) prior to deploys that require schema changes