Skip to main content
The Dockerfile build strategy builds the Dockerfile in your repository with Docker, exactly as written: you choose the base image, the system packages and the language. Use it when your language or setup isn’t detected by Nixpacks, Railpack or Buildpacks, or when you want full control over the image. To deploy an image you’ve already built elsewhere, use a Docker image source instead.

How Sevalla builds your Dockerfile

Sevalla clones the repository and runs a Docker build with:
  • the Dockerfile path as the Dockerfile,
  • the Docker context as the build context, with its .dockerignore,
  • every environment variable marked Available during buildtime, and the variables Sevalla sets, as build arguments,
  • a docker login with the Docker registry credential first, when you choose one.
The image is the Dockerfile’s last stage. Sevalla doesn’t pass a --target, so you can’t build an earlier stage of a multi-stage Dockerfile.

Use a Dockerfile

1

Open the build strategy

In the sidebar, click Applications, then click the application. On the Settings tab, in the Build strategy section, click Update build strategy.
2

Choose Dockerfile

Click Dockerfile. Enter the Dockerfile path and the Docker context, both relative to the repository root.
3

Add a registry credential if the base image is private

In Docker registry credential, choose the registry credential for the registry your FROM images come from. Leave None (public images only) for public base images.
4

Save and deploy

Click Update build strategy, then deploy the application.
The Build strategy section shows Dockerfile with the Dockerfile path, the Docker context and the Registry credential.
The Update build strategy sheet with Dockerfile selected, the Dockerfile path, the Docker context and the Docker registry credentialThe Update build strategy sheet with Dockerfile selected, the Dockerfile path, the Docker context and the Docker registry credential
In a monorepo, point both at the application’s folder, for example Dockerfile path apps/storefront/Dockerfile and Docker context apps/storefront. If the build fails to log in with the credential, the log says Docker registry authentication failed and the build continues without it.

Make the image run on Sevalla

Use build arguments

Every build-time environment variable is passed as a build argument. Declare it with ARG in the stage that needs it:
Dockerfile
An ARG is available only in the stage that declares it. Don’t copy secrets into ENV or into files in the final stage: anyone who can pull the image can read them. Runtime-only variables don’t need to be in the Dockerfile; Sevalla sets them in the running container.

Example Dockerfile

A multi-stage Dockerfile for a Node.js application that builds in one stage and runs a smaller image in the last one:
Dockerfile
The server reads process.env.PORT. Add a .dockerignore with node_modules and .git so the context stays small and the build fast.

Run software that needs a disk

With a Dockerfile you can run software Sevalla doesn’t offer as a managed service, for example a database engine, as long as it runs in a container. Its data must be on a disk, or it’s lost on every deployment and restart, and a process with a disk is briefly interrupted during each rollout. For PostgreSQL, MySQL, MariaDB, Redis and Valkey, a managed database gives you backups and no downtime on deployments.