All jobs

Dockerize an Eleventy Site

Yes. An agent writes a two-stage Dockerfile for your Eleventy site: npm ci on the Node from .nvmrc, then _site served by nginx with the right rewrites.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent reads how the site is built and what the build needs before writing the Dockerfile. In a site laid out like 11ty/eleventy-base-blog, package.json is an ES module project on @11ty/eleventy 3.1 with @11ty/eleventy-img, the navigation, RSS and syntax-highlight plugins, luxon and zod as dev dependencies and one runtime dependency, @zachleat/heading-anchors; build is npx @11ty/eleventy, start adds --serve --quiet, and build-ghpages passes --pathprefix. .nvmrc says 22 and engines says 18 or later. eleventy.config.js takes input from content/, includes from _includes/, data from _data/ and writes _site/, copies public/ to the root, bundles CSS and JS into _site/dist/, and runs the image transform plugin that writes AVIF and WebP copies, which pulls in sharp and its native binary. netlify.toml and vercel.json show the site expects _site as the publish directory and trailing slashes on URLs, .gitignore excludes _site/, node_modules/ and .cache, and there is a package-lock.json, so npm ci works.

It writes a two-stage Dockerfile. The build stage is node:22-alpine to match .nvmrc, copies package.json and package-lock.json, runs npm ci, copies the rest and runs npm run build; sharp ships a prebuilt binary for Alpine's musl on x64 and arm64, and the agent confirms that by building on both rather than assuming. The run stage is nginx:alpine with _site copied to /usr/share/nginx/html and a small nginx.conf that serves index.html for directory URLs, redirects a path without its trailing slash to the slash form so links match the canonical URLs the site generates, serves content/404.md's output as the error_page 404, and sets a long Cache-Control on /dist/ because Eleventy's bundle plugin writes content-hashed files there, with a short one on HTML. A .dockerignore keeps _site, node_modules, .cache and .git out of the build context, and a HEALTHCHECK fetches / with wget.

Two things in this site need a decision rather than a default, and the agent writes both into the pull request instead of guessing. _data/metadata.js holds the site url the Atom feed and sitemap use as their base, so the Dockerfile takes no --pathprefix and the description says to set url for the deployed host. And the drafts preprocessor in eleventy.config.js drops posts with draft: true only when ELEVENTY_RUN_MODE is build, which the build stage satisfies, so drafts stay out of the image.

Rush's sandbox has no Docker, so the agent installs it first with sudo apt-get install -y docker.io, starts dockerd, builds the image, runs it on a free port and requests /, /blog/, /blog/firstpost/, /feed/feed.xml, /blog/firstpost without the slash, and a missing path, pasting each status, the Location header on the redirect and the Cache-Control on an HTML page and a /dist/ file into the pull request. It also runs npm run build outside Docker to show the image's _site matches a local build, and writes a docker-compose.yml with the one service for a developer who wants docker-compose up, since the docker.io package ships the v1 docker-compose and not the v2 plugin.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Dockerize this Eleventy site. Read package.json, package-lock.json, .nvmrc, .gitignore, eleventy.config.js, _data/metadata.js, _includes/layouts/base.njk, netlify.toml, vercel.json and content/404.md first. Write a two-stage Dockerfile: build on the Node version from .nvmrc with npm ci and npm run build, then serve _site from nginx:alpine with an nginx.conf that serves index.html for directory URLs, redirects a path without its trailing slash to the slash form, uses the generated 404 page as error_page, sets a long Cache-Control on /dist/ bundles and a short one on HTML. Add a .dockerignore and a HEALTHCHECK, and a docker-compose.yml with the one service. Do not pass a pathprefix; say in the pull request that _data/metadata.js url must be set for the deployed host. Install Docker in your sandbox (apt-get install docker.io, start dockerd), build the image on both amd64 and arm64 if the sandbox allows, run it, request /, /blog/, /blog/firstpost/, /feed/feed.xml, /blog/firstpost without the slash and a missing path, and paste each status, the redirect Location and the Cache-Control headers into the pull request. Change nothing in content or the Eleventy config.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

