Skip to content

feat: deploy adapter for Docker#320

Merged
lazarv merged 5 commits into
mainfrom
feat/adapter-docker
Mar 1, 2026
Merged

feat: deploy adapter for Docker#320
lazarv merged 5 commits into
mainfrom
feat/adapter-docker

Conversation

@lazarv

@lazarv lazarv commented Mar 1, 2026

Copy link
Copy Markdown
Owner

Adds a new built-in Docker deploy adapter for @lazarv/react-server that generates production-ready Docker images from your application build output. The adapter supports three container runtimes — Node.js, Bun, and Deno — configurable via a single runtime option.

Motivation

While existing adapters target managed platforms (Vercel, Netlify, Cloudflare, AWS, Azure), many teams need to deploy to their own infrastructure or any environment that runs Docker containers (Kubernetes, ECS, Fly.io, Railway, self-hosted servers, etc.). This adapter bridges that gap by generating a minimal, single-stage Dockerfile with pre-built application output — no build step happens inside Docker, resulting in smaller images and faster builds.

What's included

Runtime support

Runtime Build mode Base image Static serving Signal handling
Node.js (default) Standard + NFT tracing node:<version>-alpine Built-in HTTP server tini init process
Bun Edge (single bundle) oven/bun:<version> Bun.serve() static routes tini init process
Deno Edge (single bundle) denoland/deno:<version> Deno.serve() with file reads tini init process

Adapter options

Option Type Default Description
runtime "node" | "bun" | "deno" "node" Container runtime
name string from package.json Application/image name
tag string "<name>:latest" Docker image tag
port number 3000 Container port
version string "20-alpine" / "alpine" Base image tag (default varies by runtime)

Usage

// react-server.config.mjs
export default {
  adapter: "docker",
};

// Or with options:
export default {
  adapter: [
    "docker",
    {
      runtime: "bun",
      port: 8080,
      version: "latest",
    },
  ],
};
pnpm react-server build --deploy
docker run -p 3000:3000 my-app:latest

Output structure

The adapter generates a .docker/ directory containing everything needed to build the image:

Node.js:

.docker/
├── Dockerfile
├── .dockerignore
├── package.json
├── server/
│   ├── index.mjs              # Server entry
│   ├── .react-server/         # Build output
│   └── node_modules/          # Traced dependencies (NFT)
└── static/                    # JS, CSS, images

Bun / Deno:

.docker/
├── Dockerfile
├── .dockerignore
├── package.json
├── start.mjs                  # Generated start script with inlined static routes
├── server/
│   └── .react-server/         # Edge bundle
└── static/                    # JS, CSS, images

Bug fixes in dependency resolution

During development and testing, several issues were discovered and fixed in the core dependency resolution that affected Docker (and potentially other Node-mode adapters):

  • dependencies.mjs: All eager require.resolve() calls now use a tryResolve() helper that returns undefined on failure instead of throwing. This prevents build crashes when optional peer dependencies (e.g., react/compiler-runtime, react-dom/client) are not installed.
  • module-alias.mjs: Same tryResolve() pattern applied, with undefined aliases filtered out before returning the alias map.
  • core.mjs: Added missing runtime dependencies to the NFT trace list (module-alias, unstorage, unstorage/drivers/*, picocolors, and Node runtime startup files). Fixed the alias include block to use pre-resolved paths instead of re-resolving keys, which failed in pnpm workspace setups.

Documentation

  • Full deploy guide added for both English and Japanese
  • Covers: prerequisites, installation, configuration, build & deploy, environment variables, how it works (all three runtimes), output structure, Docker Compose example, and troubleshooting
  • Adapter grid on the deploy overview page updated with Docker card
  • Adapters README updated with Docker section describing all options and runtime modes

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
react-server-docs e5ee7c6 Mar 01 2026, 08:24 PM

@lazarv lazarv changed the title Feat/adapter docker feat: deploy adapter for Docker Mar 1, 2026
@lazarv lazarv merged commit 408bd40 into main Mar 1, 2026
57 of 58 checks passed
@lazarv lazarv deleted the feat/adapter-docker branch March 1, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant