@@ -32,10 +32,6 @@ FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
32
32
# go base image
33
33
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS golatest
34
34
35
- # git stage is used for checking out remote repository sources
36
- FROM --platform=$BUILDPLATFORM alpine:${ALPINE_VERSION} AS git
37
- RUN apk add --no-cache git
38
-
39
35
# gobuild is base stage for compiling go/cgo
40
36
FROM golatest AS gobuild-base
41
37
RUN apk add --no-cache file bash clang lld musl-dev pkgconfig git make
@@ -48,23 +44,17 @@ RUN --mount=target=/root/.cache,type=cache \
48
44
--mount=target=/go/pkg/mod,type=cache \
49
45
GOBIN=/usr/bin go install github.com/go-delve/delve/cmd/dlv@${DELVE_VERSION}
50
46
51
- # runc source
52
- FROM git AS runc-src
53
- ARG RUNC_VERSION
54
- WORKDIR /usr/src
55
- RUN git clone https://github.com/opencontainers/runc.git runc \
56
- && cd runc && git checkout -q "$RUNC_VERSION"
57
-
58
47
# build runc binary
59
48
FROM gobuild-base AS runc
60
49
WORKDIR $GOPATH/src/github.com/opencontainers/runc
50
+ ARG RUNC_VERSION
51
+ ADD --keep-git-dir=true "https://github.com/opencontainers/runc.git#$RUNC_VERSION" .
61
52
ARG TARGETPLATFORM
62
53
# gcc is only installed for libgcc
63
54
# lld has issues building static binaries for ppc so prefer ld for it
64
55
RUN set -e; xx-apk add musl-dev gcc libseccomp-dev libseccomp-static; \
65
56
[ "$(xx-info arch)" != "ppc64le" ] || XX_CC_PREFER_LINKER=ld xx-clang --setup-target-triple
66
- RUN --mount=from=runc-src,src=/usr/src/runc,target=. \
67
- --mount=target=/root/.cache,type=cache <<EOT
57
+ RUN --mount=target=/root/.cache,type=cache <<EOT
68
58
set -ex
69
59
CGO_ENABLED=1 xx-go build -mod=vendor -ldflags '-extldflags -static' -tags 'apparmor seccomp netgo cgo static_build osusergo' -o /usr/bin/runc ./
70
60
xx-verify --static /usr/bin/runc
@@ -139,19 +129,13 @@ RUN --mount=target=. --mount=target=/root/.cache,type=cache \
139
129
fi
140
130
EOT
141
131
142
- # dnsname source
143
- FROM git AS dnsname-src
144
- ARG DNSNAME_VERSION
145
- WORKDIR /usr/src
146
- RUN git clone https://github.com/containers/dnsname.git dnsname \
147
- && cd dnsname && git checkout -q "$DNSNAME_VERSION"
148
-
149
132
# build dnsname CNI plugin for testing
150
133
FROM gobuild-base AS dnsname
151
134
WORKDIR /go/src/github.com/containers/dnsname
135
+ ARG DNSNAME_VERSION
136
+ ADD --keep-git-dir=true "https://github.com/containers/dnsname.git#$DNSNAME_VERSION" .
152
137
ARG TARGETPLATFORM
153
- RUN --mount=from=dnsname-src,src=/usr/src/dnsname,target=.,rw \
154
- --mount=target=/root/.cache,type=cache \
138
+ RUN --mount=target=/root/.cache,type=cache \
155
139
CGO_ENABLED=0 xx-go build -o /usr/bin/dnsname ./plugins/meta/dnsname && \
156
140
xx-verify --static /usr/bin/dnsname
157
141
@@ -216,23 +200,15 @@ RUN apk add --no-cache fuse3 git openssh pigz xz iptables ip6tables \
216
200
COPY --link examples/buildctl-daemonless/buildctl-daemonless.sh /usr/bin/
217
201
VOLUME /var/lib/buildkit
218
202
219
- FROM git AS containerd-src
220
- WORKDIR /usr/src
221
- RUN git clone https://github.com/containerd/containerd.git containerd
222
-
223
- FROM gobuild-base AS containerd-base
203
+ FROM gobuild-base AS containerd
224
204
WORKDIR /go/src/github.com/containerd/containerd
205
+ ARG CONTAINERD_VERSION
206
+ ADD --keep-git-dir=true "https://github.com/containerd/containerd.git#$CONTAINERD_VERSION" .
225
207
ARG TARGETPLATFORM
226
208
ENV CGO_ENABLED=1 BUILDTAGS=no_btrfs GO111MODULE=off
227
209
RUN xx-apk add musl-dev gcc && xx-go --wrap
228
-
229
- FROM containerd-base AS containerd
230
- ARG CONTAINERD_VERSION
231
- RUN --mount=from=containerd-src,src=/usr/src/containerd,rw \
232
- --mount=target=/root/.cache,type=cache <<EOT
210
+ RUN --mount=target=/root/.cache,type=cache <<EOT
233
211
set -ex
234
- git fetch origin
235
- git checkout -q "$CONTAINERD_VERSION"
236
212
mkdir /out
237
213
ext=""
238
214
if [ "$(xx-info os)" = "windows" ]; then
@@ -249,13 +225,15 @@ RUN --mount=from=containerd-src,src=/usr/src/containerd,rw \
249
225
EOT
250
226
251
227
# containerd v1.6 for integration tests
252
- FROM containerd-base AS containerd-alt-16
228
+ FROM gobuild-base AS containerd-alt-16
229
+ WORKDIR /go/src/github.com/containerd/containerd
253
230
ARG CONTAINERD_ALT_VERSION_16
254
- RUN --mount=from=containerd-src,src=/usr/src/containerd,rw \
255
- --mount=target=/root/.cache,type=cache <<EOT
231
+ ADD --keep-git-dir=true "https://github.com/containerd/containerd.git#$CONTAINERD_ALT_VERSION_16" .
232
+ ARG TARGETPLATFORM
233
+ ENV CGO_ENABLED=1 BUILDTAGS=no_btrfs GO111MODULE=off
234
+ RUN xx-apk add musl-dev gcc && xx-go --wrap
235
+ RUN --mount=target=/root/.cache,type=cache <<EOT
256
236
set -ex
257
- git fetch origin
258
- git checkout -q "$CONTAINERD_ALT_VERSION_16"
259
237
mkdir /out
260
238
ext=""
261
239
if [ "$(xx-info os)" = "windows" ]; then
@@ -271,19 +249,13 @@ RUN --mount=from=containerd-src,src=/usr/src/containerd,rw \
271
249
fi
272
250
EOT
273
251
274
- FROM git AS registry-src
275
- WORKDIR /usr/src
276
- RUN git clone https://github.com/distribution/distribution.git distribution
277
-
278
252
FROM gobuild-base AS registry
253
+ WORKDIR /go/src/github.com/docker/distribution
279
254
ARG REGISTRY_VERSION
255
+ ADD --keep-git-dir=true "https://github.com/distribution/distribution.git#$REGISTRY_VERSION" .
280
256
ARG TARGETPLATFORM
281
- WORKDIR /go/src/github.com/docker/distribution
282
- RUN --mount=from=registry-src,src=/usr/src/distribution,rw \
283
- --mount=target=/root/.cache,type=cache <<EOT
257
+ RUN --mount=target=/root/.cache,type=cache <<EOT
284
258
set -ex
285
- git fetch origin
286
- git checkout -q "$REGISTRY_VERSION"
287
259
mkdir /out
288
260
export GOPATH="$(pwd)/Godeps/_workspace:$GOPATH"
289
261
GO111MODULE=off CGO_ENABLED=0 xx-go build -o /out/registry ./cmd/registry
@@ -294,22 +266,20 @@ RUN --mount=from=registry-src,src=/usr/src/distribution,rw \
294
266
EOT
295
267
296
268
FROM gobuild-base AS rootlesskit
297
- ARG ROOTLESSKIT_VERSION
298
- RUN git clone https://github.com/rootless-containers/rootlesskit.git /go/src/github.com/rootless-containers/rootlesskit
299
269
WORKDIR /go/src/github.com/rootless-containers/rootlesskit
270
+ ARG ROOTLESSKIT_VERSION
271
+ ADD --keep-git-dir=true "https://github.com/rootless-containers/rootlesskit.git#$ROOTLESSKIT_VERSION" .
300
272
ARG TARGETPLATFORM
301
273
RUN --mount=target=/root/.cache,type=cache \
302
- git checkout -q "$ROOTLESSKIT_VERSION" && \
303
274
CGO_ENABLED=0 xx-go build -o /rootlesskit ./cmd/rootlesskit && \
304
275
xx-verify --static /rootlesskit
305
276
306
277
FROM gobuild-base AS stargz-snapshotter
307
- ARG STARGZ_SNAPSHOTTER_VERSION
308
- RUN git clone https://github.com/containerd/stargz-snapshotter.git /go/src/github.com/containerd/stargz-snapshotter
309
278
WORKDIR /go/src/github.com/containerd/stargz-snapshotter
279
+ ARG STARGZ_SNAPSHOTTER_VERSION
280
+ ADD --keep-git-dir=true "https://github.com/containerd/stargz-snapshotter.git#$STARGZ_SNAPSHOTTER_VERSION" .
310
281
ARG TARGETPLATFORM
311
282
RUN --mount=target=/root/.cache,type=cache \
312
- git checkout -q "$STARGZ_SNAPSHOTTER_VERSION" && \
313
283
xx-go --wrap && \
314
284
mkdir /out && CGO_ENABLED=0 PREFIX=/out/ make && \
315
285
xx-verify --static /out/containerd-stargz-grpc && \
0 commit comments