The pull request adds Dockerfile, .dockerignore, nginx.conf and docker-compose.yml and touches nothing under content/, _includes/ or eleventy.config.js. Its description shows the image build log, including the sharp install on Alpine, the docker run line, and the six requests with their status codes, the 301 and Location for the slash-less path, the 404 page body's title, and the Cache-Control values for an HTML page and a /dist/ bundle.

The site builds exactly as npm run build does locally, so the feed, sitemap and image transforms in the image are the same files Netlify or Vercel would publish. The one thing the image cannot decide is the public URL in _data/metadata.js, which the description calls out as the value to set before the feed is served from a new host.

Before merging, a reviewer picks the registry and the base image policy, decides whether the long cache on /dist/ matches how they deploy, and checks the nginx redirect against any path prefix their host adds. If the site is deployed under a subpath, the build-ghpages script shows where --pathprefix would go.

Run it on every static site without a Dockerfile

A writer who runs the site from a laptop starts this from the terminal with this body and goes back to the post they were drafting. The run reads the real package.json, lock file, .nvmrc and Eleventy config, so the Node version, the install command, the output directory and the trailing-slash rule in the image match this site rather than a generic static-site template.

Send a request_id, a UUID, with the body so a retried start returns the run it already began. The pull request link is on the run's GET /o/{org}/sessions/{id} answer once it is open, and a key with a webhook_url hears run.completed when the turn ends. A team with several Eleventy sites sends one body per repository, each with its own resources URL.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

A Dockerfile for a static site looks trivial until the image is built: sharp needs a binary for the base image's libc, the trailing-slash rule has to match the URLs the site generates or every internal link redirects, and the 404 page is a file nginx has to be told about. The agent builds and runs the image in its own sandbox, with Docker installed for that run, and requests the pages that exercise each of those rules, so the pull request shows headers rather than describing them.

The transcript keeps the build log and every request, so a reviewer sees what the image does without pulling it. Several sites can be containerised at once, each in its own sandbox, and nothing merges until a person reads the diff.

Frequently asked questions

Why nginx rather than serving with Eleventy's dev server?

npm start runs Eleventy's dev server with --serve, which watches files and rebuilds; it is a development tool and needs Node and the full dependency tree in the image. The site is static, so the run stage only needs the files in _site and a web server, which keeps the image small and starts in milliseconds. nginx:alpine is the smallest common choice; the nginx.conf is where the trailing-slash and cache rules live.

Does sharp build on Alpine?

The image transform plugin pulls in sharp, which installs a prebuilt binary for Alpine's musl on x64 and arm64 with no compiler. The agent builds the image for both and pastes the install lines, so the pull request shows it rather than assuming. If a target platform has no prebuilt binary, the build stage can switch to the Debian-based node:22 image, which the description notes.

What about the site URL in the feed and sitemap?

_data/metadata.js sets url to the placeholder host and the Atom feed and sitemap use it as their base. The Dockerfile does not override it, because the right value depends on where the image is deployed, so the pull request says to set it before the feed is served from a new host. A --pathprefix is only needed when the site lives under a subpath, as build-ghpages shows.

Why redirect paths without a trailing slash?

Eleventy writes every page as <path>/index.html, the templates link to slash-ending URLs, and vercel.json sets trailingSlash: true for the same reason. Without a rule, /blog/firstpost and /blog/firstpost/ would both serve the page and split search engines across two URLs. The nginx rule sends the slash-less form to the canonical one with a 301, which the pull request shows with a curl -i of both.

Does the sandbox have Docker?

No. The agent installs the docker.io package and starts dockerd inside its sandbox for the run, then builds and runs the image there. That package ships the v1 docker-compose command rather than the v2 plugin, so the docker-compose.yml it adds is checked with that, and the pull request says which.

More Eleventy jobs

The same job on other stacks

Keep reading