Deployment
Production Build
Section titled “Production Build”bun run buildThis produces a dist/ directory with:
dist/server/— server entry pointdist/client/— client JavaScript and CSS bundlesdist/prerendered/— static HTML for prerendered routes
Running in Production
Section titled “Running in Production”bun run startOr directly:
bun dist/server/index.jsSet the port with the PORT environment variable (default: 9000).
Health Check
Section titled “Health Check”Bosia exposes a health endpoint at /_health:
curl http://localhost:9000/_health{ "status": "ok", "timestamp": 1711360000000, "timezone": "UTC" }Prerendering
Section titled “Prerendering”Mark routes for static prerendering:
export const prerender = true;Prerendered pages are built as static HTML during bosia build and served from dist/prerendered/ with a 1-hour cache header.
Static Asset Caching
Section titled “Static Asset Caching”Bosia sets cache headers automatically:
| Asset Type | Cache Header |
|---|---|
| Hashed filenames | public, max-age=31536000, immutable |
| Non-hashed files | no-cache |
Graceful Shutdown
Section titled “Graceful Shutdown”The production server handles SIGTERM and SIGINT signals:
- Stops accepting new connections
- Waits for in-flight requests to complete
- Force exits after 10 seconds if shutdown hangs
Docker
Section titled “Docker”Example Dockerfile:
FROM oven/bun:1 AS baseWORKDIR /app
# Install dependenciesFROM base AS depsCOPY package.json bun.lock ./RUN bun install --frozen-lockfile
# BuildFROM deps AS buildCOPY . .RUN bun run build
# ProductionFROM base AS runtimeCOPY --from=deps /app/node_modules ./node_modulesCOPY --from=build /app/dist ./distCOPY --from=build /app/package.json ./
ENV NODE_ENV=productionENV PORT=9000EXPOSE 9000
CMD ["bun", "dist/server/index.js"]Environment Variables
Section titled “Environment Variables”See Environment Variables for the full list of configuration options including PORT, BODY_SIZE_LIMIT, CORS, and CSRF settings.