Skip to content
Skip to Content

Dockerfile builds

Build a service with a Dockerfile you name, and the folder Docker builds it from.

A service built from Git uses Railpack until you name a Dockerfile. Then Docker builds it with that file, on your own server.

The settings

SettingWhat it isWhen you give none
DockerfileThe Dockerfile's path, inside the service's folder in the repository, such as Dockerfile or docker/web.Dockerfile.Dockerfile
ContextThe folder Docker builds from, inside the service's folder. Files outside it cannot be copied into the image.The service's folder itself

Both paths start at the service's folder: for a service whose folder is apps/web, the Dockerfile Dockerfile is apps/web/Dockerfile in the repository. Neither may lead out of the repository.

Build with a Dockerfile

openpanel services update web --project shop --dockerfile docker/Dockerfile
openpanel deploy web --project shop --wait

--dockerfile also works on services create. It sets the Dockerfile's path; the context stays the service's folder.

The change takes effect at the next deploy.

Go back to Railpack

Send "build": { "kind": "auto" }, or "build": null, in the same PATCH. The CLI has no option for this yet.

How Docker runs the build

  • The agent runs docker buildx build with BuildKit on the server, and loads the image into the server's Docker.
  • Docker's usual rules apply inside the context, such as a .dockerignore file.
  • The image is built from the Dockerfile's last stage. Choosing another target stage is not offered yet.
  • No build arguments or build secrets are passed, and the service's variables do not reach the build. See How builds work.
  • The image runs the command your Dockerfile sets, unless the service has a start command of its own.

What can go wrong

MessageWhat it means
"The build failed: apps/web/docker/Dockerfile is not in the repository"The Dockerfile, or the context folder, does not exist in the commit that was built. The message gives the path from the repository's root: the service's folder, then your path.
"The build failed: there is no Dockerfile at apps/web/docker"The path names a folder, not a file.
"The build failed: … leads out of the repository"The path, or a symbolic link on it, points outside the clone.
"A path stays inside the repository."The path you sent holds ...
"Build settings are for a service built from Git."You sent build settings while creating a service that runs an image, which has nothing to build.

See A build fails for the rest.