earthly

earthly

基于容器的构建框架 实现可重复和高效的CI/CD流程

Earthly是一个基于容器的CI/CD框架,通过将所有构建流程在容器中执行,实现可重复和一致的构建。它采用简单易懂的语法,结合了Dockerfile和Makefile的优点。Earthly支持多种编程语言和构建工具,适用于单仓库和多仓库项目。通过并行执行和缓存机制,Earthly可以显著提高构建速度。它还支持跨Earthfile重用构建目标、构件和镜像,提升开发效率。Earthly不仅可以在本地开发环境使用,还能无缝集成到各种CI/CD平台中。

Earthly容器化构建CI/CD并行执行缓存机制Github开源项目
<h1>Earthly</h1> <div align="center"> <a href="https://earthly.dev"><img src="img/logo-banner-white-bg.png" alt="Earthly" width="700px" /></a> <br/> <em>It’s like Docker for builds</em> </div> <br/>

GitHub Actions CI Join the chat on Slack Docs Website Install Earthly Docker Hub License MPL-2

Open in GitHub Codespaces

🔁 Repeatable Builds - Write builds once, and run them anywhere – on your laptop, remote, and in any CI.

❤️ Super Simple - Instantly recognizable syntax – like Dockerfile and Makefile had a baby.

🛠 Compatible with Every Language, Framework, and Build Tool - If it runs on Linux, it runs on Earthly.

🏘 Great for Monorepos and Polyrepos - Organize your build logic however makes the most sense for your project.

💨 Fast Builds - Build caching and parallel execution makes builds fast automatically.

♻️ Reuse, Don't Repeat - Never write the same code in multiple builds again.


🌎 Earthly is a versatile, approachable CI/CD framework that runs every pipeline inside containers, giving you repeatable builds that you write once and run anywhere. It has a super simple, instantly recognizable syntax that is easy to write and understand – like Dockerfile and Makefile had a baby. And it leverages and augments popular build tools instead of replacing them, so you don’t have to rewrite all your builds no matter what languages you use.

<br/> <div align="center"><a href="https://earthly.dev/get-earthly"><img src="docs/img/get-earthly-button.png" alt="Get Earthly" title="Get Earthly" /></a></div>
<h2 align="center">Table of Contents</h2> <h2 align="center">Why Use Earthly?</h2>

🔁 Repeatable Builds

Earthly runs all builds in containers, making them self-contained, isolated, repeatable, and portable. This allows for faster iteration on build scripts and easier debugging when something goes wrong – no more git commit -m "try again". When you write a build, you know it will execute correctly no matter where it runs – your laptop, a colleague’s laptop, or any CI. You don’t have to configure language-specific tooling, install additional dependencies, or complicate your build scripts to ensure they are compatible with different OSs. Earthly gives you consistent, repeatable builds regardless of where they run.

❤️ Super Simple

Earthly’s syntax is easy to write and understand. Most engineers can read an Earthfile instantly, without prior knowledge of Earthly. We combined some of the best ideas from Dockerfiles and Makefiles into one specification – like Dockerfile and Makefile had a baby.

🛠 Compatible with Every Language, Framework, and Build Tool

Earthly works with the compilers and build tools you use. If it runs on Linux, it runs on Earthly. And you don’t have to rewrite your existing builds or replace your package.json, go.mod, build.gradle, or Cargo.toml files. You can use Earthly as a wrapper around your existing tooling and still get Earthly’s repeatable builds, parallel execution, and build caching.

🏘 Great for Monorepos and Polyrepos

Earthly is great for both monorepos and polyrepos. You can split your build logic across multiple Earthfiles, placing some deeper inside the directory structure or even in other repositories. Referencing targets from other Earthfiles is easy regardless of where they are stored. So you can organize your build logic however makes the most sense for your project.

💨 Fast Builds

Earthly automatically executes build targets in parallel and makes maximum use of cache. This makes builds fast. Earthly also has powerful shared caching capabilities that speed up builds frequently run across a team or in sandboxed environments, such as Earthly Satellites, GitHub Actions, or your CI.

If your build has multiple steps, Earthly will:

  1. Build a directed acyclic graph (DAG).
  2. Isolate execution of each step.
  3. Run independent steps in parallel.
  4. Cache results for future use.

♻️ Reuse, Don't Repeat

Never have to write the same code in multiple builds again. With Earthly, you can reuse targets, artifacts, and images across multiple Earthfiles, even ones in other repositories, in a single line. Earthly is cache-aware, based on the individual hashes of each file, and has shared caching capabilities. So you can create a vast and efficient build hierarchy that only executes the minimum required steps.

<h2 align="center">Where Does Earthly Fit?</h2> <div align="center"><img src="docs/img/integration-diagram-v2.png" alt="Earthly fits between language-specific tooling and the CI" width="700px" /></div>

Earthly is meant to be used both on your development machine and in CI. It runs on top of your CI/CD platform (such as Jenkins, Circle CI, GitHub Actions, and GitLab CI/CD). Earthly provides the benefits of a modern build automation system wherever it runs – such as caching and parallelism. It is a glue layer between language-specific build tooling (like maven, gradle, npm, pip, go build) and CI, working like a wrapper around your build tooling and build logic that isolates build execution from the environments they run in.

