Docker Deployment
The two Dockerfiles create-sailor generates, and how to run them.
What's generated
create-sailor writes exactly two things for Docker:
| File | Builds | Purpose |
|---|---|---|
Dockerfile.web (repo root) | apps/web (Next output: "standalone", gateway mounted in-process) | The default deploy unit — one image, one process |
docker-compose.yml (repo root) | web + local postgres + redis | A one-command local or single-VM stack |
If you run the gateway standalone (GATEWAY_MODE=external), backends/gateway/Dockerfile builds
that image separately — it isn't wired into the generated docker-compose.yml, which assumes the
embedded default.
services:
web:
build:
context: .
dockerfile: Dockerfile.web
ports: ["3000:3000"]
environment:
- DATABASE_URL=postgresql://postgres:postgres@db:5432/nebutra
- REDIS_URL=redis://redis:6379
depends_on: [db, redis]
db:
image: postgres:15-alpine
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=nebutra
ports: ["5432:5432"]
volumes: [pgdata:/var/lib/postgresql/data]
redis:
image: redis:7-alpine
ports: ["6379:6379"]
volumes: [redisdata:/data]
volumes:
pgdata:
redisdata:Step-by-step
Copy .env.example to .env.production (or however your host injects env vars) and fill in
real values — see Environment Variables.
docker compose build
# or, standalone:
docker build -f Dockerfile.web -t my-app-web .Build context is the repo root so Turborepo can reach the shared packages/.
docker compose up -d db redispnpm db:deploy # migrations + platform.sql + generated RLS, verified
docker compose up -dpnpm db:deploy needs DATABASE_URL pointed at the running db container — run it from the
host, or docker compose run --rm web pnpm --filter @nebutra/db db:deploy if you'd rather run
it inside the network.
docker compose ps
docker compose logs web
curl http://localhost:3000/api/misc/healthThe web Dockerfile
Multi-stage, ending in a standalone Next server:
FROM node:22-alpine AS deps
# ... pnpm install --frozen-lockfile
FROM node:22-alpine AS builder
# ... pnpm run build
FROM node:22-alpine AS runner
ENV NODE_ENV production
COPY --from=builder /app/apps/web/.next/standalone ./
COPY --from=builder /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=builder /app/apps/web/public ./apps/web/public
USER nextjs
EXPOSE 3000
CMD ["node", "apps/web/server.js"].next/standalone/ is self-contained — no node_modules needed at runtime. The gateway ships
inside this same image (GATEWAY_MODE=embedded by default), so there's nothing extra to build or
run for the API in the common case.
Health check
The gateway exposes a real health endpoint (mounted at both /misc/health and
/api/misc/health):
GET /api/misc/health{
"status": "healthy",
"version": "0.1.0",
"uptime": 1234.5,
"timestamp": "2026-09-29T00:00:00.000Z",
"dependencies": {
"database": { "status": "up", "latencyMs": 4 },
"cache": { "status": "up", "latencyMs": 1 }
}
}Returns 200 for healthy / degraded, 503 for unhealthy. Point your load balancer or
container orchestrator's health check at this path.
Reverse proxy
If you're fronting the container yourself (nginx, Caddy, etc.), a single upstream is enough — the gateway is part of the same process by default:
yourdomain.com {
reverse_proxy web:3000
}Only add a second upstream if you've switched to GATEWAY_MODE=external and run
backends/gateway's image separately.
Updating a running deployment
git pull origin main
docker compose build web
pnpm db:deploy
docker compose up -d --no-deps web--no-deps avoids restarting db/redis on a web-only rebuild.
Related
How is this guide?
Last updated on