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.
先审查再安装
这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。
npx -y tokrepo@latest install 641e0288-37c8-11f1-9bc6-00163e2b0d79 --target codex先 dry-run,确认写入项后再运行此命令。
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.
常见问题
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.
引用来源 (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
TokRepo 相关
讨论
相关资产
Concourse — Container-Native CI/CD with Pipelines as Code
Build reliable CI/CD pipelines with Concourse. Every step runs in an isolated container, pipelines are declarative YAML, and the resource model makes dependencies explicit and reproducible.
Docker Compose — Define and Run Multi-Container Applications
Docker Compose lets you define multi-container application stacks in a single YAML file and manage their full lifecycle with simple CLI commands.
Sysdig — Deep System Visibility and Container Troubleshooting for Linux
Sysdig is an open-source system exploration tool that captures kernel-level events on Linux. It combines the power of strace, tcpdump, and top into a single CLI with container-native awareness.
Jackett — Unified Torrent Indexer API for Media Automation
A proxy server that translates queries from media automation apps like Sonarr and Radarr into site-specific requests for torrent indexers, providing a single API interface.