Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
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:f46745e0958c6942be03b9d49684d804e7bdffc4+build
END
ARG EARTHLY_TARGET_TAG_DOCKER
ARG TAG="dev-$EARTHLY_TARGET_TAG_DOCKER"
FROM $BUILDKIT_BASE_IMAGE --RELEASE_VERSION=$TAG
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.pprof.template /etc/buildkitd.pprof.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 ../+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
COPY ./oom-adjust.sh.template /bin/oom-adjust.sh.template
ENV EARTHLY_RESET_TMP_DIR=false
ENV EARTHLY_TMP_DIR=/tmp/earthly
ENV BUILDKIT_DEBUG=false
ENV BUILDKIT_MAX_PARALLELISM=20
ENV BUILDKIT_LOCAL_REGISTRY_LISTEN_PORT=8371
ENV CACHE_SIZE_MB=0
ENV CACHE_SIZE_PCT=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 REGISTRY_USER="earthly"
ARG IMAGE_REGISTRY="docker.io"
# Ensure that the image we save is a fully qualified name. Podman defaults to "localhost", while Docker defaults to
# "docker.io". This keeps it consistent across both frontends.
SAVE IMAGE --push --cache-from=$IMAGE_REGISTRY/earthly/buildkitd:main $IMAGE_REGISTRY/$REGISTRY_USER/buildkitd:$TAG
buildkit-sha:
RUN apk add git
ARG BUILDKIT_GIT_SHA
ARG BUILDKIT_GIT_BRANCH=earthly-main
ARG --required BUILDKIT_GIT_ORG
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/$BUILDKIT_GIT_ORG/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-earthfile:
LOCALLY
ARG --required BUILDKIT_GIT_SHA
ARG --required BUILDKIT_GIT_ORG
# We run the Mac version on Darwin as it is not compatible with Linux sed
# The regular expressions are intentionally different, but should be functionally equivalent on the correct uname.
RUN if [ "$(uname)" = "Darwin" ]; then \
sed -E -i '' -e 's/(^[ \t]+ARG BUILDKIT_BASE_IMAGE).*\/buildkit.*/\1=github.com\/'$BUILDKIT_GIT_ORG'\/buildkit:'$BUILDKIT_GIT_SHA'+build/g' Earthfile; \
else \
sed -i 's/\(^[ \t]\+ARG BUILDKIT_BASE_IMAGE\)=github.com\/.*\/buildkit.*/\1=github.com\/'$BUILDKIT_GIT_ORG'\/buildkit:'$BUILDKIT_GIT_SHA'+build/g' Earthfile; \
fi