Skip to content

Commit 72cebdd

Browse files
author
Vlad A. Ionescu
committed
Initial commit.
1 parent 1346b2b commit 72cebdd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+15966
-2
lines changed

.earthignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build
2+
earthfile2llb/parser/*.go
3+
examples
4+
.git

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/build/
2+
/examples/go/build/
3+
*.tokens
4+
*.interp
5+
.antlr/

README.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,47 @@
1-
# earthly
2-
A build system for inhabitants of planet earth
1+
# 🌎 Earthly - a build system for inhabitants of planet earth
2+
3+
*Parallel, reproducible, consistent and portable builds for the same era as your code*
4+
5+
## Why
6+
7+
TODO: Simplify this by moving details into launch blog post. Keep only the essence here.
8+
9+
Why does the world need a new build system?
10+
11+
We live in an era of containers, CI/CD, automation, rich set of programming languages, varying code structures (mono/poly-repos) and open-source collaboration. None of the build systems out there serve well these new trends:
12+
13+
* They don't take advantage of container-based isolation to make the builds portable
14+
* Builds are not easily reproducible - they often depend on already installed dependencies
15+
* They don't provide a way to import open-source recipes
16+
* Many are programming language-specific, making them unattractive to be used as a one-stop-shop
17+
* Parallelization ranges from difficult to almost impossible
18+
* Importing and reusability are primitive or difficult to use across repos
19+
* Caching is difficult to master, making it impossible to scale the build system in a mono-repo
20+
* They are difficult to use, leading to a build system guru situation (only one person knows how the build works)
21+
* Or a combination of the above.
22+
23+
Of the popular choices out there, the options that come close are [Bazel](https://bazel.build/) and [Dockerfiles](https://docs.docker.com/engine/reference/builder/). Both are excellent, yet there are challenges: Bazel is difficult to adopt because it requires an all-in approach (are you ready to completely rewrite the build.gradle's in your org into [Bazel BUILD files](https://docs.bazel.build/versions/master/tutorial/java.html)?). Dockerfiles are great, but they only output images. You can subsequently use docker run commands and mounted volumes to output other kinds of artifacts - but that requires that you now wrap your docker builds into Makefiles or some other build system.
24+
25+
Earthly accepts the reality that for some languages, the best build system is provided by the community of that language (like gradle, webpack, sbt etc), yet it adds the Dockerfile-like caching on top, plus more flexibility in defining hierarchies of dependencies for caching and reusability.
26+
27+
### Benefits
28+
29+
Here's what you get with Earthly:
30+
31+
* Consistent environment between developers and with CI
32+
* Programming language agnostic
33+
* No need to install project-specific dependencies - the build is self-contained
34+
* First-party support for Docker
35+
* Syntax easy to understand even with no previous experience
36+
* Efficient use of caching, that is easy to understand by anyone
37+
* Simple parallelism, without the gnarly race conditions
38+
* Like a docker build but it can also yield classical artifacts (packages, binaries etc)
39+
owned by the user, not by root
40+
* Mono-repo friendly (reference targets within subdirs, with no strings attached)
41+
* Multi-repo friendly (reference targets in other repos just as easily)
42+
* In a complex setup, ability to trigger rebuild of only affected targets and tests
43+
* An import system that is easy to use and has no hidden implications
44+
45+
## Dive in
46+
47+
... TODO

build.earth

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
FROM golang:1.13-alpine3.10
2+
3+
RUN apk add --update --no-cache \
4+
openssl \
5+
ca-certificates \
6+
bash \
7+
bash-completion \
8+
util-linux \
9+
grep \
10+
less \
11+
binutils \
12+
findutils \
13+
coreutils \
14+
grep \
15+
less \
16+
git \
17+
g++ \
18+
curl \
19+
make
20+
21+
ENV GOCACHE=/go-cache
22+
WORKDIR /earthly
23+
24+
deps:
25+
RUN go get golang.org/x/tools/cmd/goimports
26+
RUN go get golang.org/x/lint/golint
27+
COPY go.mod go.sum ./
28+
RUN go mod download
29+
SAVE ARTIFACT go.mod /go.mod AS LOCAL go.mod
30+
SAVE ARTIFACT go.sum /go.sum AS LOCAL go.sum
31+
SAVE IMAGE
32+
33+
code:
34+
FROM +deps
35+
COPY builder builder
36+
COPY buildcontext buildcontext
37+
COPY buildkitd/buildkitd.go buildkitd/settings.go buildkitd/
38+
COPY cleanup cleanup
39+
COPY cmd cmd
40+
COPY conslogging conslogging
41+
COPY dockertar dockertar
42+
COPY domain domain
43+
COPY earthfile2llb/*.go earthfile2llb/
44+
COPY earthfile2llb/dedup earthfile2llb/dedup
45+
COPY earthfile2llb/image earthfile2llb/image
46+
COPY --artifact ./earthfile2llb/parser+parser/*.go ./earthfile2llb/parser/
47+
COPY earthfile2llb/variables earthfile2llb/variables
48+
COPY llbutil llbutil
49+
COPY logging logging
50+
SAVE IMAGE
51+
52+
lint:
53+
FROM +code
54+
RUN output="$(goimports -d .)" ; test -z "$output" || (echo "$output" && exit 1)
55+
RUN golint -set_exit_status .
56+
57+
earth:
58+
FROM +code
59+
ARG GOOS=linux
60+
ARG GOARCH=amd64
61+
ARG GO_EXTRA_LDFLAGS="-linkmode external -extldflags -static"
62+
RUN test -n "$GOOS"
63+
RUN test -n "$GOARCH"
64+
RUN \
65+
--mount=type=cache,target=/go-cache \
66+
go build \
67+
-ldflags "$GO_EXTRA_LDFLAGS" \
68+
-o build/earth \
69+
cmd/earth/*.go
70+
SAVE ARTIFACT build/earth /earth AS LOCAL "build/$GOOS/$GOARCH/earth"
71+
72+
earth-all:
73+
BUILD +earth
74+
BUILD \
75+
--build-arg=GOOS=darwin \
76+
--build-arg=GOARCH=amd64 \
77+
--build-arg=GO_EXTRA_LDFLAGS= \
78+
+earth
79+
80+
earth-docker:
81+
FROM ./buildkitd+buildkitd
82+
ENV ENABLE_LOOP_DEVICE=false
83+
COPY earth-buildkitd-wrapper.sh /usr/bin/earth-buildkitd-wrapper.sh
84+
ENTRYPOINT /usr/bin/earth-buildkitd-wrapper.sh
85+
COPY --artifact +earth/earth /usr/bin/earth
86+
SAVE IMAGE earthly/earth:latest
87+
88+
all:
89+
BUILD +earth-all
90+
BUILD +earth-docker
91+
BUILD ./buildkitd+buildkitd
92+
93+
test:
94+
BUILD +lint
95+
BUILD ./examples/tests+all
96+
97+
test-experimental:
98+
BUILD ./examples/tests+experimental

0 commit comments

Comments
 (0)