Earthly — Build Automation for the Container Era
Earthly combines the best of Dockerfiles and Makefiles into a single repeatable build tool. Define builds in an Earthfile, and Earthly caches, parallelizes, and runs them identically on laptop or CI.
What it is
Earthly is a build automation tool that runs builds inside containers, ensuring they work the same on your laptop, your teammate's laptop, and in CI. It uses an Earthfile (similar to a Dockerfile) to define build targets with explicit inputs and outputs. Each target runs in an isolated container with caching, parallelism, and dependency management built in.
Earthly is for teams frustrated by builds that pass locally but fail in CI, or vice versa. If you maintain complex Makefiles, Bash scripts, or multi-step CI configurations, Earthly replaces them with a single, reproducible definition.
How it saves time or tokens
Earthly eliminates the 'works on my machine' problem by running builds in containers. Layer caching means only changed steps re-execute, saving minutes on each build. Parallel execution of independent targets reduces total build time. A single Earthfile replaces Makefiles, shell scripts, and CI-specific configuration files. For AI workflows, the declarative Earthfile syntax is concise and easy to generate or review.
How to use
- Install Earthly:
brew install earthly(macOS) or follow the install guide for your OS. - Create an Earthfile in your project root defining build targets.
- Run targets with
earthly +build,earthly +test, etc.
Example
# Earthfile
VERSION 0.8
FROM golang:1.23
WORKDIR /app
deps:
COPY go.mod go.sum .
RUN go mod download
SAVE IMAGE --cache-hint
build:
FROM +deps
COPY . .
RUN go build -o bin/myapp ./cmd/myapp
SAVE ARTIFACT bin/myapp AS LOCAL bin/myapp
test:
FROM +deps
COPY . .
RUN go test ./...
docker:
FROM alpine:3.19
COPY +build/myapp /usr/local/bin/myapp
ENTRYPOINT ["/usr/local/bin/myapp"]
SAVE IMAGE myapp:latest
Related on TokRepo
- DevOps AI tools -- build and deployment automation tools
- AI tools for automation -- CI/CD and workflow automation
Common pitfalls
- Not using cache hints on dependency steps. Mark dependency download steps with SAVE IMAGE --cache-hint so they persist across builds. Without caching, every build re-downloads dependencies.
- Mixing Earthly with traditional CI scripts. Earthly works best when it owns the build definition end-to-end. Your CI config should just call
earthly +targetrather than duplicating build logic. - Forgetting that each target runs in a fresh container. Files from one target are not available in another unless explicitly passed with COPY +target/artifact.
Frequently Asked Questions
Docker multi-stage builds are limited to building container images. Earthly extends the concept to general build automation -- tests, linting, code generation, artifact creation, and more. Earthly targets can produce files, images, or both, with explicit dependency tracking between targets.
Yes. Earthly runs in any CI environment that has Docker. GitHub Actions, GitLab CI, Jenkins, CircleCI, and others are supported. The build runs identically in CI and locally because both use the same containerized execution.
Yes. Earthly supports cross-referencing targets across directories and even across repositories. A top-level Earthfile can orchestrate builds for multiple services in a mono-repo with proper dependency ordering and parallel execution.
Earthly is language-agnostic. Since builds run in containers, any language or toolchain available in a Docker image works. Go, Python, Node.js, Rust, Java, and C++ all work with the same Earthfile syntax.
Earthly CLI is open-source and free. Earthly Cloud provides remote caching and build sharing for teams, with a free tier for small projects and paid plans for larger teams.
Citations (3)
- Earthly GitHub— Earthly provides containerized reproducible builds
- Earthly Earthfile Docs— Earthfile syntax for defining build targets
- Earthly Caching Docs— Caching and parallelism for faster builds
Related on TokRepo
Discussion
Related Assets
NAPI-RS — Build Node.js Native Addons in Rust
Write high-performance Node.js native modules in Rust with automatic TypeScript type generation and cross-platform prebuilt binaries.
Mamba — Fast Cross-Platform Package Manager
A drop-in conda replacement written in C++ that resolves environments in seconds instead of minutes.
Plasmo — The Browser Extension Framework
Build, test, and publish browser extensions for Chrome, Firefox, and Edge using React or Vue with hot-reload and automatic manifest generation.