Configuration guides

Generate a Dockerfile that copies build output into a runtime stage

·

Use a build stage when the files you need at runtime are only part of the source tree. Set that boundary explicitly so the generated Dockerfile says which artifacts cross it.

Dockerfile Generator

Generate the static site recipe

Select Load static site. The build image is node:22-alpine, the build directory is /app and the build command is the JSON array for npm run build. The runtime image is nginx:1.28-alpine.

Select Generate Dockerfile. Find the stage alias build and the COPY --from=build instruction. The recipe passes /app/dist/ to /usr/share/nginx/html/.

Generate the static site recipe
SettingGenerated instruction or result
Build imageFROM node:22-alpine AS build
Build artifactCOPY reads /app/dist/ from build
Runtime destinationCOPY writes to /usr/share/nginx/html/
Exposed TCP portEXPOSE 80

Docker multi-stage buildsDockerfile reference

Review a single-stage service

Select Load Node service. The recipe uses one FROM line and adds CMD with node and server.js as separate JSON strings.

Clear Exposed TCP port and generate again. The downloaded Dockerfile now has no EXPOSE instruction. Port publication is a runtime setting.

Dockerfile referenceDockerfile shell and exec forms

Review the context and explicit defaults

Open the exported Dockerfile and compare the images, paths and commands with the intended project. Both recipes start from a supplied context with COPY of the current directory.

The presets assume the lockfile and scripts named in the recipe are available. Set .dockerignore for the context and use verified image digests and dependency locks if the image must be reproducible.

Docker build contextDocker multi-stage buildsDockerfile shell and exec forms

Common questions

Can an argument contain a space or a semicolon?

Yes. Put it inside one JSON string so it stays in one argument in exec form.

How do I generate a recipe without an install step?

Clear the optional install command. The file omits that RUN line and keeps the other selected layers.

Sources

Put it into practice.

Related guides