Comment on page
Continuous Integration systems are as varied as the companies that use them. Fortunately, Earthly is flexible enough to fit into most (and where we don't, let us know!). This document serves as a starting point to configuring Earthly in your CI environment.
Setting up Earthly is as easy as three steps:
Earthly has two software dependencies:
earthlywill not install these for you, please ensure they are present before proceeding. These tools are very common, so many environments will already have them installed. If you choose to use our prebuilt containers, these dependencies are already included.
dockeris used to glean information about the containerization environment, and manage our
earthly-buildkitddaemon. It is also used to do things like save images locally on your machine after they have been built by Earthly. To install
docker, use the most recent versions directly from Docker. The versions packaged for many distributions tend to fall behind.
Once you have ensured that the dependencies are available, you'll need to install
This is the simplest method for adding
earthlyto your CI. It will work best on dedicated computers, or in scripted/auto-provisioned build environments. You can pin it to a specific version like so:
wget https://github.com/earthly/earthly/releases/download/v0.7.22/earthly-linux-amd64 -O /usr/local/bin/earthly && \
chmod +x /usr/local/bin/earthly && \
It is recommended to install
earthlyas part of the new host's configuration, and not as part of your build. This will speed up your builds, since you do not need to download
earthlyeach time; and it will also provide stability in case a future version of
earthlychanges the behavior of a command.
Don't forget to run
earthly bootstrapwhen you are done to finish configuration!
If a local installation isn't possible, Earthly currently offers two official images:
earthly/earthly, which is a 1-stop shop. It includes a built-in
earthly-buildkitddaemon, and accepts a target to be built as a parameter. It requires a mount for your source code, and an accessible
earthlyis fairly configurable by itself, it also depends on the configuration of its dependencies. In a CI environment, you will need to ensure all of them are configured correctly.
dockeralso needs to be configured to have access to any private repositories referenced in the
Earthfilesyou want to build. Please our documentation for how to log in, and our examples for pushing to many popular repositories.
earthly-buildkitddaemon requires running in
--privilegedmode, which means that the
dockerdaemon needs to be configured to allow this as well. Rootless configurations are currently unsupported.
Some options that may make sense in a CI environment are:
Earthly also has a special
--pushoption that can be used when invoking a target. In a CI, you may want to ensure this flag is present to push images or run commands that are not typically done as part of a normal development workflow.
If you would like to do cross-platform builds, you will need to install some
binfmt_miscentries. This can be done by running:
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes. This installs the needed entries and
qemu-user-staticbinaries on your system. This will need to be repeated on each physical box (only once, since its a kernel level change, and the kernel is shared across containers).
earthlydepends on the availability of an
earthly-buildkitdaemon to perform its build. This daemon has some networking and security considerations.
earthlyis running on a dedicated host, the only consideration to take is the ability to run the container in a
--privilegedmode. Typical installations should support this out of the box. We also support running under user namespaces, when
earthlyis configured to start the
earthly-buildkitcontainer with the
--userns hostoption. Rootless configurations are currently unsupported.
Below are links to CI systems that we have more specific information for. If you run into anything in your CI that wasn't covered here, we would love to add it to our documentation. Pull requests are welcome!