Examples
Examples of CI integration
Examples of integrating EarthBuild into various CI systems can be found on the following pages:
For more general information on CI systems not listed above, see the CI integration guide.
Examples by dev environments
Examples of how EarthBuild can be integrated into different dev environments
GitHub Codespaces - shows how Earthfiles can be used in GitHub Codespaces and Devcontainers
Example Earthfiles
In this section, you will find some examples of Earthfiles to familiarize yourself with EarthBuild.
The code for all the examples is available in the examples GitHub directory.
Examples from the Basics tutorial
If you are new to EarthBuild, you may find the Basics tutorial helpful.
Examples by language
Please note that these examples, although similar, are distinct from the ones used in the tutorial.
Examples by use-cases
integration-test - shows how
WITH DOCKERanddocker-composecan be used to start up services and then run an integration test suite.monorepo - shows how multiple sub-projects can be co-located in a single repository and how the build can be fragmented across these.
multirepo - shows how artifacts from multiple repositories can be referenced in a single build. See also the
grpcexample for a more extensive use-case.
Examples by EarthBuild features
import - shows how to use the
IMPORTcommand to alias Earthfile references.cutoff-optimization - shows that if an intermediate artifact does not change, then the rest of the build will use the cache, even if the source has changed.
multiplatform - shows how EarthBuild can execute builds and create images for multiple platforms, using QEMU emulation.
multiplatform-cross-compile - shows has through the use of cross-compilation, you can create images for multiple platforms, without using QEMU emulation.
Examples by use of other technologies
grpc - shows how to use EarthBuild to compile a protobuf grpc definition into protobuf code for both a Go-based server, and a python-based client, in a multirepo setup.
terraform - shows how Terraform could be used from EarthBuild.
Other
readme - some sample code we used in our README.
tests - a suite of tests EarthBuild uses to ensure that its features are working correctly.
Larger Examples And Community Examples
The repositories below predate the EarthBuild fork and are maintained under the earth organization, so they invoke the CLI as earth rather than earth. The Earthfile syntax they demonstrate applies unchanged to EarthBuild -- treat them as examples of Earthfile usage rather than as current installation or invocation guidance.
EarthBuild's own build
As a distinct example of a complete build, you can take a look at EarthBuild's own build. EarthBuild builds itself, and the build files are available on GitHub:
Earthfile - the root build file
buildkitd/Earthfile - the build of the BuildKit daemon
AST/parser/Earthfile - the build of the parser, which generates .go files
tests/Earthfile - system and smoke tests
earthfile-grammar/Earthfile - the build of the VS Code extension
To invoke EarthBuild's build, check out the code and then run the following in the root of the repository
Last updated