Skip to main content

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.

  1. Open the Create Application page.
  2. Provide your repository details. 3. Enable the Dockerfile Build switch.

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.

After enabling Dockerfile Build, you can specify the path in the Dockerfile Path field.

Build Context​

By default, the system sets the build context to your repository root.

After enabling Dockerfile Build, you can specify the directory in the Build Context field.

Build Arguments​

You can pass Dockerfile build arguments to your build.

Add your arguments in the Build Environment Variables section.

Deploio also automatically provides certain variables as build arguments, such as DEPLOIO_GIT_REVISION. To use them during the build, declare them as ARG in your Dockerfile:

ARG DEPLOIO_GIT_REVISION
RUN echo "Building revision $DEPLOIO_GIT_REVISION"

The following variables are automatically provided:

VariableDescriptionBuild timeRuntime
PORTThe port number your app is exposed on.—✓
DEPLOIO_APP_NAMEThe name of your application.—✓
DEPLOIO_PROJECT_NAMEThe name of the project your app belongs to.—✓
DEPLOIO_RELEASE_NAMEThe name of the currently active release.—✓
DEPLOIO_GIT_REVISIONThe git revision (commit SHA) of the deployed source code.✓✓

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.

Switch the Build Type​

You can switch an existing application from buildpacks to Dockerfile builds and back again without recreating it. Switching triggers a new build. The current release stays active until the new build succeeds.

To switch to Dockerfile builds with nctl, run:

nctl update application <app-name> --build-type=dockerfile

To switch back to buildpacks, set --build-type to the buildpack stack you want to use, heroku or paketo:

nctl update application <app-name> --build-type=heroku