Infraista DocsDocs
Developer toolsDockerfile Studio

Generate a Dockerfile

Pick a repository and branch, check what Dockerfile Studio detects about how your app builds and runs, choose a base image and options, and generate.

Before you start: connect GitHub, GitLab or Bitbucket. Git connections are shared by Containers, Pipelines, Code Security and Dockerfile Studio (see Create a pipeline).

1. Choose a repository

  1. Open Dockerfile Studio and select Generate Dockerfile.
  2. Pick the Git connection and the repository.
  3. Choose the Branch, and the Folder of the app in a monorepo (leave . for the whole repository).
  4. Select Analyze repository.

The repository is cloned into an isolated, single-use sandbox and read there. This usually takes a few seconds.

Generate Dockerfile, with the steps Repository, Analyze and OptionsGenerate Dockerfile, with the steps Repository, Analyze and Options

2. Check what was detected

What we detected lists the language, framework, package manager, start command, worker command, port, test command, health check path and the services the app uses. Values marked High come straight from a manifest or lockfile; Medium ones were inferred and are worth a look. Correct anything that's off: the Dockerfile is written from these values.

If the repository already has a Dockerfile, Dockerfile Studio writes an improved one.

3. Choose options

OptionChoices
Files to generateDockerfile and .dockerignore always; docker-compose.yml for local development (the app, its worker and the services it uses)
TargetProduction (small runtime image, production dependencies only) or Development (a dev stage with dev dependencies and reload)
Base imageSlim (Debian slim, compatible with prebuilt packages), Alpine (smallest, uses musl), or Distroless (no shell or package manager in the final image)
Architectureamd64, arm64 or both
Add HEALTHCHECKWith the path found in your code, or a default you should check
Pin base image by digestAdds @sha256:… for reproducible builds; someone has to bump it to get security patches
Run tests during the buildA failing test stops the image from being built
Extra instructionsAnything else, in plain language

Every generated Dockerfile runs the app as a non-root user (app, uid 10001).

The summary shows whether this generation uses one of your included generations or is billed.

4. Generate

Select Generate. Writing the files usually takes 10–40 seconds, and you can leave the page; you get a notification when it's ready.

A generated Dockerfile with line explanations, best-practice checks, the estimated image size and versionsA generated Dockerfile with line explanations, best-practice checks, the estimated image size and versions

Read the result

  • Files: click a line or a numbered marker to see what it does.
  • About this image: the estimated image size, base image and architecture.
  • Best-practice checks: real checks of the files, such as a non-root user, pinned base image versions, no secrets in ENV or ARG, and your organization's rules.
  • Try it locally: the commands to build and run it.
  • Download files as they are in the version you're viewing.

If it failed

Open the generation to see why it didn't finish, then select Try again.

On this page