<h2 align="center">How Does It Work?</h2>

In short: containers, layer caching, and complex build graphs!

Earthly executes builds in containers, where execution is isolated. The dependencies of the build are explicitly specified in the build definition, thus making the build self-sufficient.

We use a target-based system to help users break up complex builds into reusable parts. Nothing is shared between targets other than clearly declared dependencies. Nothing shared means no unexpected race conditions. In fact, the build is executed in parallel whenever possible, without any need for the user to take care of any locking or unexpected environment interactions.

ℹ️ Note Earthfiles might seem very similar to Dockerfile multi-stage builds. In fact, the same technology is used underneath. However, a key difference is that Earthly is designed to be a general-purpose build system, not just a Docker image specification. Read more about how Earthly is different from Dockerfiles.

<h2 align="center">Installation</h2>

See installation instructions.

To build from source, check the contributing page.

<h2 align="center">Quick Start</h2>

Here are some resources to get you started with Earthly

See also the full documentation.

Reference pages

A simple example (for Go)

# Earthfile VERSION 0.8 FROM golang:1.15-alpine3.13 RUN apk --update --no-cache add git WORKDIR /go-example all: BUILD +lint BUILD +docker build: COPY main.go . RUN go build -o build/go-example main.go SAVE ARTIFACT build/go-example AS LOCAL build/go-example lint: RUN go get golang.org/x/lint/golint COPY main.go . RUN golint -set_exit_status ./... docker: COPY +build/go-example . ENTRYPOINT ["/go-example/go-example"] SAVE IMAGE go-example:latest
// main.go package main import "fmt" func main() { fmt.Println("hello world") }

Invoke the build using earthly +all.

<div align="center"><a href="https://asciinema.org/a/351683?speed=2"><img src="img/demo-351683.gif" alt="Demonstration of a simple Earthly build" title="View on asciinema.org" width="600px" /></a></div>

Examples for other languages are available in the examples dir.

<h2 align="center">Features</h2>

⛓ Parallelization that just works

Whenever possible, Earthly automatically executes targets in parallel.

<div align="center"><a href="https://asciinema.org/a/351678?speed=2"><img src="img/demo-351678.gif" alt="Demonstration of Earthly's parallelization" title="View on asciinema.org" width="600px" /></a></div>

💾 Caching that works the same as Docker builds

Cut down build times in CI through shared remote caching.

<div align="center"><a href="https://asciinema.org/a/351674?speed=2"><img src="img/demo-351674.gif" alt="Demonstration of Earthly's caching" title="View on asciinema.org" width="600px" /></a></div>

🛠 Multi-platform support

Build for multiple platforms in parallel.

VERSION 0.8 all: BUILD \ --platform=linux/amd64 \ --platform=linux/arm64 \ --platform=linux/arm/v7 \ --platform=linux/arm/v6 \ +build build: FROM alpine:3.18 CMD ["uname", "-m"] SAVE IMAGE multiplatform-image

🤲 Build tools that work everywhere

No need to ask your team to install protoc, a specific version of Python, Java 1.6, or the .NET Core ecosystem. Install once in your Earthfile, and it works for everyone. Or even better, you can just make use of the rich Docker Hub ecosystem.

VERSION 0.8 FROM golang:1.15-alpine3.13 WORKDIR /proto-example proto: FROM namely/protoc-all:1.29_4 COPY api.proto /defs RUN --entrypoint -- -f api.proto -l go SAVE ARTIFACT ./gen/pb-go /pb AS LOCAL pb build: COPY go.mod go.sum . RUN go mod download COPY +proto/pb pb COPY main.go ./ RUN go build -o build/proto-example main.go SAVE ARTIFACT build/proto-example

See full example code.

📦 Modern import system

Earthly can be used to reference and build targets from other directories or even other repositories. For example, if we wanted to build an example target from the github.com/earthly/earthly repository, we could issue

# Try it yourself! No need to clone. earthly github.com/earthly/earthly/examples/go:main+docker # Run the resulting image. docker run --rm earthly/examples:go

🔨 Reference other targets using +

Use + to reference other targets and create complex build inter-dependencies.

<div align="center"><a href="https://docs.earthly.dev/guides/target-ref"><img src="docs/guides/img/ref-infographic-v2.png" alt="Target and artifact reference syntax" title="Reference targets using +" width="600px" /></a></div>

Examples

  • Same directory (same Earthfile)

    BUILD +some-target FROM +some-target COPY +some-target/my-artifact ./
  • Other directories

    BUILD ./some/local/path+some-target FROM ./some/local/path+some-target COPY ./some/local/path+some-target/my-artifact ./
  • Other repositories

    BUILD github.com/someone/someproject:v1.2.3+some-target FROM github.com/someone/someproject:v1.2.3+some-target COPY github.com/someone/someproject:v1.2.3+some-target/my-artifact ./

🔑 Cloud secrets support built-in

Secrets are never stored within an image's layers and they are only available to the commands that need them.

