2018-06-04 11:00:07 +00:00
|
|
|
ARG RUNC_VERSION=dd56ece8236d6d9e5bed4ea0c31fe53c7b873ff4
|
2018-08-23 07:12:56 +00:00
|
|
|
ARG CONTAINERD_VERSION=v1.1.3
|
2018-05-08 06:26:19 +00:00
|
|
|
# containerd v1.0 for integration tests
|
|
|
|
ARG CONTAINERD10_VERSION=v1.0.3
|
2017-12-18 07:33:02 +00:00
|
|
|
# available targets: buildkitd, buildkitd.oci_only, buildkitd.containerd_only
|
|
|
|
ARG BUILDKIT_TARGET=buildkitd
|
2017-12-05 19:46:04 +00:00
|
|
|
ARG REGISTRY_VERSION=2.6
|
2018-07-04 07:11:52 +00:00
|
|
|
ARG ROOTLESSKIT_VERSION=20b0fc24b305b031a61ef1a1ca456aadafaf5e77
|
2017-06-19 20:39:00 +00:00
|
|
|
|
2017-12-18 07:33:02 +00:00
|
|
|
# The `buildkitd` stage and the `buildctl` stage are placed here
|
2017-12-13 04:34:55 +00:00
|
|
|
# so that they can be built quickly with legacy DAG-unaware `docker build --target=...`
|
|
|
|
|
2018-09-14 05:35:38 +00:00
|
|
|
FROM golang:1.11-alpine AS gobuild-base
|
2017-06-01 22:24:23 +00:00
|
|
|
RUN apk add --no-cache g++ linux-headers
|
2018-03-23 16:50:49 +00:00
|
|
|
RUN apk add --no-cache git libseccomp-dev make
|
2017-06-19 20:39:00 +00:00
|
|
|
|
2017-12-13 04:34:55 +00:00
|
|
|
FROM gobuild-base AS buildkit-base
|
|
|
|
WORKDIR /go/src/github.com/moby/buildkit
|
|
|
|
COPY . .
|
2018-05-21 10:42:59 +00:00
|
|
|
RUN mkdir .tmp; \
|
|
|
|
PKG=github.com/moby/buildkit VERSION=$(git describe --match 'v[0-9]*' --dirty='.m' --always) REVISION=$(git rev-parse HEAD)$(if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi); \
|
|
|
|
echo "-X ${PKG}/version.Version=${VERSION} -X ${PKG}/version.Revision=${REVISION} -X ${PKG}/version.Package=${PKG}" | tee .tmp/ldflags
|
2017-12-13 04:34:55 +00:00
|
|
|
|
|
|
|
FROM buildkit-base AS buildctl
|
|
|
|
ENV CGO_ENABLED=0
|
2018-05-21 10:42:59 +00:00
|
|
|
RUN go build -ldflags "$(cat .tmp/ldflags) -d" -o /usr/bin/buildctl ./cmd/buildctl
|
2017-12-13 04:34:55 +00:00
|
|
|
|
2018-09-14 05:35:38 +00:00
|
|
|
FROM buildkit-base AS buildctl-darwin
|
|
|
|
ENV CGO_ENABLED=0
|
|
|
|
ENV GOOS=darwin
|
|
|
|
RUN go build -ldflags "$(cat .tmp/ldflags)" -o /usr/bin/buildctl-darwin ./cmd/buildctl
|
|
|
|
# reset GOOS for legacy builder
|
|
|
|
ENV GOOS=linux
|
|
|
|
|
2017-12-18 07:33:02 +00:00
|
|
|
FROM buildkit-base AS buildkitd
|
2018-03-23 16:50:49 +00:00
|
|
|
ENV CGO_ENABLED=1
|
2018-05-21 10:42:59 +00:00
|
|
|
RUN go build -installsuffix netgo -ldflags "$(cat .tmp/ldflags) -w -extldflags -static" -tags 'seccomp netgo cgo static_build' -o /usr/bin/buildkitd ./cmd/buildkitd
|
2017-12-13 04:34:55 +00:00
|
|
|
|
|
|
|
# test dependencies begin here
|
2017-06-19 20:39:00 +00:00
|
|
|
FROM gobuild-base AS runc
|
|
|
|
ARG RUNC_VERSION
|
2018-03-23 16:50:49 +00:00
|
|
|
ENV CGO_ENABLED=1
|
2017-06-01 22:24:23 +00:00
|
|
|
RUN git clone https://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
|
|
|
|
&& cd "$GOPATH/src/github.com/opencontainers/runc" \
|
|
|
|
&& git checkout -q "$RUNC_VERSION" \
|
2018-03-23 16:50:49 +00:00
|
|
|
&& go build -installsuffix netgo -ldflags '-w -extldflags -static' -tags 'seccomp netgo cgo static_build' -o /usr/bin/runc ./
|
2017-06-01 22:24:23 +00:00
|
|
|
|
2018-05-08 06:26:19 +00:00
|
|
|
FROM gobuild-base AS containerd-base
|
2017-06-19 20:39:00 +00:00
|
|
|
RUN apk add --no-cache btrfs-progs-dev
|
2018-05-08 06:26:19 +00:00
|
|
|
RUN git clone https://github.com/containerd/containerd.git /go/src/github.com/containerd/containerd
|
|
|
|
WORKDIR /go/src/github.com/containerd/containerd
|
|
|
|
|
|
|
|
FROM containerd-base as containerd
|
2017-06-19 20:39:00 +00:00
|
|
|
ARG CONTAINERD_VERSION
|
2018-05-08 06:26:19 +00:00
|
|
|
RUN git checkout -q "$CONTAINERD_VERSION" \
|
|
|
|
&& make bin/containerd \
|
|
|
|
&& make bin/containerd-shim \
|
|
|
|
&& make bin/ctr
|
|
|
|
|
|
|
|
# containerd v1.0 for integration tests
|
|
|
|
FROM containerd-base as containerd10
|
|
|
|
ARG CONTAINERD10_VERSION
|
|
|
|
RUN git checkout -q "$CONTAINERD10_VERSION" \
|
|
|
|
&& make bin/containerd \
|
|
|
|
&& make bin/containerd-shim
|
2017-06-19 20:39:00 +00:00
|
|
|
|
2017-12-06 20:09:36 +00:00
|
|
|
FROM buildkit-base AS unit-tests
|
|
|
|
COPY --from=runc /usr/bin/runc /usr/bin/runc
|
|
|
|
COPY --from=containerd /go/src/github.com/containerd/containerd/bin/containerd* /usr/bin/
|
|
|
|
|
2017-06-19 23:10:09 +00:00
|
|
|
|
2017-12-18 07:33:02 +00:00
|
|
|
FROM buildkit-base AS buildkitd.oci_only
|
2018-03-23 16:50:49 +00:00
|
|
|
ENV CGO_ENABLED=1
|
2018-06-05 06:54:44 +00:00
|
|
|
# mitigate https://github.com/moby/moby/pull/35456
|
|
|
|
WORKDIR /go/src/github.com/moby/buildkit
|
2018-05-21 10:42:59 +00:00
|
|
|
RUN go build -installsuffix netgo -ldflags "$(cat .tmp/ldflags) -w -extldflags -static" -tags 'no_containerd_worker seccomp netgo cgo static_build' -o /usr/bin/buildkitd.oci_only ./cmd/buildkitd
|
2017-06-19 23:10:09 +00:00
|
|
|
|
2017-12-18 07:33:02 +00:00
|
|
|
FROM buildkit-base AS buildkitd.containerd_only
|
2017-06-19 23:10:09 +00:00
|
|
|
ENV CGO_ENABLED=0
|
2018-05-21 10:42:59 +00:00
|
|
|
RUN go build -ldflags "$(cat .tmp/ldflags) -d" -o /usr/bin/buildkitd.containerd_only -tags no_oci_worker ./cmd/buildkitd
|
2017-06-19 23:10:09 +00:00
|
|
|
|
2017-12-05 19:46:04 +00:00
|
|
|
FROM registry:$REGISTRY_VERSION AS registry
|
|
|
|
|
2018-07-04 09:18:00 +00:00
|
|
|
FROM gobuild-base AS rootlesskit-base
|
|
|
|
RUN git clone https://github.com/rootless-containers/rootlesskit.git /go/src/github.com/rootless-containers/rootlesskit
|
|
|
|
WORKDIR /go/src/github.com/rootless-containers/rootlesskit
|
|
|
|
|
|
|
|
FROM rootlesskit-base as rootlesskit
|
|
|
|
ARG ROOTLESSKIT_VERSION
|
|
|
|
# mitigate https://github.com/moby/moby/pull/35456
|
|
|
|
ENV GOOS=linux
|
|
|
|
RUN git checkout -q "$ROOTLESSKIT_VERSION" \
|
|
|
|
&& go build -o /rootlesskit ./cmd/rootlesskit
|
|
|
|
|
2017-06-19 23:10:09 +00:00
|
|
|
FROM unit-tests AS integration-tests
|
2018-07-04 09:18:00 +00:00
|
|
|
ENV BUILDKIT_INTEGRATION_ROOTLESS_IDPAIR="1000:1000"
|
|
|
|
RUN apk add --no-cache shadow shadow-uidmap sudo \
|
|
|
|
&& useradd --create-home --home-dir /home/user --uid 1000 -s /bin/sh user \
|
|
|
|
&& echo "XDG_RUNTIME_DIR=/run/user/1000; export XDG_RUNTIME_DIR" >> /home/user/.profile \
|
|
|
|
&& mkdir -m 0700 -p /run/user/1000 \
|
|
|
|
&& chown -R user /run/user/1000 /home/user
|
2018-07-06 06:16:38 +00:00
|
|
|
ENV BUILDKIT_INTEGRATION_CONTAINERD_EXTRA="containerd-1.0=/opt/containerd-1.0/bin"
|
2018-05-08 06:26:19 +00:00
|
|
|
COPY --from=containerd10 /go/src/github.com/containerd/containerd/bin/containerd* /opt/containerd-1.0/bin/
|
2017-11-30 01:41:44 +00:00
|
|
|
COPY --from=buildctl /usr/bin/buildctl /usr/bin/
|
2017-12-18 07:33:02 +00:00
|
|
|
COPY --from=buildkitd /usr/bin/buildkitd /usr/bin
|
2017-12-05 19:46:04 +00:00
|
|
|
COPY --from=registry /bin/registry /usr/bin
|
2018-07-04 09:18:00 +00:00
|
|
|
COPY --from=rootlesskit /rootlesskit /usr/bin/
|
2017-07-12 05:08:53 +00:00
|
|
|
|
2018-06-30 09:40:55 +00:00
|
|
|
FROM buildkit-base AS cross-windows
|
2017-07-12 05:08:53 +00:00
|
|
|
ENV GOOS=windows
|
|
|
|
|
|
|
|
FROM cross-windows AS buildctl.exe
|
2018-05-21 10:42:59 +00:00
|
|
|
RUN go build -ldflags "$(cat .tmp/ldflags)" -o /buildctl.exe ./cmd/buildctl
|
2017-07-12 05:08:53 +00:00
|
|
|
|
2017-12-18 07:33:02 +00:00
|
|
|
FROM cross-windows AS buildkitd.exe
|
2018-03-23 16:50:49 +00:00
|
|
|
ENV CGO_ENABLED=0
|
2018-05-21 10:42:59 +00:00
|
|
|
RUN go build -ldflags "$(cat .tmp/ldflags)" -o /buildkitd.exe ./cmd/buildkitd
|
2017-10-15 19:13:47 +00:00
|
|
|
|
2017-12-06 20:09:36 +00:00
|
|
|
FROM alpine AS buildkit-export
|
|
|
|
RUN apk add --no-cache git
|
|
|
|
VOLUME /var/lib/buildkit
|
|
|
|
|
2017-12-15 07:00:13 +00:00
|
|
|
# Copy together all binaries for oci+containerd mode
|
2017-12-18 07:33:02 +00:00
|
|
|
FROM buildkit-export AS buildkit-buildkitd
|
2017-12-13 04:34:55 +00:00
|
|
|
COPY --from=runc /usr/bin/runc /usr/bin/
|
2017-12-18 07:33:02 +00:00
|
|
|
COPY --from=buildkitd /usr/bin/buildkitd /usr/bin/
|
2017-12-13 04:34:55 +00:00
|
|
|
COPY --from=buildctl /usr/bin/buildctl /usr/bin/
|
2017-12-18 07:33:02 +00:00
|
|
|
ENTRYPOINT ["buildkitd"]
|
2017-12-13 04:34:55 +00:00
|
|
|
|
2017-12-15 07:00:13 +00:00
|
|
|
# Copy together all binaries needed for oci worker mode
|
2017-12-18 07:33:02 +00:00
|
|
|
FROM buildkit-export AS buildkit-buildkitd.oci_only
|
|
|
|
COPY --from=buildkitd.oci_only /usr/bin/buildkitd.oci_only /usr/bin/
|
2017-10-15 19:13:47 +00:00
|
|
|
COPY --from=buildctl /usr/bin/buildctl /usr/bin/
|
2017-12-18 07:33:02 +00:00
|
|
|
ENTRYPOINT ["buildkitd.oci_only"]
|
2017-10-15 19:13:47 +00:00
|
|
|
|
2017-12-15 07:00:13 +00:00
|
|
|
# Copy together all binaries for containerd worker mode
|
2017-12-18 07:33:02 +00:00
|
|
|
FROM buildkit-export AS buildkit-buildkitd.containerd_only
|
2017-12-06 20:09:36 +00:00
|
|
|
COPY --from=runc /usr/bin/runc /usr/bin/
|
2017-12-18 07:33:02 +00:00
|
|
|
COPY --from=buildkitd.containerd_only /usr/bin/buildkitd.containerd_only /usr/bin/
|
2017-10-15 19:13:47 +00:00
|
|
|
COPY --from=buildctl /usr/bin/buildctl /usr/bin/
|
2017-12-18 07:33:02 +00:00
|
|
|
ENTRYPOINT ["buildkitd.containerd_only"]
|
2017-10-15 19:13:47 +00:00
|
|
|
|
2017-12-06 20:09:36 +00:00
|
|
|
FROM alpine AS containerd-runtime
|
|
|
|
COPY --from=runc /usr/bin/runc /usr/bin/
|
|
|
|
COPY --from=containerd /go/src/github.com/containerd/containerd/bin/containerd* /usr/bin/
|
|
|
|
COPY --from=containerd /go/src/github.com/containerd/containerd/bin/ctr /usr/bin/
|
|
|
|
VOLUME /var/lib/containerd
|
|
|
|
VOLUME /run/containerd
|
|
|
|
ENTRYPOINT ["containerd"]
|
|
|
|
|
2018-06-04 11:00:07 +00:00
|
|
|
# Rootless mode.
|
|
|
|
# Still requires `--privileged`.
|
|
|
|
FROM buildkit-buildkitd AS rootless
|
|
|
|
RUN apk add --no-cache shadow shadow-uidmap \
|
|
|
|
&& useradd --create-home --home-dir /home/user --uid 1000 user \
|
2018-07-04 07:11:52 +00:00
|
|
|
&& mkdir -p /run/user/1000 /home/user/.local/tmp /home/user/.local/share/buildkit \
|
|
|
|
&& chown -R user /run/user/1000 /home/user
|
2018-06-04 11:00:07 +00:00
|
|
|
COPY --from=rootlesskit /rootlesskit /usr/bin/
|
|
|
|
USER user
|
|
|
|
ENV HOME /home/user
|
|
|
|
ENV USER user
|
2018-07-04 07:11:52 +00:00
|
|
|
ENV XDG_RUNTIME_DIR=/run/user/1000
|
2018-06-04 11:00:07 +00:00
|
|
|
ENV TMPDIR=/home/user/.local/tmp
|
|
|
|
VOLUME /home/user/.local/share/buildkit
|
|
|
|
ENTRYPOINT ["rootlesskit", "buildkitd"]
|
|
|
|
|
2017-10-15 19:13:47 +00:00
|
|
|
FROM buildkit-${BUILDKIT_TARGET}
|
2017-12-06 20:09:36 +00:00
|
|
|
|
|
|
|
|