feat: add Docker deployment adapter - #195
Conversation
Add @marko/run-adapter-docker for deploying Marko Run apps as a container. - Builds a self-contained Node.js server (dist/index.mjs) with all dependencies bundled (noExternal), so the image needs no node_modules install; the server handles routes and serves static assets from dist/public, listening on PORT - Generates a Dockerfile and .dockerignore in the project root (only when absent, so user edits are preserved); base image configurable via the `baseImage` option - Reuses the base adapter's dev/preview so `marko-run preview` runs the built server directly - Adds a run-package fixture covering both dev and preview
🦋 Changeset detectedLatest commit: c1b5151 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughThis pull request adds a new 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/adapters/docker/package.json`:
- Around line 16-22: The package entrypoints in the Docker adapter still point
to src/index.ts, but only dist is published, so update the package.json exports
and types for `@marko/run-adapter-docker` to reference the built dist outputs
instead. Adjust the package entry configuration so the main export resolves to
dist/index.mjs and dist/index.cjs, and the type declaration points to
dist/index.d.ts, using the existing exports and types fields as the place to fix
it.
In `@packages/adapters/docker/src/index.ts`:
- Around line 41-52: Normalize the Docker path fragments in the Docker adapter
so generated Dockerfile contents always use POSIX separators. In the
Dockerfile/template logic used by dockerfile(), dockerignore(), and the COPY/CMD
path construction, convert relDist from path.relative to forward-slash form
before interpolating it, and avoid mixing it with path.posix.join on Windows.
Ensure the generated COPY and CMD paths are built from the normalized value so
Dockerfile parsing works consistently across platforms.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 85780caa-7207-4c4b-a6b1-d029f45d344b
⛔ Files ignored due to path filters (3)
package-lock.jsonis excluded by!**/package-lock.jsonand included by**packages/run/src/__tests__/fixtures/docker-adapter/__snapshots__/dev.expected.mdis excluded by!**/__snapshots__/**and included by**packages/run/src/__tests__/fixtures/docker-adapter/__snapshots__/preview.expected.mdis excluded by!**/__snapshots__/**and included by**
📒 Files selected for processing (16)
.changeset/docker-adapter.mdpackages/adapters/docker/README.mdpackages/adapters/docker/package.jsonpackages/adapters/docker/scripts/build.tspackages/adapters/docker/scripts/importMetaURL.jspackages/adapters/docker/src/index.tspackages/adapters/docker/src/types.tspackages/adapters/docker/tsconfig.jsonpackages/run/src/__tests__/fixtures/docker-adapter/.gitignorepackages/run/src/__tests__/fixtures/docker-adapter/.marko-run/routes.d.tspackages/run/src/__tests__/fixtures/docker-adapter/package.jsonpackages/run/src/__tests__/fixtures/docker-adapter/src/components/counter.markopackages/run/src/__tests__/fixtures/docker-adapter/src/routes/+page.markopackages/run/src/__tests__/fixtures/docker-adapter/test.config.tspackages/run/src/__tests__/fixtures/docker-adapter/tsconfig.jsonpackages/run/src/__tests__/fixtures/docker-adapter/vite.config.ts
- Add package.toggle.json so publish points exports/types at dist/ - Make the injected import.meta.url shim a string (.href) for the CJS build - Normalize the generated Dockerfile paths to POSIX separators so the Dockerfile is valid when the build runs on Windows
Clarify that Marko Run automatically uses an installed adapter with no Vite config, and put the `npm run build` + docker build/run steps in a Deploying section right after installation.
Description
Adds a new adapter package,
@marko/run-adapter-docker, for deploying Marko Run apps as a container image.dist/index.mjs) with all dependencies bundled (noExternal: true), so the image needs nonode_modulesinstall. The server handles the app's routes and serves the static assets indist/public, listening on thePORTenvironment variable (default3000).Dockerfileand.dockerignorein the project root duringmarko-run build. Both are only written when they don't already exist, so you can freely customize them (delete a file to have it regenerated).baseImageoption (defaultnode:20-alpine).marko-run previewruns the built server directly — the resulting image runs anywhere containers do (Fly.io, Railway, Render, Cloud Run, ECS/Fargate, Kubernetes, …).marko-run build docker build -t my-app . docker run -p 3000:3000 my-appRoute handlers receive the underlying Node request/response via the exported
DockerPlatformInfotype.Also adds a test fixture to the
@marko/runpackage (docker-adapter) covering both dev and preview — because the output runs on plain Node, the preview test actually builds and runs the server and drives it with Playwright.Motivation and Context
Containers are the most portable deployment target — a single image covers Fly.io, Railway, Render, Cloud Run, ECS/Fargate, Kubernetes, and self-hosting — but Marko Run had no first-class story for it. This bundles the server so the image is small and dependency-free, and generates a working Dockerfile so deploying is a two-command flow.
Screenshots (if appropriate):
Checklist:
Generated by Claude Code