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.

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 nctl and jq to 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 -