Build Docker image

📚 Learn more about Build Docker image action features, integrations and alternatives.

Buddy lets developers easily build and test Docker images with code from Git repository. Setting up a Docker-focused pipeline is as easy as setting up any other type of delivery in the service.

First, you need to specify which repository should the image be based on. Buddy has native integrations with GitHub, Bitbucket and GitLab, but you can hook up any other repository as well: Selecting a repositorySelecting a repository

With the repository successfully synchronized, you can add the pipeline. A pipeline can be triggered in three ways: manually on click, automatically on git push, or recurrently at a specific time: Adding a new pipelineAdding a new pipeline

The second thing is setting the branch, tag, or PR for which the build will run: Pipeline configurationPipeline configuration

The next step is adding the action that will dockerize your application. Select Build Image from the Docker section of the action roster: Adding the Docker actionAdding the Docker action

In the action details, specify the Dockerfile location and the directory in the context of which the image will be built (optional): Docker action configurationDocker action configuration

Building private images

If the image is private (e.g. FROM: my-registry.com/buddy/my-image:latest) and requires logging into a registry, you can configure the access data in the 'Options' tab. Buddy integrates with Docker Hub, Google GCR and Amazon ECR. Apart from that, you can use any other private registry.

Selecting the Docker registrySelecting the Docker registry

Building Multi-Arch Docker images

The Build Image action allows you to set the target architecture for which the Docker image is built.

To choose the platform, add a Build Image action to a pipeline, switch to the Options tab, and use the dropdown menu in the Target build stage section.

Choosing the target platformChoosing the target platform

Buddy currently supports these platforms:

  • linux/386
  • linux/amd64
  • linux/arm/v6
  • linux/arm/v7
  • linux/arm64
  • linux/ppc64le
  • linux/riscv64
  • linux/s390x

Docker image Continuous Delivery

With Buddy, you can automate basically any type of a DevOps process. For example, you can create a pipeline that will perform the following tasks on every push to the selected branch – just by adding new actions to the already existing ones:

  • run unit tests
  • check the Dockerfile for issues
  • build a Docker image
  • run the image and test it for errors
  • push the image to the selected registry
  • send a notification to a Slack channel
By default, Buddy caches Docker layers and application dependencies to speed up your build process.

Docker pipeline exampleDocker pipeline example

Build arguments

By default, Buddy doesn't pass the environment variables to the build. If you want to pass them, you have to define build args and provide the environment variable that you want to pass as a value.

Apart from this, you can define your own build arguments in the action:

Build argumentsBuild arguments

Target build stage

If your Dockerfile contains multiple build stages of an image, you can specify which stage should be built in the 'Options' tab:

Target build stageTarget build stage

Cache

All Docker layers are automatically cached after the build. This means that subsequent builds only create layers that have changed since the last build, which drastically reduces the build time. After every build, Buddy runs docker prune which deletes all dangling images (layers that have no relationship to any tagged images and consume disk space).

If you run multi-stage builds, you may want to disable the prune option, as it deletes the layers of intermediate stages as well. You can do it in the 'Options' tab:

Cache optionsCache options

See also

Last modified on May 23, 2022

Questions?

Not sure how to configure a pipeline for your process? Reach out on the live-chat or contact support

Get Started

Sign up for free and deploy your project in less than 10 minutes.