Skip to content

Commit bc8153b

Browse files
committed
Use only one build base in Dockerfile
Signed-off-by: apostasie <[email protected]>
1 parent 772bb09 commit bc8153b

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

Dockerfile

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ ARG KUBO_VERSION=v0.34.1
5555
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.6.1@sha256:923441d7c25f1e2eb5789f82d987693c47b8ed987c4ab3b075d6ed2b5d6779a3 AS xx
5656

5757

58-
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-bookworm AS build-base-debian
58+
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-bookworm AS build-base
5959
COPY --from=xx / /
6060
ENV DEBIAN_FRONTEND=noninteractive
6161
RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
62+
make \
6263
git \
64+
curl \
6365
dpkg-dev
6466
ARG TARGETARCH
6567
# libbtrfs: for containerd
@@ -74,7 +76,7 @@ RUN xx-apt-get update -qq && xx-apt-get install -qq --no-install-recommends \
7476
RUN git config --global advice.detachedHead false
7577
ADD hack/git-checkout-tag-with-hash.sh /usr/local/bin/
7678

77-
FROM build-base-debian AS build-containerd
79+
FROM build-base AS build-containerd
7880
ARG TARGETARCH
7981
ARG CONTAINERD_VERSION
8082
RUN git clone --quiet --depth 1 --branch "${CONTAINERD_VERSION%@*}" https://github.com/containerd/containerd.git /go/src/github.com/containerd/containerd
@@ -85,7 +87,7 @@ RUN git-checkout-tag-with-hash.sh ${CONTAINERD_VERSION} && \
8587
RUN GO=xx-go make STATIC=1 && \
8688
cp -a bin/containerd bin/containerd-shim-runc-v2 bin/ctr /out/$TARGETARCH
8789

88-
FROM build-base-debian AS build-runc
90+
FROM build-base AS build-runc
8991
ARG RUNC_VERSION
9092
ARG TARGETARCH
9193
RUN git clone --quiet --depth 1 --branch "${RUNC_VERSION%@*}" https://github.com/opencontainers/runc.git /go/src/github.com/opencontainers/runc
@@ -96,7 +98,7 @@ ENV CGO_ENABLED=1
9698
RUN GO=xx-go CC=$(xx-info)-gcc STRIP=$(xx-info)-strip make static && \
9799
xx-verify --static runc && cp -v -a runc /out/runc.${TARGETARCH}
98100

99-
FROM build-base-debian AS build-bypass4netns
101+
FROM build-base AS build-bypass4netns
100102
ARG BYPASS4NETNS_VERSION
101103
ARG TARGETARCH
102104
RUN git clone --quiet --depth 1 --branch "${BYPASS4NETNS_VERSION%@*}" https://github.com/rootless-containers/bypass4netns.git /go/src/github.com/rootless-containers/bypass4netns
@@ -107,7 +109,7 @@ ENV CGO_ENABLED=1
107109
RUN GO=xx-go make static && \
108110
xx-verify --static bypass4netns && cp -a bypass4netns bypass4netnsd /out/${TARGETARCH}
109111

110-
FROM build-base-debian AS build-gomodjail
112+
FROM build-base AS build-gomodjail
111113
ARG GOMODJAIL_VERSION
112114
ARG TARGETARCH
113115
RUN git clone --quiet --depth 1 --branch "${GOMODJAIL_VERSION%@*}" https://github.com/AkihiroSuda/gomodjail.git /go/src/github.com/AkihiroSuda/gomodjail
@@ -117,7 +119,7 @@ RUN git-checkout-tag-with-hash.sh ${GOMODJAIL_VERSION} && \
117119
RUN GO=xx-go make STATIC=1 && \
118120
xx-verify --static _output/bin/gomodjail && cp -a _output/bin/gomodjail /out/${TARGETARCH}
119121

120-
FROM build-base-debian AS build-kubo
122+
FROM build-base AS build-kubo
121123
ARG KUBO_VERSION
122124
ARG TARGETARCH
123125
RUN git clone --quiet --depth 1 --branch "${KUBO_VERSION%@*}" https://github.com/ipfs/kubo.git /go/src/github.com/ipfs/kubo
@@ -129,11 +131,6 @@ RUN xx-go --wrap && \
129131
make build && \
130132
xx-verify --static cmd/ipfs/ipfs && cp -a cmd/ipfs/ipfs /out/${TARGETARCH}
131133

132-
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS build-base
133-
RUN apk add --no-cache make git curl
134-
RUN git config --global advice.detachedHead false
135-
ADD hack/git-checkout-tag-with-hash.sh /usr/local/bin/
136-
137134
FROM build-base AS build-minimal
138135
RUN BINDIR=/out/bin make binaries install
139136
# We do not set CMD to `go test` here, because it requires systemd
@@ -310,7 +307,7 @@ RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
310307
git \
311308
make
312309
# We wouldn't need this if Docker Hub could have "golang:${GO_VERSION}-ubuntu"
313-
COPY --from=build-base-debian /usr/local/go /usr/local/go
310+
COPY --from=build-base /usr/local/go /usr/local/go
314311
ARG TARGETARCH
315312
ENV PATH=/usr/local/go/bin:$PATH
316313
ARG GOTESTSUM_VERSION

0 commit comments

Comments
 (0)