Earthly is a build tool that combines the best of Dockerfiles and Makefiles. Every build runs in containers, so it works identically on your laptop and in CI. It's free, open source, and has a cloud service for caching and satellites.
Why Earthly?
- Reproducible — containerized builds, same result everywhere
- Familiar syntax — if you know Dockerfile + Makefile, you know Earthly
- Caching — automatic layer caching, shared across team via Earthly Cloud
- Multi-language — Go, Python, JS, Rust, Java — all in one Earthfile
- Parallelism — automatic parallel execution of independent targets
Install
# Linux/Mac
curl -sSfL https://github.com/earthly/earthly/releases/latest/download/earthly-$(uname -s)-$(uname -m) -o /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly
# Or via brew
brew install earthly
# Bootstrap (sets up BuildKit)
earthly bootstrap
Earthfile (Like Dockerfile + Makefile)
# Earthfile
VERSION 0.8
# Base image with dependencies
deps:
FROM node:20-alpine
WORKDIR /app
COPY package.json package-lock.json .
RUN npm ci
SAVE IMAGE --cache-hint
# Run tests
test:
FROM +deps
COPY src/ src/
COPY tests/ tests/
RUN npm test
# Build the app
build:
FROM +deps
COPY src/ src/
RUN npm run build
SAVE ARTIFACT dist/ /dist AS LOCAL ./dist
# Docker image
docker:
FROM +build
EXPOSE 3000
CMD ["node", "dist/index.js"]
SAVE IMAGE myapp:latest
# Run everything
all:
BUILD +test
BUILD +docker
# Run specific target
earthly +test
# Run all targets
earthly +all
# Build and push Docker image
earthly --push +docker
Multi-Language Monorepo
# Earthfile for monorepo
VERSION 0.8
# Go backend
backend-test:
FROM golang:1.22-alpine
WORKDIR /app
COPY backend/go.mod backend/go.sum .
RUN go mod download
COPY backend/ .
RUN go test ./...
backend-build:
FROM +backend-test
RUN go build -o server ./cmd/server
SAVE ARTIFACT server /server
# Python ML service
ml-test:
FROM python:3.12-slim
WORKDIR /app
COPY ml/requirements.txt .
RUN pip install -r requirements.txt
COPY ml/ .
RUN pytest
# Frontend
frontend-build:
FROM node:20-alpine
WORKDIR /app
COPY frontend/package*.json .
RUN npm ci
COPY frontend/ .
RUN npm run build
SAVE ARTIFACT build/ /build
# All tests in parallel (automatic!)
test-all:
BUILD +backend-test
BUILD +ml-test
BUILD +frontend-build
CI Integration
# .github/workflows/ci.yml
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: earthly/actions-setup@v1
- run: earthly +test-all
Earthly Cloud (Free Tier)
# Login to Earthly Cloud
earthly account login
# Use remote cache (team shares cache)
earthly --ci --remote-cache=myorg/myrepo +all
# Earthly Satellites (remote BuildKit)
earthly sat launch my-satellite
earthly --sat my-satellite +all
Key Features
| Feature | Details |
|---|---|
| Syntax | Dockerfile + Makefile hybrid |
| Execution | Containerized (BuildKit) |
| Caching | Layer cache, remote cache |
| Parallelism | Automatic for independent targets |
| Artifacts | Export files or Docker images |
| CI | GitHub Actions, GitLab, Jenkins, etc. |
| Cloud | Free tier with remote caching |
Resources
Need CI/CD optimization or custom build tools? Check my automation tools on Apify or email spinov001@gmail.com.
Top comments (0)