DEV Community

Alex Spinov
Alex Spinov

Posted on

Earthly Is Free — Makefile + Docker = Reproducible Builds

The Problem With CI/CD

Your build works locally but fails in CI. Different Node versions, missing system libraries, environment differences. Earthly fixes this.

What Earthly Does

Earthly = Makefile syntax + Docker isolation. Every step runs in a container. Same result everywhere.

Earthfile

VERSION 0.8

build:
    FROM node:20
    WORKDIR /app
    COPY package.json package-lock.json .
    RUN npm ci
    COPY . .
    RUN npm run build
    SAVE ARTIFACT dist AS LOCAL dist

test:
    FROM +build
    RUN npm test

docker:
    FROM +build
    EXPOSE 3000
    CMD ["node", "dist/server.js"]
    SAVE IMAGE my-app:latest

all:
    BUILD +test
    BUILD +docker
Enter fullscreen mode Exit fullscreen mode

Usage

# Install
curl -sSfL https://earthly.dev/get-earthly | sh

# Run
earthly +build    # Build only
earthly +test     # Build + test
earthly +docker   # Build + create Docker image
earthly +all      # Everything
Enter fullscreen mode Exit fullscreen mode

Why Earthly

  • Same build locally and in CI
  • Layer caching (fast rebuilds)
  • Multi-platform builds
  • Parallel execution
  • Works with any CI (GitHub Actions, GitLab, Jenkins)

Earthly vs Alternatives

Feature Earthly Makefile Docker Bazel
Reproducible Yes No Partial Yes
Caching Docker layers None Layers Advanced
Learning curve 30 min 10 min 1 hour 1 week
Language support Any Any Any Limited

More


More from me: 10 Dev Tools I Use Daily | 77 Scrapers on a Schedule | 150+ Free APIs
Also: Neon Free Postgres | Vercel Free API | Hetzner 4x More Server

Top comments (0)