Dockerfile Build
With Dockerfile builds, Deploio can build any app that can be built using a Dockerfile. This is especially useful if your application uses a programming language or runtime that Deploio does not yet support natively.
Getting Started
Creating a Dockerfile application works like any other application in Deploio.
The only requirements are that your repository contains a Dockerfile and that
you specify the --dockerfile argument during creation (or enable the
Dockerfile Build switch in Cockpit).
We have a basic Dockerfile app in our examples repository.
- Cockpit
- nctl
- Open the Create Application page.
- Provide your repository details.
- Enable the Dockerfile Build switch.
You can deploy the example with nctl:
nctl create application dockerfile-rust \
--git-url=https://github.com/ninech/deploio-examples \
--git-revision=main \
--git-sub-path=dockerfile/rust \
--dockerfile
Configuration
Deploio allows you to customize various aspects of your Dockerfile-based application:
Dockerfile Path
By default, the Dockerfile in your repository root is used.
- Cockpit
- nctl
After enabling Dockerfile Build, you can specify the path in the Dockerfile Path field.
Use the flag --dockerfile-path to specify a Dockerfile at a different location:
--dockerfile-path="path/to/Dockerfile"
Build Context
By default, the system sets the build context to your repository root.
- Cockpit
- nctl
After enabling Dockerfile Build, you can specify the directory in the Build Context field.
Use the flag --dockerfile-build-context to specify a different location:
--dockerfile-build-context="path/to/build/context/"
Build Arguments
You can pass Dockerfile build arguments to your build.
- Cockpit
- nctl
Add your arguments in the Build Environment Variables section.
Use the --build-env flag. For example, to define a ARG named APP_VERSION with a value of "v0.0.1":
--build-env=APP_VERSION=v0.0.1
Runtime and Health Checks
The Deploio runtime uses the ENTRYPOINT and CMD specified in the
Dockerfile to start your application.
To serve traffic to your app, the runtime expects it to listen on a TCP socket at 0.0.0.0:$PORT. The port defaults to 8080 if not specified, but you can
configure it to any valid port number in the app definition. The runtime checks
app health via a TCP probe to the configured port and traffic only flows to the
app once the probe is successful. If the TCP probe fails at any point of the
lifecycle, the runtime restarts the app. If the app exits for any reason, the
runtime automatically restarts it.
Optimize Image Size
Images built with Deploio's Dockerfile build should not exceed 2 GiB uncompressed. There's a hard limit at 10 GiB for the whole build environment but with an image size of more than 2 GiB, the system won't be able to cache all the layers anymore and you'll notice degraded building performance.
Best Practices
Any best practices that apply to Dockerfiles in general also apply to Dockerfile builds on Deploio. For a comprehensive guide, see the official Docker best practices.
- Minimize your image size for faster builds, faster releases, and a decreased attack surface.
- Use multi-stage builds for compiled languages whenever possible.
Restrictions
Please note the following restrictions:
-
It is currently not possible to directly convert an existing application that is using buildpacks into a Dockerfile-based application. You must create a new application to use Dockerfile builds.
You can use
nctlandjqto create a new application using the configuration of an existing one:nctl get applications <existing-app-name> -o json | jq '
del(.metadata.creationTimestamp, .metadata.resourceVersion, .metadata.uid, .status) |
.metadata.name = "<new-app-name>" |
.spec.forProvider.dockerfileBuild.enabled = true
' | nctl create -f -