earthly set /user/github/token 'shhh...'
release: RUN --push --secret GITHUB_TOKEN=user/github/token github-release upload file.bin
<h2 align="center">FAQ</h2>

How is Earthly different from Dockerfiles?

Dockerfiles were designed for specifying the make-up of Docker images and that's where Dockerfiles stop. Earthly takes some key principles of Dockerfiles (like layer caching) but expands on the use cases. For example, Earthly can output regular artifacts, run unit and integration tests, and create several Docker images at a time - all outside the scope of Dockerfiles.

It is possible to use Dockerfiles in combination with other technologies (e.g., Makefiles or bash files) to solve such use cases. However, these combinations are difficult to parallelize, challenging to scale across repositories as they lack a robust import system, and often vary in style from one team to another. Earthly does not have these limitations as it was designed as a general-purpose build system.

For example, Earthly introduces a richer target, artifact, and image referencing system, allowing for better reuse in complex builds spanning a single large repository or multiple repositories. Because Dockerfiles are only meant to describe one image at a time, such features are outside the scope of applicability of Dockerfiles.

How do I know if a command is a classic Dockerfile command or an Earthly command?

Check out the Earthfile reference doc page. It has all the commands there and specifies which commands are the same as Dockerfile commands and which are new.

Can Earthly build Dockerfiles?

Yes! You can use the command FROM DOCKERFILE to inherit the commands in an existing Dockerfile.

build: FROM DOCKERFILE . SAVE IMAGE some-image:latest

You may also optionally port your Dockerfiles to Earthly entirely. Translating Dockerfiles to Earthfiles is usually a matter of copy-pasting and making minor adjustments. See the getting started page for some Earthfile examples.

How is Earthly different from Bazel?

Bazel is a build tool developed by Google to optimize the speed, correctness, and reproducibility of their internal monorepo codebase. The main difference between Bazel and Earthly is that Bazel is a build system, whereas Earthly is a general-purpose CI/CD framework. For a more in-depth explanation see

编辑推荐精选

音述AI

音述AI

全球首个AI音乐社区

音述AI是全球首个AI音乐社区,致力让每个人都能用音乐表达自我。音述AI提供零门槛AI创作工具,独创GETI法则帮助用户精准定义音乐风格,AI润色功能支持自动优化作品质感。音述AI支持交流讨论、二次创作与价值变现。针对中文用户的语言习惯与文化背景进行专门优化,支持国风融合、C-pop等本土音乐标签,让技术更好地承载人文表达。

QoderWork

QoderWork

阿里Qoder团队推出的桌面端AI智能体

QoderWork 是阿里推出的本地优先桌面 AI 智能体,适配 macOS14+/Windows10+,以自然语言交互实现文件管理、数据分析、AI 视觉生成、浏览器自动化等办公任务,自主拆解执行复杂工作流,数据本地运行零上传,技能市场可无限扩展,是高效的 Agentic 生产力办公助手。

lynote.ai

lynote.ai

一站式搞定所有学习需求

不再被海量信息淹没,开始真正理解知识。Lynote 可摘要 YouTube 视频、PDF、文章等内容。即时创建笔记,检测 AI 内容并下载资料,将您的学习效率提升 10 倍。

AniShort

AniShort

为AI短剧协作而生

专为AI短剧协作而生的AniShort正式发布,深度重构AI短剧全流程生产模式,整合创意策划、制作执行、实时协作、在线审片、资产复用等全链路功能,独创无限画布、双轨并行工业化工作流与Ani智能体助手,集成多款主流AI大模型,破解素材零散、版本混乱、沟通低效等行业痛点,助力3人团队效率提升800%,打造标准化、可追溯的AI短剧量产体系,是AI短剧团队协同创作、提升制作效率的核心工具。

seedancetwo2.0

seedancetwo2.0

能听懂你表达的视频模型

Seedance two是基于seedance2.0的中国大模型,支持图像、视频、音频、文本四种模态输入,表达方式更丰富,生成也更可控。

nano-banana纳米香蕉中文站

nano-banana纳米香蕉中文站

国内直接访问,限时3折

输入简单文字,生成想要的图片,纳米香蕉中文站基于 Google 模型的 AI 图片生成网站,支持文字生图、图生图。官网价格限时3折活动

扣子-AI办公

扣子-AI办公

职场AI,就用扣子

AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!

堆友

堆友

多风格AI绘画神器

堆友平台由阿里巴巴设计团队创建,作为一款AI驱动的设计工具,专为设计师提供一站式增长服务。功能覆盖海量3D素材、AI绘画、实时渲染以及专业抠图,显著提升设计品质和效率。平台不仅提供工具,还是一个促进创意交流和个人发展的空间,界面友好,适合所有级别的设计师和创意工作者。

图像生成AI工具AI反应堆AI工具箱AI绘画GOAI艺术字堆友相机AI图像热门
码上飞

码上飞

零代码AI应用开发平台

零代码AI应用开发平台,用户只需一句话简单描述需求,AI能自动生成小程序、APP或H5网页应用,无需编写代码。

Vora

Vora

免费创建高清无水印Sora视频

Vora是一个免费创建高清无水印Sora视频的AI工具

下拉加载更多