ScriptsApr 14, 2026·3 min read

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.

TL;DR
Earthly provides containerized, reproducible builds using Dockerfile-like syntax that runs identically on your laptop and in CI.
§01

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.

§02

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.

§03

How to use

  1. Install Earthly: brew install earthly (macOS) or follow the install guide for your OS.
  2. Create an Earthfile in your project root defining build targets.
  3. Run targets with earthly +build, earthly +test, etc.
§04

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
§05

Related on TokRepo

§06

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 +target rather 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

How does Earthly compare to Docker multi-stage builds?+

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.

Does Earthly work in CI/CD?+

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.

Can Earthly handle mono-repos?+

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.

What languages does Earthly support?+

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.

Is Earthly free?+

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)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets