Deployment Guide
Dinou features universal deployment flexibility: deploy as an in-process Node.js server, on Netlify Serverless Functions v2, at the edge with Cloudflare Workers or Deno Deploy, on Bun, exported as 100% static HTML, or compiled into single zero-dependency native binaries.
1. Deploy Everywhere with Dinou
Historically, deploying React Server Components to serverless and edge platforms was difficult because Node.js required runtime flags such as --conditions=react-server, custom JSX/TypeScript module loaders, or dual child processes. On managed serverless and V8 isolate runtimes, you rarely control how the underlying runtime process is spawned.
Dinou solves this at build time through its Ahead-of-Time (AOT) Dual-Bundle Engine: Pass A compiles your Server Components, layouts, Server Functions, plugins, and setupFiles with react-server conditions pre-resolved, while Pass B compiles streaming HTML SSR with client component manifests in isolated module scope. Production runtimes execute pure standard JavaScript with zero runtime transpilers and zero Node CLI flags:
preferStatic: true CDN routing and read-only Lambda safety.workerd with Workers Static Assets, KV, D1, and R2.2. Supported Deployment Targets
Every production build command defaults to Esbuild and accepts explicit bundler suffixes (:esbuild, :rollup, or :webpack — see the Bundlers & Dual-Mode Vendoring guide):
| Deployment Target | Build Command | Start / Output |
|---|---|---|
| Node.js Server | dinou build / dinou build:node | dinou start / dinou start:node |
| Node.js Standalone Binary | dinou build:node:compile | ./dist/server |
| Node.js (Pure Bun Build) | dinou build:node:pure | dinou start:node |
| Node.js Pure Standalone Binary | dinou build:node:pure:compile | ./dist/server |
| Netlify (Functions v2) | dinou build / dinou build:netlify | Automated via netlify.toml (.dinou/netlify/functions) |
| Cloudflare Workers | dinou build:cloudflare | wrangler deploy |
| Deno Deploy (Edge / Cloud) | dinou build:deno | deno deploy --project=<app> --include=.dinou/deno,.dinou/dist2,.dinou/dist3 .dinou/deno/main.js |
| Deno Standalone Server | dinou build:deno | dinou start:deno |
| Deno Standalone Binary | dinou build:deno:compile | ./dist/deno-server |
| Bun Runtime | dinou build:bun / dinou build:bun:pure | dinou start:bun |
| Bun Standalone Binary | dinou build:bun:compile / dinou build:bun:pure:compile | ./dist/server |
| Static HTML Export (SSG) | dinou export-static | out/ (HTML, Assets & .rsc Flight Payloads) |
3. Node.js Targets & Standalone Binaries
Dinou provides four production compilation and packaging pipelines for Node.js environments, scaling from traditional PaaS and VPS deployments to zero-dependency standalone native executables:
3.1 Standard Node.js Server (build:node)
Compiles your application into an in-process Dual-Bundle HTTP orchestrator at .dinou/node/server.mjs alongside pre-rendered SSG artifacts in .dinou/dist2 and public static assets in .dinou/dist3:
# 1. Compile for standard Node.js production (alias: dinou build)
dinou build:node
# 2. Start the production server (respects PORT=3000 and optional HOST=0.0.0.0)
dinou start:nodeSet Build Command to npm run build (or npx dinou build:node) and Start Command to npm start (or npx dinou start:node). Dinou automatically binds to process.env.PORT (and process.env.HOST when specified), serves static assets with zero-copy streams and HTTP Range support, and executes without special Node flags.
3.2 Node Standalone Binary (build:node:compile)
Uses Node.js to build your application and then compiles .dinou/node/server.mjs (including both RSC and SSR engines) into a single self-contained native executable at dist/server via Bun's standalone compiler:
# Compile standalone binary for current OS (dist/server)
dinou build:node:compile
# Run the single binary directly (no Node or Bun required on the production host!)
./dist/serverUnlike build:bun:compile (which runs on Bun.serve), build:node:compile packages Dinou's Node.js HTTP server architecture (http.createServer()), preserving full compatibility with Node configureServer hooks, WebSockets (ws / Socket.IO), and Express/Connect middlewares.
| Cross-Compilation Target | Architecture & Target Flag | Generated Binary |
|---|---|---|
| dinou build:node:compile | Host Architecture (Default) | dist/server |
| dinou build:node:compile:linux | Linux x86_64 (--target=bun-linux-x64) | dist/server-linux |
| dinou build:node:compile:linux_arm | Linux ARM64 / AWS Graviton (--target=bun-linux-arm64) | dist/server-linux-arm |
| dinou build:node:compile:mac | macOS ARM64 / Apple Silicon (--target=bun-darwin-arm64) | dist/server-mac |
| dinou build:node:compile:win | Windows x64 (--target=bun-windows-x64) | dist/server-win.exe |
3.3 Pure Bun Runner (build:node:pure)
Executes the entire build pipeline (Esbuild, Rollup, or Webpack + SSG + Dual-Engine bundling) using 100% Bun without requiring Node.js on the build machine, emitting the standard Node orchestrator at .dinou/node/server.mjs:
# 1. Build Node orchestrator using 100% Bun (zero Node.js required in CI)
dinou build:node:pure
# 2. Run the resulting Node server
dinou start:node3.4 Pure Standalone Binary (build:node:pure:compile)
Combines the 100% Bun build pipeline with standalone native binary compilation:
# Compile standalone binary using 100% Bun pipeline
dinou build:node:pure:compile
# Cross-compilation targets (also support :esbuild, :rollup, :webpack):
dinou build:node:pure:compile:linux # Linux x86_64
dinou build:node:pure:compile:linux_arm # Linux ARM64 (AWS Graviton)
dinou build:node:pure:compile:mac # Apple macOS (ARM64)
dinou build:node:pure:compile:win # Windows executable (.exe)At runtime, dist/server only needs .dinou/dist2 (pre-rendered SSG cache) and .dinou/dist3 (public static assets)—no node_modules, no src/, and no Node or Bun installation on the host. See Section 9.1 for the production Docker recipe.
4. Netlify (Serverless Functions v2)
Netlify is a first-class serverless target in Dinou. Both npm run build (dinou build) and npm run build:netlify (dinou build:netlify) compile a self-contained AOT Dual-Bundle Netlify Functions v2 entry into .dinou/netlify/functions/ssr.mjs, physically isolated from the public static webroot in .dinou/dist3.
build vs. build:netlify: Both commands work interchangeably on Netlify. Standard dinou build (npm run build, Netlify's default CI command) generates all Netlify artifacts plus the standalone Node HTTP server (.dinou/node/server.mjs), whereas dinou build:netlify skips the Node HTTP server step for a slightly faster serverless-only build.
Step 1: Create a netlify.toml file in your repository root:
# netlify.toml
[build]
command = "npm run build:netlify" # or "npm run build"
publish = ".dinou/dist3"
[build.environment]
NODE_VERSION = "22"
[functions]
directory = ".dinou/netlify/functions"
node_bundler = "none"
included_files = [".dinou/dist2/**"]Step 2: Deploy via Git push or Netlify CLI:
# Option A: Automatic Git-based CI/CD (Recommended)
git push origin main
# Option B: Manual deployment using Netlify CLI
npm run build:netlify # or: npx dinou build:netlify
npx netlify deploy --prodThe compiled .dinou/netlify/functions/ssr.mjs bundle embeds Pass A (RSC) and Pass B (Streaming SSR) together with your routes, Server Functions, and plugins—so included_files only needs .dinou/dist2/** (~1–2 MB instead of shipping node_modules/** or src/**). Because it exports config = { path: "/*", preferStatic: true }, Netlify serves client chunks, CSS, and public/ files directly from its global CDN at zero compute cost. On AWS Lambda's read-only /var/task filesystem, Dinou automatically uses MemoryStorage({ hydrateFromDisk: true }) (unless you configure RedisStorage), hydrating pre-rendered SSG pages from .dinou/dist2 while running background ISR via context.waitUntil() and unifying Netlify.env with getContext().env.
5. Cloudflare Workers & Pages
Dinou compiles Server Components and streaming HTML SSR directly for Cloudflare's V8-based workerd runtime using standard W3C Web Streams:
Step 1: Build the Cloudflare Workers bundle and static asset staging tree:
# Build edge worker (.dinou/cloudflare/worker.js) & staged assets (.dinou/cloudflare/assets)
dinou build:cloudflareStep 2: Configure wrangler.toml in your repository root:
#:schema node_modules/wrangler/config-schema.json
name = "dinou-cloudflare-app"
main = ".dinou/cloudflare/worker.js"
compatibility_date = "2024-09-23"
compatibility_flags = ["nodejs_compat"]
# Serves public static assets from .dinou/cloudflare/assets while keeping
# internal SSG/ISR/PPR cache files isolated under /__dinou_dist2/*.
[assets]
directory = ".dinou/cloudflare/assets"
binding = "ASSETS"
run_worker_first = true
html_handling = "none"
# Optional: Bind a Cloudflare KV namespace for persistent global ISR/ISG caching
# [[kv_namespaces]]
# binding = "DINOU_CACHE"
# id = "<YOUR_KV_NAMESPACE_ID>"Step 3: Preview locally or deploy to the Cloudflare edge:
# Preview locally with Wrangler
npx wrangler dev
# Deploy globally to Cloudflare Workers
npx wrangler deployDinou emits .dinou/cloudflare/worker.js alongside .dinou/cloudflare/assets (leaving .dinou/dist3 untouched). Public client bundles and public/ files are served via env.ASSETS, while pre-rendered SSG/ISR/PPR cache artifacts live inside .dinou/cloudflare/assets/__dinou_dist2 (blocked from direct external HTTP access). When env.DINOU_CACHE is bound, Dinou activates CloudflareKVStorage automatically; secrets, KV namespaces, D1 databases, and R2 buckets are all accessible via getContext().env.
6. Deno Deploy (deno-edge) & Standalone Binaries
Dinou provides native compilation for Deno Deploy, self-hosted Deno servers, and single-file native executables via deno compile:
deno-edge)dinou build:deno compiles your RSC and SSR engines into .dinou/deno/main.js and integrates natively with Deno KV (Deno.openKv()). Because .dinou is typically listed in .gitignore, pass --include=.dinou/deno,.dinou/dist2,.dinou/dist3 when deploying with the Deno CLI so static assets and pre-rendered SSG cache files are uploaded alongside main.js:
# 1. Build Deno bundle (.dinou/deno/main.js) & seed local KV (.dinou/kv.db)
# (Optional: set DENO_KV_URL=... to pre-seed remote Deno Deploy KV at build time)
dinou build:deno
# 2. Deploy to Deno Deploy (explicitly including gitignored .dinou build artifacts)
deno deploy --project=<my-project> --include=.dinou/deno,.dinou/dist2,.dinou/dist3 .dinou/deno/main.jsRun your pre-bundled application with the standard Deno runtime locally or in Linux containers (respects PORT, HOST, and DENO_KV_PATH):
dinou build:deno
dinou start:denodeno compile)Package your Dinou app, V8, the Deno runtime, and embedded Deno KV support into a single executable:
# Compile standalone binary for current OS
dinou build:deno:compile
./dist/deno-server
# Cross-compile for any target OS / architecture:
dinou build:deno:compile:linux # x86_64 Linux
dinou build:deno:compile:linux_arm # ARM64 Linux (AWS Graviton, Raspberry Pi)
dinou build:deno:compile:mac # Apple macOS (ARM64)
dinou build:deno:compile:win # Windows x64 (.exe)7. Bun Runtime & Standalone Executables
Run your application directly on Bun.serve with zero-copy Bun.file() static asset delivery (respecting PORT, HOST, and IDLE_TIMEOUT), or compile a native Bun executable:
# 1. Standard Bun build and execution
dinou build:bun
dinou start:bun
# 2. Pure Bun (100% Bun from bundler to runtime, 0 Node.js on the machine)
dinou build:bun:pure
dinou start:bun
# 3. Standalone Bun single-file binary compilation
dinou build:bun:compile
./dist/server
# 4. Pure Bun standalone binary compilation (100% Bun end-to-end)
dinou build:bun:pure:compile
./dist/server
# Cross-compilation targets (also available for build:bun:pure:compile:*):
dinou build:bun:compile:linux # x86_64 Linux
dinou build:bun:compile:linux_arm # ARM64 Linux (AWS Graviton)
dinou build:bun:compile:mac # Apple macOS (Apple Silicon)
dinou build:bun:compile:win # Windows x64 (.exe)8. Static Export (GitHub Pages, S3, CDN)
When your site consists purely of static routes and pre-rendered dynamic routes (via getStaticPaths), export a self-contained static site into out/:
# Generates complete static site in out/ (also supports :esbuild, :rollup, :webpack)
dinou export-staticout/ includes pre-rendered index.html files, hashed client bundles, public/ assets, and segmented page.rsc / layout.rsc Flight payloads—preserving instant client-side SPA transitions on GitHub Pages, Cloudflare Pages, AWS S3, Surge, or Nginx without any backend server.
9. Production Docker Setup
Containerizing Dinou supports two battle-tested patterns: an ultra-lightweight standalone binary container (zero JS runtime in the runner image) or a pruned multi-stage Node.js container.
9.1 Ultra-Lightweight Standalone Binary Container (Recommended)
Uses Bun in the builder stage with build:node:pure:compile (or build:bun:pure:compile) and copies only the compiled executable plus .dinou/dist2 and .dinou/dist3 into a minimal Debian Bookworm Slim image:
# ==============================================================================
# 1. Compilation Stage (100% Bun, Zero Node.js required)
# ==============================================================================
FROM oven/bun:latest AS builder
WORKDIR /app
# Symlink so #!/usr/bin/env node CLI shebangs execute Bun transparently
RUN ln -s /usr/local/bin/bun /usr/local/bin/node
# Install dependencies cleanly
COPY package.json package-lock.json* bun.lock* ./
RUN bun install
# Copy application source and compile standalone binary
COPY . .
RUN bun run build:node:pure:compile
# ==============================================================================
# 2. Minimal Production Runner Stage
# ==============================================================================
FROM debian:bookworm-slim AS runner
WORKDIR /app
# Install CA certificates for outbound HTTPS (add openssl if using Prisma)
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
# Copy ONLY the standalone binary, SSG cache (dist2), and static assets (dist3)
COPY /app/dist/server ./server
COPY /app/.dinou/dist2 ./.dinou/dist2
COPY /app/.dinou/dist3 ./.dinou/dist3
RUN chmod +x ./server
ENV NODE_ENV=production PORT=8080
EXPOSE 8080
CMD ["./server"]- Shebang Compatibility (
ln -s /usr/local/bin/bun /usr/local/bin/node): CLI binaries with#!/usr/bin/env nodeexecute directly on Bun without installing Node.js in the builder image. - Debian Bookworm Slim vs. Alpine: Standard GNU
glibcavoidsmuslnative-addon compatibility issues (such as Prisma engines — if your project uses Prisma, installopenssland copynode_modules/.prisma,node_modules/@prisma, andprisma). - Minimal Attack Surface: Neither Node.js, npm, Bun,
node_modules, nor.dinou/nodeintermediate bundles are present in the final production container.
9.2 Standard Node.js Multi-Stage Container
Thanks to Dinou's Dual-Mode Vendoring, running npm prune --omit=dev strips development packages cleanly while keeping production startup instantaneous:
# Multi-Stage Production Dockerfile for Dinou (Standard Node.js)
FROM node:22-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build:node && npm prune --omit=dev
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production PORT=3000
COPY /app/package*.json ./
COPY /app/node_modules ./node_modules
COPY /app/.dinou/node ./.dinou/node
COPY /app/.dinou/dist2 ./.dinou/dist2
COPY /app/.dinou/dist3 ./.dinou/dist3
USER node
EXPOSE 3000
CMD ["npm", "run", "start:node"]10. Horizontal Scaling & Distributed ISR Cache
Single-server Node and Bun deployments store Incremental Static Regeneration (ISR), ISG, Partial Prerendering (PPR) shells, and Cache Slots in .dinou/dist2 via FileSystemStorage. When scaling horizontally across multiple container replicas (Kubernetes, Fly.io, Railway, AWS ECS) or across serverless Netlify Function instances, configure RedisStorage in dinou.config.ts so all instances share one coherent cache and instant revalidateTag() / revalidatePath() invalidations:
// dinou.config.ts
import { defineConfig } from "dinou";
import { RedisStorage } from "dinou/server";
import Redis from "ioredis";
const redis = process.env.REDIS_URL ? new Redis(process.env.REDIS_URL) : null;
export default defineConfig({
...(redis
? {
storage: new RedisStorage(redis, {
prefix: "dinou:prod:",
}),
}
: {}),
});During dinou build, Dinou automatically writes build-time SSG pages to .dinou/dist2 without touching your remote Redis cluster. At runtime, RedisStorage (as well as CloudflareKVStorage via /__dinou_dist2 and DenoKVStorage) lazily hydrates missing build-time artifacts from disk while respecting tag/path invalidation timestamps across every replica.
11. Managing Production Environment Secrets
Never commit .env secrets to Git or bake runtime secrets into Docker images. Remember that client-exposed variables prefixed with DINOU_PUBLIC_ are statically inlined at build time, while server-only secrets are read dynamically at request time via getContext().env (see Environment Variables):
- Railway / Render: Project Settings → Environment Variables.
- Fly.io:
fly secrets set DATABASE_URL="...". - Netlify: Site Configuration → Environment variables (unified automatically from
Netlify.env&process.env). - Cloudflare Workers:
npx wrangler secret put DATABASE_URL. - Deno Deploy: Project Settings → Environment Variables (or
--env-fileindeno deploy).
12. Production Pre-Flight Checklist
- Validate Production Build Locally: Run
npm run build && npm startlocally to verify SSG routes, Server Functions, and production bundles before deploying. - Build-Time vs. Runtime Env Vars: Ensure
DINOU_PUBLIC_*variables are available in your CI builder stage, and private secrets are set in your runtime platform dashboard. - Immutable Asset Caching: Content-hashed client JS/CSS bundles and fingerprinted files in
/assets/*are served withCache-Control: public, max-age=31536000, immutableautomatically across Dinou's Node, Bun, and Deno servers and edge CDNs. - Distributed Cache for Multi-Replica / Edge: Bind
DINOU_CACHEon Cloudflare Workers, enable Deno KV on Deno Deploy, or configureRedisStoragewhen running multiple Node/Bun/Netlify instances. - HTTPS & Reverse Proxy Headers: Ensure TLS termination is active (automatic on Netlify, Cloudflare, Deno Deploy, Railway, and Fly.io; use Caddy or Nginx with Let's Encrypt on self-hosted VPS hosts).