forked from earthly/earthly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Earthfile
85 lines (77 loc) · 4.2 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
VERSION 0.6
FROM alpine:3.15
buildkitd:
ARG BUILDKIT_PROJECT
IF [ "$BUILDKIT_PROJECT" != "" ]
IF case "$BUILDKIT_PROJECT" in "../*") true;; "*") false;; esac
# Assuming this is coming from the main Earthly Earthfile.
ARG BUILDKIT_BASE_IMAGE=../$BUILDKIT_PROJECT+build
ELSE
ARG BUILDKIT_BASE_IMAGE=$BUILDKIT_PROJECT+build
END
ELSE
ARG BUILDKIT_BASE_IMAGE=github.com/earthly/buildkit:8d4eb6b24e7253afd621f91f2589221bfd1dabdf+build
END
FROM $BUILDKIT_BASE_IMAGE
RUN echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN apk add --update --no-cache \
cni-plugins@edge-community \
gettext \
iptables \
openssh-client \
pigz \
util-linux \
xz
# Add github and gitlab to known hosts.
RUN mkdir -p ~/.ssh
RUN echo "github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~/.ssh/known_hosts
RUN echo "gitlab.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsj2bNKTBSpIYDEGk9KxsGh3mySTRgMtXL583qmBpzeQ+jqCMRgBqB98u3z++J1sKlXHWfM9dyhSevkMwSbhoR8XIq/U0tCNyokEi/ueaBMCvbcTHhO7FcwzY92WK4Yt0aGROY5qX2UKSeOvuP4D6TPqKF1onrSzH9bx9XUf2lEdWT/ia1NEKjunUqu1xOB/StKDHMoX4/OKyIzuS0q/T1zOATthvasJFoPrAjkohTyaDUz2LN5JoH839hViyEG82yB+MjcFV5MU3N1l1QL3cVUCh93xSaua1N85qivl+siMkPGbO5xR/En4iEY6K2XPASUEMaieWVNTRCtJ4S8H+9" >> ~/.ssh/known_hosts
# Add the config templates and our own wrapper script.
COPY ./entrypoint.sh /usr/bin/entrypoint.sh
COPY ./buildkitd.toml.template /etc/buildkitd.toml.template
COPY ./buildkitd.cache.template /etc/buildkitd.cache.template
COPY ./buildkitd.tcp.template /etc/buildkitd.tcp.template
COPY ./buildkitd.tls.template /etc/buildkitd.tls.template
COPY ./cni-conf.json.template /etc/cni/cni-conf.json.template
# Scripts and binaries used for the builds.
COPY ../+shellrepeater/shellrepeater /usr/bin/shellrepeater
COPY ../+debugger/earth_debugger /usr/bin/earth_debugger
COPY ./dockerd-wrapper.sh /var/earthly/dockerd-wrapper.sh
COPY ./docker-auto-install.sh /var/earthly/docker-auto-install.sh
ENV EARTHLY_RESET_TMP_DIR=false
ENV EARTHLY_TMP_DIR=/tmp/earthly
ENV BUILDKIT_DEBUG=false
ENV BUILDKIT_MAX_PARALLELISM=20
ENV CACHE_SIZE_MB=0
ENV NETWORK_MODE=cni
ARG EARTHLY_GIT_HASH
ENV EARTHLY_GIT_HASH=$EARTHLY_GIT_HASH
ENV BUILDKIT_BASE_IMAGE=$BUILDKIT_BASE_IMAGE
ENV EARTHLY_CACHE_VERSION="2" # whenever this value changes, a forced cache reset is performed
VOLUME /tmp/earthly
ENTRYPOINT ["/usr/bin/entrypoint.sh", "buildkitd", "--config=/etc/buildkitd.toml"]
ARG EARTHLY_TARGET_TAG_DOCKER
ARG TAG="dev-$EARTHLY_TARGET_TAG_DOCKER"
ARG DOCKERHUB_USER="earthly"
SAVE IMAGE --push --cache-from=earthly/buildkitd:main $DOCKERHUB_USER/buildkitd:$TAG
buildkit-sha:
RUN apk add git
ARG BUILDKIT_GIT_SHA
ARG BUILDKIT_GIT_BRANCH=earthly-main
RUN --no-cache set -e; \
if [ "$(echo -n $BUILDKIT_GIT_SHA | wc -c)" = 40 ]; then \
echo "pinning github.com/earthly/buildkit to reference git sha1: $BUILDKIT_GIT_SHA"; \
buildkit_sha1="$BUILDKIT_GIT_SHA"; \
else \
test -z "$BUILDKIT_GIT_SHA"; \
echo "looking up branch $BUILDKIT_GIT_BRANCH"; \
buildkit_sha1=$(git ls-remote --refs -q https://github.com/earthly/buildkit.git "$BUILDKIT_GIT_BRANCH" | awk 'BEGIN { FS = "[ \t]+" } {print $1}'); \
echo "pinning github.com/earthly/buildkit@${BUILDKIT_BRANCH} to reference git sha1: $buildkit_sha1"; \
fi && \
test -n "$buildkit_sha1" && \
echo "$buildkit_sha1" > buildkit_sha
SAVE ARTIFACT buildkit_sha buildkit_sha
update-buildkit:
LOCALLY
ARG --required BUILDKIT_GIT_SHA
RUN sed -i 's/\(^[ \t]\+ARG BUILDKIT_BASE_IMAGE=github.com\/earthly\/buildkit\).*/\1:'$BUILDKIT_GIT_SHA'+build/g' Earthfile