-
Notifications
You must be signed in to change notification settings - Fork 386
/
Earthfile
613 lines (553 loc) · 22.6 KB
/
Earthfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
VERSION --shell-out-anywhere --use-copy-link 0.6
FROM golang:1.17-alpine3.14
RUN apk add --update --no-cache \
bash \
bash-completion \
binutils \
ca-certificates \
coreutils \
curl \
findutils \
g++ \
git \
grep \
less \
make \
openssl \
util-linux
WORKDIR /earthly
deps:
FROM +base
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0
COPY go.mod go.sum ./
COPY ./ast/go.mod ./ast/go.sum ./ast
RUN go mod download
SAVE ARTIFACT go.mod AS LOCAL go.mod
SAVE ARTIFACT go.sum AS LOCAL go.sum
code:
FROM +deps
# Use BUILDKIT_PROJECT to point go.mod to a buildkit dir being actively developed.
# --BUILDKIT_PROJECT=../buildkit or --BUILDKIT_PROJECT=github.com/earthly/buildkit:4f1c968c3778a7140c56e3e6a755b7f2d38f2156
ARG BUILDKIT_PROJECT
IF [ "$BUILDKIT_PROJECT" != "" ]
COPY --dir "$BUILDKIT_PROJECT"+code/buildkit /buildkit
RUN go mod edit -replace github.com/moby/buildkit=/buildkit
RUN go mod download
END
COPY ./ast/parser+parser/*.go ./ast/parser/
COPY --dir analytics autocomplete buildcontext builder cleanup cmd config conslogging debugger dockertar \
docker2earthly domain features outmon slog cloud states util variables ./
COPY --dir buildkitd/buildkitd.go buildkitd/settings.go buildkitd/certificates.go buildkitd/
COPY --dir earthfile2llb/*.go earthfile2llb/
COPY --dir ast/antlrhandler ast/spec ast/*.go ast/
update-buildkit:
FROM +code # if we use deps, go mod tidy will remove a bunch of requirements since it won't have access to our codebase.
ARG BUILDKIT_GIT_SHA
ARG BUILDKIT_GIT_BRANCH=earthly-main
ARG BUILDKIT_GIT_ORG=earthly
COPY (./buildkitd+buildkit-sha/buildkit_sha --BUILDKIT_GIT_ORG="$BUILDKIT_GIT_ORG" --BUILDKIT_GIT_SHA="$BUILDKIT_GIT_SHA" --BUILDKIT_GIT_BRANCH="$BUILDKIT_GIT_BRANCH") buildkit_sha
BUILD ./buildkitd+update-buildkit-earthfile --BUILDKIT_GIT_ORG="$BUILDKIT_GIT_ORG" --BUILDKIT_GIT_SHA="$(cat buildkit_sha)"
RUN --no-cache go mod edit -replace "github.com/moby/buildkit=github.com/$BUILDKIT_GIT_ORG/buildkit@$(cat buildkit_sha)"
RUN --no-cache go mod tidy
SAVE ARTIFACT go.mod AS LOCAL go.mod
SAVE ARTIFACT go.sum AS LOCAL go.sum
lint-scripts-base:
FROM alpine:3.15
ARG TARGETARCH
IF [ $TARGETARCH == "arm64" ]
RUN echo "Downloading, and manually installing shellcheck for ARM" && \
wget https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.aarch64.tar.xz && \
tar -xf shellcheck-stable.linux.aarch64.tar.xz && \
mv shellcheck-stable/shellcheck /usr/bin/shellcheck
ELSE
RUN echo "Installing shellcheck from Alpine repos" && \
apk add --update --no-cache shellcheck
END
WORKDIR /shell_scripts
lint-scripts-misc:
FROM +lint-scripts-base
COPY ./earthly ./scripts/install-all-versions.sh ./buildkitd/entrypoint.sh ./earthly-entrypoint.sh \
./buildkitd/dockerd-wrapper.sh ./buildkitd/docker-auto-install.sh \
./release/envcredhelper.sh ./.buildkite/*.sh \
./scripts/tests/*.sh \
./scripts/*.sh \
./shell_scripts/
RUN shellcheck shell_scripts/*
lint-scripts-auth-test:
FROM +lint-scripts-base
COPY ./scripts/tests/auth/*.sh ./
# the auth test script make use of a common setup.sh which contain unused variables
# when run directly; so we must exclude checking this directly, and make use of the -x
# flag to source setup.sh during analysis.
RUN shellcheck -x test-*.sh
lint-scripts:
BUILD +lint-scripts-auth-test
BUILD +lint-scripts-misc
earthly-script-no-stdout:
# This validates the ./earthly script doesn't print anything to stdout (it should print to stderr)
# This is to ensure commands such as: MYSECRET="$(./earthly secrets get -n /user/my-secret)" work
FROM earthly/dind:alpine
RUN apk add --no-cache --update bash
COPY earthly .earthly_version_flag_overrides .
# This script performs an explicit "docker pull earthlybinaries:prerelease" which can cause rate-limiting
# to work-around this, we will copy an earthly binary in, and disable auto-updating (and therefore don't require a WITH DOCKER)
COPY +earthly/earthly /root/.earthly/earthly-prerelease
RUN EARTHLY_DISABLE_AUTO_UPDATE=true ./earthly --version > earthly-version-output
RUN test "$(cat earthly-version-output | wc -l)" = "1"
RUN grep '^earthly version.*$' earthly-version-output # only --version info should go to stdout
lint:
FROM +code
COPY ./.golangci.yaml ./
RUN golangci-lint run
RUN if find . -type f -name \*.go | xargs grep '"io/ioutil"'; then echo "io/ioutil is deprecated: https://go.dev/doc/go1.16#ioutil"; exit 1; fi
lint-newline-ending:
FROM alpine:3.15
WORKDIR /everything
COPY . .
# test that line endings are unix-style
RUN set -e; \
code=0; \
for f in $(find . -not -path "./.git/*" -type f \( -iname '*.go' -o -iname 'Earthfile' -o -iname '*.earth' -o -iname '*.md' \) | grep -v "ast/tests/empty-targets.earth" ); do \
if ! dos2unix < "$f" | cmp - "$f"; then \
echo "$f contains windows-style newlines and must be converted to unix-style (use dos2unix to fix)"; \
code=1; \
fi; \
done; \
exit $code
# test file ends with a single newline
RUN set -e; \
code=0; \
for f in $(find . -not -path "./.git/*" -type f \( -iname '*.yml' -o -iname '*.go' -o -iname '*.sh' -o -iname '*.template' -o -iname 'Earthfile' -o -iname '*.earth' -o -iname '*.md' \) | grep -v "ast/tests/empty-targets.earth" | grep -v "tests/version/version-only.earth" ); do \
if [ "$(tail -c 1 $f)" != "$(printf '\n')" ]; then \
echo "$f does not end with a newline"; \
code=1; \
fi; \
done; \
exit $code
RUN if [ "$(tail -c 1 ast/tests/empty-targets.earth)" = "$(printf '\n')" ]; then \
echo "$f is a special-case test which must not end with a newline."; \
exit 1; \
fi
# check for files with trailing newlines
RUN set -e; \
code=0; \
for f in $(find . -not -path "./.git/*" -type f \( -iname '*.go' -o -iname 'Earthfile' -o -iname '*.earth' -o -iname '*.md' \) | grep -v "ast/tests/empty-targets.earth" | grep -v "ast/parser/earth_parser.go" | grep -v "ast/parser/earth_lexer.go" ); do \
if [ "$(tail -c 2 $f)" == "$(printf '\n\n')" ]; then \
echo "$f has trailing newlines"; \
code=1; \
fi; \
done; \
exit $code
vale:
WORKDIR /
RUN curl -sfL https://install.goreleaser.com/github.com/ValeLint/vale.sh | sh -s v2.10.3
WORKDIR /etc/vale
COPY .vale/ .
markdown-spellcheck:
FROM --platform=linux/amd64 +vale
WORKDIR /everything
COPY . .
# TODO figure out a way to ignore this pattern in vale (doesn't seem to be working under spelling's filter option)
RUN find . -type f -iname '*.md' | xargs -n 1 sed -i 's/{[^}]*}//g'
# TODO remove the greps once the corresponding markdown files have spelling fixed (or techterms added to .vale/styles/HouseStyle/tech-terms/...
RUN find . -type f -iname '*.md' | xargs vale --config /etc/vale/vale.ini --output line --minAlertLevel error
unit-test:
FROM +code
COPY podman-setup.sh .
ARG testname # when specified, only run specific unit-test, otherwise run all.
WITH DOCKER
RUN ./podman-setup.sh && \
if [ -n "$testname" ]; then testarg="-run $testname"; fi && \
go test -timeout 20m $testarg ./...
END
changelog:
FROM scratch
COPY CHANGELOG.md .
SAVE ARTIFACT CHANGELOG.md
lint-changelog:
FROM python:3
COPY release/changelogparser.py /usr/bin/changelogparser
COPY CHANGELOG.md .
RUN changelogparser --changelog CHANGELOG.md
debugger:
FROM +code
ARG GOCACHE=/go-cache
ARG GO_EXTRA_LDFLAGS="-linkmode external -extldflags -static"
ARG EARTHLY_TARGET_TAG
ARG VERSION=$EARTHLY_TARGET_TAG
ARG EARTHLY_GIT_HASH
RUN --mount=type=cache,target=$GOCACHE \
go build \
-ldflags "-X main.Version=$VERSION -X main.GitSha=$EARTHLY_GIT_HASH $GO_EXTRA_LDFLAGS" \
-tags netgo -installsuffix netgo \
-o build/earth_debugger \
cmd/debugger/*.go
SAVE ARTIFACT build/earth_debugger
earthly:
FROM +code
ARG GOOS=linux
ARG TARGETARCH
ARG TARGETVARIANT
ARG GOARCH=$TARGETARCH
ARG VARIANT=$TARGETVARIANT
ARG GO_EXTRA_LDFLAGS="-linkmode external -extldflags -static"
ARG EXECUTABLE_NAME="earthly"
RUN test -n "$GOOS" && test -n "$GOARCH"
RUN test "$GOARCH" != "arm" || test -n "$VARIANT"
ARG EARTHLY_TARGET_TAG_DOCKER
ARG VERSION="dev-$EARTHLY_TARGET_TAG_DOCKER"
ARG EARTHLY_GIT_HASH
ARG DEFAULT_BUILDKITD_IMAGE=docker.io/earthly/buildkitd:$VERSION # The image needs to be fully qualified for alternative frontend support.
ARG BUILD_TAGS=dfrunmount dfrunsecurity dfsecrets dfssh dfrunnetwork dfheredoc forceposix
ARG GOCACHE=/go-cache
RUN mkdir -p build
RUN printf "$BUILD_TAGS" > ./build/tags && echo "$(cat ./build/tags)"
RUN printf '-X main.DefaultBuildkitdImage='"$DEFAULT_BUILDKITD_IMAGE" > ./build/ldflags && \
printf ' -X main.Version='"$VERSION" >> ./build/ldflags && \
printf ' -X main.GitSha='"$EARTHLY_GIT_HASH" >> ./build/ldflags && \
printf ' '"$GO_EXTRA_LDFLAGS" >> ./build/ldflags && \
echo "$(cat ./build/ldflags)"
# Important! If you change the go build options, you may need to also change them
# in https://github.com/earthly/homebrew-earthly/blob/main/Formula/earthly.rb
RUN --mount=type=cache,target=$GOCACHE \
GOARM=${VARIANT#v} go build \
-tags "$(cat ./build/tags)" \
-ldflags "$(cat ./build/ldflags)" \
-o build/$EXECUTABLE_NAME \
cmd/earthly/*.go
SAVE ARTIFACT ./build/tags
SAVE ARTIFACT ./build/ldflags
SAVE ARTIFACT build/$EXECUTABLE_NAME AS LOCAL "build/$GOOS/$GOARCH$VARIANT/$EXECUTABLE_NAME"
SAVE IMAGE --cache-from=earthly/earthly:main
earthly-linux-amd64:
COPY (+earthly/* \
--GOARCH=amd64 \
--VARIANT= \
) ./
SAVE ARTIFACT ./*
earthly-linux-arm64:
COPY (+earthly/* \
--GOARCH=arm64 \
--VARIANT= \
--GO_EXTRA_LDFLAGS= \
) ./
SAVE ARTIFACT ./*
earthly-darwin-amd64:
COPY (+earthly/* \
--GOOS=darwin \
--GOARCH=amd64 \
--VARIANT= \
--GO_EXTRA_LDFLAGS= \
) ./
SAVE ARTIFACT ./*
earthly-darwin-arm64:
COPY (+earthly/* \
--GOOS=darwin \
--GOARCH=arm64 \
--VARIANT= \
--GO_EXTRA_LDFLAGS= \
) ./
SAVE ARTIFACT ./*
earthly-windows-amd64:
COPY (+earthly/* \
--GOOS=windows \
--GOARCH=amd64 \
--VARIANT= \
--GO_EXTRA_LDFLAGS= \
--EXECUTABLE_NAME=earthly.exe \
) ./
SAVE ARTIFACT ./*
earthly-all:
COPY +earthly-linux-amd64/earthly ./earthly-linux-amd64
COPY +earthly-linux-arm64/earthly ./earthly-linux-arm64
COPY +earthly-darwin-amd64/earthly ./earthly-darwin-amd64
COPY +earthly-darwin-arm64/earthly ./earthly-darwin-arm64
COPY +earthly-windows-amd64/earthly.exe ./earthly-windows-amd64.exe
SAVE ARTIFACT ./*
earthly-docker:
ARG BUILDKIT_PROJECT
FROM ./buildkitd+buildkitd --BUILDKIT_PROJECT="$BUILDKIT_PROJECT"
RUN apk add --update --no-cache docker-cli libcap-ng-utils
ENV EARTHLY_IMAGE=true
COPY earthly-entrypoint.sh /usr/bin/earthly-entrypoint.sh
ENTRYPOINT ["/usr/bin/earthly-entrypoint.sh"]
WORKDIR /workspace
ARG EARTHLY_TARGET_TAG_DOCKER
ARG TAG="dev-$EARTHLY_TARGET_TAG_DOCKER"
COPY (+earthly/earthly --VERSION=$TAG) /usr/bin/earthly
SAVE IMAGE --push --cache-from=earthly/earthly:main earthly/earthly:$TAG
earthly-integration-test-base:
FROM +earthly-docker
ENV NO_DOCKER=1
ENV NETWORK_MODE=host # Note that this breaks access to embedded registry in WITH DOCKER.
ENV EARTHLY_VERSION_FLAG_OVERRIDES=no-use-registry-for-with-docker # Use tar-based due to above.
WORKDIR /test
# The inner buildkit requires Docker hub creds to prevent rate-limiting issues.
ARG DOCKERHUB_MIRROR
ARG DOCKERHUB_MIRROR_INSECURE
ARG DOCKERHUB_AUTH=true
ARG DOCKERHUB_USER_SECRET=+secrets/DOCKERHUB_USER
ARG DOCKERHUB_TOKEN_SECRET=+secrets/DOCKERHUB_TOKEN
IF [ -z $DOCKERHUB_MIRROR ]
# No mirror, easy CI and local use by all
ENV GLOBAL_CONFIG="{disable_analytics: true}"
IF [ "$DOCKERHUB_AUTH" = "true" ]
RUN --secret USERNAME=$DOCKERHUB_USER_SECRET \
--secret TOKEN=$DOCKERHUB_TOKEN_SECRET \
docker login --username="$USERNAME" --password="$TOKEN"
END
ELSE
# Use a mirror, supports mirroring Docker Hub only.
ENV EARTHLY_ADDITIONAL_BUILDKIT_CONFIG="[registry.\"docker.io\"]
mirrors = [\"$DOCKERHUB_MIRROR\"]"
IF [ "$DOCKERHUB_MIRROR_INSECURE" = "true" ]
ENV EARTHLY_ADDITIONAL_BUILDKIT_CONFIG="$EARTHLY_ADDITIONAL_BUILDKIT_CONFIG
[registry.\"$DOCKERHUB_MIRROR\"]
http = true
insecure = true"
END
# NOTE: newlines+indentation is important here, see https://github.com/earthly/earthly/issues/1764 for potential pitfalls
# yaml will convert newlines to spaces when using regular quoted-strings, therefore we will use the literal-style (denoted by `|`)
ENV GLOBAL_CONFIG="disable_analytics: true
buildkit_additional_config: |
$(echo "$EARTHLY_ADDITIONAL_BUILDKIT_CONFIG" | sed "s/^/ /g")
"
IF [ "$DOCKERHUB_AUTH" = "true" ]
RUN --secret USERNAME=$DOCKERHUB_USER_SECRET \
--secret TOKEN=$DOCKERHUB_TOKEN_SECRET \
docker login $DOCKERHUB_MIRROR --username="$USERNAME" --password="$TOKEN"
END
END
prerelease:
FROM alpine:3.15
ARG BUILDKIT_PROJECT
BUILD \
--platform=linux/amd64 \
--platform=linux/arm64 \
./buildkitd+buildkitd --TAG=prerelease --BUILDKIT_PROJECT="$BUILDKIT_PROJECT"
COPY (+earthly-all/* --VERSION=prerelease) ./
SAVE IMAGE --push earthly/earthlybinaries:prerelease
prerelease-script:
FROM alpine:3.15
COPY ./earthly ./
# This script is useful in other repos too.
SAVE ARTIFACT ./earthly
dind:
BUILD +dind-alpine
BUILD +dind-ubuntu
dind-alpine:
FROM docker:20.10.14-dind
COPY ./buildkitd/docker-auto-install.sh /usr/local/bin/docker-auto-install.sh
RUN docker-auto-install.sh
ARG EARTHLY_TARGET_TAG_DOCKER
ARG DIND_ALPINE_TAG=alpine-$EARTHLY_TARGET_TAG_DOCKER
ARG DOCKERHUB_USER=earthly
SAVE IMAGE --push --cache-from=earthly/dind:main $DOCKERHUB_USER/dind:$DIND_ALPINE_TAG
dind-ubuntu:
FROM ubuntu:20.04
COPY ./buildkitd/docker-auto-install.sh /usr/local/bin/docker-auto-install.sh
RUN docker-auto-install.sh
ARG EARTHLY_TARGET_TAG_DOCKER
ARG DIND_UBUNTU_TAG=ubuntu-$EARTHLY_TARGET_TAG_DOCKER
ARG DOCKERHUB_USER=earthly
SAVE IMAGE --push --cache-from=earthly/dind:ubuntu-main $DOCKERHUB_USER/dind:$DIND_UBUNTU_TAG
for-own:
ARG BUILDKIT_PROJECT
BUILD ./buildkitd+buildkitd --BUILDKIT_PROJECT="$BUILDKIT_PROJECT"
COPY +earthly/earthly ./
SAVE ARTIFACT ./earthly AS LOCAL ./build/own/earthly
for-linux:
ARG BUILDKIT_PROJECT
BUILD --platform=linux/amd64 ./buildkitd+buildkitd --BUILDKIT_PROJECT="$BUILDKIT_PROJECT"
BUILD ./ast/parser+parser
COPY +earthly-linux-amd64/earthly ./
SAVE ARTIFACT ./earthly AS LOCAL ./build/linux/amd64/earthly
for-darwin:
ARG BUILDKIT_PROJECT
BUILD --platform=linux/amd64 ./buildkitd+buildkitd --BUILDKIT_PROJECT="$BUILDKIT_PROJECT"
BUILD ./ast/parser+parser
COPY +earthly-darwin-amd64/earthly ./
SAVE ARTIFACT ./earthly AS LOCAL ./build/darwin/amd64/earthly
for-darwin-m1:
ARG BUILDKIT_PROJECT
BUILD --platform=linux/arm64 ./buildkitd+buildkitd --BUILDKIT_PROJECT="$BUILDKIT_PROJECT"
BUILD ./ast/parser+parser
COPY +earthly-darwin-arm64/earthly ./
SAVE ARTIFACT ./earthly AS LOCAL ./build/darwin/arm64/earthly
for-windows:
# BUILD --platform=linux/amd64 ./buildkitd+buildkitd
BUILD ./ast/parser+parser
COPY +earthly-windows-amd64/earthly.exe ./
SAVE ARTIFACT ./earthly.exe AS LOCAL ./build/windows/amd64/earthly.exe
all-buildkitd:
ARG BUILDKIT_PROJECT
BUILD \
--platform=linux/amd64 \
--platform=linux/arm64 \
./buildkitd+buildkitd --BUILDKIT_PROJECT="$BUILDKIT_PROJECT"
all-dind:
BUILD \
--platform=linux/amd64 \
--platform=linux/arm64 \
+dind
all:
BUILD +all-buildkitd
BUILD +earthly-all
BUILD +earthly-docker
BUILD +prerelease
BUILD +all-dind
lint-all:
BUILD +lint
BUILD +lint-scripts
BUILD +lint-newline-ending
BUILD +lint-changelog
# TODO: Document qemu vs non-qemu
test-no-qemu:
BUILD +unit-test
BUILD +earthly-script-no-stdout
ARG DOCKERHUB_MIRROR
ARG DOCKERHUB_MIRROR_INSECURE=false
ARG DOCKERHUB_AUTH=true
ARG DOCKERHUB_USER_SECRET=+secrets/DOCKERHUB_USER
ARG DOCKERHUB_TOKEN_SECRET=+secrets/DOCKERHUB_TOKEN
BUILD ./ast/tests+all \
--DOCKERHUB_AUTH=$DOCKERHUB_AUTH \
--DOCKERHUB_USER_SECRET=$DOCKERHUB_USER_SECRET \
--DOCKERHUB_TOKEN_SECRET=$DOCKERHUB_TOKEN_SECRET \
--DOCKERHUB_MIRROR=$DOCKERHUB_MIRROR \
--DOCKERHUB_MIRROR_INSECURE=$DOCKERHUB_MIRROR_INSECURE
ARG GLOBAL_WAIT_END="false"
BUILD ./tests+ga-no-qemu \
--DOCKERHUB_AUTH=$DOCKERHUB_AUTH \
--DOCKERHUB_USER_SECRET=$DOCKERHUB_USER_SECRET \
--DOCKERHUB_TOKEN_SECRET=$DOCKERHUB_TOKEN_SECRET \
--DOCKERHUB_MIRROR=$DOCKERHUB_MIRROR \
--DOCKERHUB_MIRROR_INSECURE=$DOCKERHUB_MIRROR_INSECURE \
--GLOBAL_WAIT_END="$GLOBAL_WAIT_END"
test-qemu:
ARG DOCKERHUB_MIRROR
ARG DOCKERHUB_MIRROR_INSECURE=false
ARG DOCKERHUB_AUTH=true
ARG DOCKERHUB_USER_SECRET=+secrets/DOCKERHUB_USER
ARG DOCKERHUB_TOKEN_SECRET=+secrets/DOCKERHUB_TOKEN
ARG GLOBAL_WAIT_END="false"
BUILD ./tests+ga-qemu \
--DOCKERHUB_AUTH=$DOCKERHUB_AUTH \
--DOCKERHUB_USER_SECRET=$DOCKERHUB_USER_SECRET \
--DOCKERHUB_TOKEN_SECRET=$DOCKERHUB_TOKEN_SECRET \
--DOCKERHUB_MIRROR=$DOCKERHUB_MIRROR \
--DOCKERHUB_MIRROR_INSECURE=$DOCKERHUB_MIRROR_INSECURE \
--GLOBAL_WAIT_END="$GLOBAL_WAIT_END"
test:
ARG DOCKERHUB_MIRROR
ARG DOCKERHUB_MIRROR_INSECURE=false
ARG DOCKERHUB_AUTH=true
ARG DOCKERHUB_USER_SECRET=+secrets/DOCKERHUB_USER
ARG DOCKERHUB_TOKEN_SECRET=+secrets/DOCKERHUB_TOKEN
BUILD +test-no-qemu \
--DOCKERHUB_AUTH=$DOCKERHUB_AUTH \
--DOCKERHUB_USER_SECRET=$DOCKERHUB_USER_SECRET \
--DOCKERHUB_TOKEN_SECRET=$DOCKERHUB_TOKEN_SECRET \
--DOCKERHUB_MIRROR=$DOCKERHUB_MIRROR \
--DOCKERHUB_MIRROR_INSECURE=$DOCKERHUB_MIRROR_INSECURE
BUILD +test-qemu \
--DOCKERHUB_AUTH=$DOCKERHUB_AUTH \
--DOCKERHUB_USER_SECRET=$DOCKERHUB_USER_SECRET \
--DOCKERHUB_TOKEN_SECRET=$DOCKERHUB_TOKEN_SECRET \
--DOCKERHUB_MIRROR=$DOCKERHUB_MIRROR \
--DOCKERHUB_MIRROR_INSECURE=$DOCKERHUB_MIRROR_INSECURE
test-all:
BUILD +examples
ARG DOCKERHUB_MIRROR
ARG DOCKERHUB_MIRROR_INSECURE=false
ARG DOCKERHUB_AUTH=true
ARG DOCKERHUB_USER_SECRET=+secrets/DOCKERHUB_USER
ARG DOCKERHUB_TOKEN_SECRET=+secrets/DOCKERHUB_TOKEN
BUILD +test-no-qemu \
--DOCKERHUB_AUTH=$DOCKERHUB_AUTH \
--DOCKERHUB_USER_SECRET=$DOCKERHUB_USER_SECRET \
--DOCKERHUB_TOKEN_SECRET=$DOCKERHUB_TOKEN_SECRET \
--DOCKERHUB_MIRROR=$DOCKERHUB_MIRROR \
--DOCKERHUB_MIRROR_INSECURE=$DOCKERHUB_MIRROR_INSECURE
BUILD +test-qemu \
--DOCKERHUB_AUTH=$DOCKERHUB_AUTH \
--DOCKERHUB_USER_SECRET=$DOCKERHUB_USER_SECRET \
--DOCKERHUB_TOKEN_SECRET=$DOCKERHUB_TOKEN_SECRET \
--DOCKERHUB_MIRROR=$DOCKERHUB_MIRROR \
--DOCKERHUB_MIRROR_INSECURE=$DOCKERHUB_MIRROR_INSECURE
BUILD ./tests+experimental \
--DOCKERHUB_AUTH=$DOCKERHUB_AUTH \
--DOCKERHUB_USER_SECRET=$DOCKERHUB_USER_SECRET \
--DOCKERHUB_TOKEN_SECRET=$DOCKERHUB_TOKEN_SECRET \
--DOCKERHUB_MIRROR=$DOCKERHUB_MIRROR \
--DOCKERHUB_MIRROR_INSECURE=$DOCKERHUB_MIRROR_INSECURE
examples:
BUILD +examples1
BUILD +examples2
examples1:
ARG TARGETARCH
BUILD ./examples/c+docker
BUILD ./examples/cpp+docker
IF [ "$TARGETARCH" = "amd64" ]
# This only works on amd64 for now.
BUILD ./examples/dotnet+docker
END
BUILD ./examples/elixir+docker
BUILD ./examples/go+docker
BUILD ./examples/grpc+test
IF [ "$TARGETARCH" = "amd64" ]
# This only works on amd64 for now.
BUILD ./examples/integration-test+integration-test
END
BUILD ./examples/java+docker
BUILD ./examples/js+docker
BUILD ./examples/monorepo+all
BUILD ./examples/multirepo+docker
BUILD ./examples/python+docker
BUILD ./examples/react+docker
BUILD ./examples/cutoff-optimization+run
BUILD ./examples/import+build
BUILD ./examples/secrets+base
examples2:
BUILD ./examples/readme/go1+all
BUILD ./examples/readme/go2+build
BUILD ./examples/readme/proto+docker
# TODO: This example is flaky for some reason.
#BUILD ./examples/terraform+localstack
BUILD ./examples/ruby+docker
BUILD ./examples/ruby-on-rails+docker
IF [ "$TARGETARCH" = "amd64" ]
# This crashes randomly on arm.
BUILD ./examples/scala+docker
END
BUILD ./examples/cobol+docker
BUILD ./examples/rust+docker
BUILD ./examples/multiplatform+all
BUILD ./examples/multiplatform-cross-compile+build-all-platforms
BUILD github.com/earthly/hello-world:main+hello
BUILD ./examples/cache-command/npm+docker
BUILD ./examples/cache-command/mvn+docker
BUILD ./examples/typescript-node+docker
license:
COPY LICENSE ./
SAVE ARTIFACT LICENSE
# This target is to help keep all node package-lock.json files up to date
npm-update-all:
FROM node:16.16.0-alpine3.15
COPY . /code
WORKDIR /code
FOR nodepath IN \
contrib/earthfile-syntax-highlighting \
examples/cache-command/npm \
examples/js \
examples/react \
examples/ruby-on-rails \
examples/tutorial/js/part3 \
examples/tutorial/js/part4 \
examples/tutorial/js/part5/services/service-one \
examples/tutorial/js/part6/api \
examples/tutorial/js/part6/app \
tests/remote-cache/test2
RUN cd $nodepath && npm update
SAVE ARTIFACT --if-exists $nodepath/package-lock.json AS LOCAL $nodepath/package-lock.json
END