Private betav0.1.0
Docs
Format developer documentation

Docker

Deploy Format in a Docker container.

Copy the _generated directory into your production image alongside your compiled app.

Dockerfile

Dockerfile
FROM node:20-alpine AS build
WORKDIR /app
COPY . .
RUN npm ci
RUN npm run build

FROM node:20-alpine
WORKDIR /app
COPY --from=build /app/_generated ./_generated
COPY --from=build /app/dist ./dist
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/package.json ./package.json
CMD ["node", "dist/index.js"]

The build stage runs format compile (via your build script) and the production stage copies the output.

Build script

Compile your Format documents as part of your build:

package.json
{
	"scripts": {
		"build": "format compile && tsc",
		"start": "node dist/index.js"
	}
}

Dependencies

The node target externalizes dependencies by default. Your framework packages (react, react-dom or vue) and any packages your documents import must be in node_modules at runtime.

Copying node_modules in the Dockerfile handles this. If you want a smaller image, use --bundle to include packages directly and avoid copying them:

npx format compile --bundle date-fns @company/shared-utils

Assets

The node target reads assets.zip from the filesystem automatically. As long as _generated is copied into the container, assets work without extra configuration.

See Assets for alternative strategies.

Was this page helpful?