mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00
dockerfile: use moby-bin and cli-bin images for docker binaries
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
253cbee5c7
commit
70a28fed12
30
Dockerfile
30
Dockerfile
@ -3,15 +3,18 @@
|
||||
ARG GO_VERSION=1.21
|
||||
ARG XX_VERSION=1.4.0
|
||||
|
||||
# for testing
|
||||
ARG DOCKER_VERSION=25.0.2
|
||||
ARG GOTESTSUM_VERSION=v1.9.0
|
||||
ARG REGISTRY_VERSION=2.8.0
|
||||
ARG BUILDKIT_VERSION=v0.12.5
|
||||
|
||||
# xx is a helper for cross-compilation
|
||||
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
|
||||
|
||||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS golatest
|
||||
FROM moby/moby-bin:$DOCKER_VERSION AS docker-engine
|
||||
FROM dockereng/cli-bin:$DOCKER_VERSION AS docker-cli
|
||||
FROM registry:$REGISTRY_VERSION AS registry
|
||||
FROM moby/buildkit:$BUILDKIT_VERSION AS buildkit
|
||||
|
||||
FROM golatest AS gobase
|
||||
COPY --from=xx / /
|
||||
@ -20,26 +23,6 @@ ENV GOFLAGS=-mod=vendor
|
||||
ENV CGO_ENABLED=0
|
||||
WORKDIR /src
|
||||
|
||||
FROM registry:$REGISTRY_VERSION AS registry
|
||||
|
||||
FROM moby/buildkit:$BUILDKIT_VERSION AS buildkit
|
||||
|
||||
FROM gobase AS docker
|
||||
ARG TARGETPLATFORM
|
||||
ARG DOCKER_VERSION
|
||||
WORKDIR /opt/docker
|
||||
RUN DOCKER_ARCH=$(case ${TARGETPLATFORM:-linux/amd64} in \
|
||||
"linux/amd64") echo "x86_64" ;; \
|
||||
"linux/arm/v6") echo "armel" ;; \
|
||||
"linux/arm/v7") echo "armhf" ;; \
|
||||
"linux/arm64") echo "aarch64" ;; \
|
||||
"linux/ppc64le") echo "ppc64le" ;; \
|
||||
"linux/s390x") echo "s390x" ;; \
|
||||
*) echo "" ;; esac) \
|
||||
&& echo "DOCKER_ARCH=$DOCKER_ARCH" \
|
||||
&& wget -qO- "https://download.docker.com/linux/static/stable/${DOCKER_ARCH}/docker-${DOCKER_VERSION}.tgz" | tar xvz --strip 1
|
||||
RUN ./dockerd --version && ./containerd --version && ./ctr --version && ./runc --version
|
||||
|
||||
FROM gobase AS gotestsum
|
||||
ARG GOTESTSUM_VERSION
|
||||
ENV GOFLAGS=
|
||||
@ -105,7 +88,8 @@ RUN apk add --no-cache \
|
||||
xz
|
||||
COPY --link --from=gotestsum /out/gotestsum /usr/bin/
|
||||
COPY --link --from=registry /bin/registry /usr/bin/
|
||||
COPY --link --from=docker /opt/docker/* /usr/bin/
|
||||
COPY --link --from=docker-engine / /usr/bin/
|
||||
COPY --link --from=docker-cli / /usr/bin/
|
||||
COPY --link --from=buildkit /usr/bin/buildkitd /usr/bin/
|
||||
COPY --link --from=buildkit /usr/bin/buildctl /usr/bin/
|
||||
COPY --link --from=binaries /buildx /usr/bin/
|
||||
|
Loading…
x
Reference in New Issue
Block a user