Docker
docmd generates static HTML — perfect for lightweight, reproducible Docker containers.
Generate a Dockerfile
docmd deploy --docker
This creates a Dockerfile and .dockerignore in your project root, personalised to your configuration:
- Your output directory is used in the
COPYpath (not a hardcodedsite/) - Your exact
@docmd/coreversion is pinned in the install step for reproducible builds - Your config file is passed to
docmd buildif you use a non-default name
What Gets Generated
The Dockerfile uses an optimised multi-stage build:
- Stage 1 — Build: Installs dependencies with layer caching (
package.jsoncopied first), installs the pinned@docmd/coreversion, and runsdocmd build. - Stage 2 — Serve: Copies the built output into a minimal
nginx:alpinecontainer.
# Stage 1: Build
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN if [ -f package.json ]; then npm install --ignore-scripts; fi
COPY . .
RUN npm install -g @docmd/core@0.7.2
RUN docmd build
# Stage 2: Serve
FROM nginx:alpine
COPY --from=builder /app/site /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Custom Nginx with Docker
If you generate an nginx.conf (via docmd deploy --nginx) before generating the Dockerfile, it will be detected and automatically configured inside the container.
The .dockerignore
A .dockerignore is generated alongside the Dockerfile to keep the build context lean:
node_modules
site
dist
.git
.env
*.md
!docs/**/*.md
Build and Run
docker build -t my-docs .
docker run -p 8080:80 my-docs
Your documentation is now live at http://localhost:8080.
Re-Generating
Changed your config? Just run docmd deploy --docker again — the files are always regenerated to match your current docmd.config.js.