Skip to content

Commit af05a68

Browse files
committed
Dockerfile: use COPY --link where possible
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 41183c2 commit af05a68

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

Dockerfile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ARG BUILDX_VERSION=0.11.2
1111
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
1212

1313
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS build-base-alpine
14-
COPY --from=xx / /
14+
COPY --link --from=xx / /
1515
RUN apk add --no-cache bash clang lld llvm file git
1616
WORKDIR /go/src/github.com/docker/cli
1717

@@ -21,7 +21,7 @@ ARG TARGETPLATFORM
2121
RUN xx-apk add --no-cache musl-dev gcc
2222

2323
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-bullseye AS build-base-bullseye
24-
COPY --from=xx / /
24+
COPY --link --from=xx / /
2525
RUN apt-get update && apt-get install --no-install-recommends -y bash clang lld llvm file
2626
WORKDIR /go/src/github.com/docker/cli
2727

@@ -62,7 +62,7 @@ ARG CGO_ENABLED
6262
ARG VERSION
6363
# PACKAGER_NAME sets the company that produced the windows binary
6464
ARG PACKAGER_NAME
65-
COPY --from=goversioninfo /out/goversioninfo /usr/bin/goversioninfo
65+
COPY --link --from=goversioninfo /out/goversioninfo /usr/bin/goversioninfo
6666
# in bullseye arm64 target does not link with lld so configure it to use ld instead
6767
RUN [ ! -f /etc/alpine-release ] && xx-info is-cross && [ "$(xx-info arch)" = "arm64" ] && XX_CC_PREFER_LINKER=ld xx-clang --setup-target-triple || true
6868
RUN --mount=type=bind,target=.,ro \
@@ -76,7 +76,7 @@ RUN --mount=type=bind,target=.,ro \
7676
xx-verify $([ "$GO_LINKMODE" = "static" ] && echo "--static") /out/docker
7777

7878
FROM build-${BASE_VARIANT} AS test
79-
COPY --from=gotestsum /out/gotestsum /usr/bin/gotestsum
79+
COPY --link --from=gotestsum /out/gotestsum /usr/bin/gotestsum
8080
ENV GO111MODULE=auto
8181
RUN --mount=type=bind,target=.,rw \
8282
--mount=type=cache,target=/root/.cache \
@@ -111,19 +111,19 @@ FROM docker/buildx-bin:${BUILDX_VERSION} AS buildx
111111
FROM e2e-base-${BASE_VARIANT} AS e2e
112112
ARG NOTARY_VERSION=v0.6.1
113113
ADD --chmod=0755 https://github.com/theupdateframework/notary/releases/download/${NOTARY_VERSION}/notary-Linux-amd64 /usr/local/bin/notary
114-
COPY e2e/testdata/notary/root-ca.cert /usr/share/ca-certificates/notary.cert
114+
COPY --link e2e/testdata/notary/root-ca.cert /usr/share/ca-certificates/notary.cert
115115
RUN echo 'notary.cert' >> /etc/ca-certificates.conf && update-ca-certificates
116-
COPY --from=gotestsum /out/gotestsum /usr/bin/gotestsum
117-
COPY --from=build /out ./build/
118-
COPY --from=build-plugins /out ./build/
119-
COPY --from=buildx /buildx /usr/libexec/docker/cli-plugins/docker-buildx
120-
COPY . .
116+
COPY --link --from=gotestsum /out/gotestsum /usr/bin/gotestsum
117+
COPY --link --from=build /out ./build/
118+
COPY --link --from=build-plugins /out ./build/
119+
COPY --link --from=buildx /buildx /usr/libexec/docker/cli-plugins/docker-buildx
120+
COPY --link . .
121121
ENV DOCKER_BUILDKIT=1
122122
ENV PATH=/go/src/github.com/docker/cli/build:$PATH
123123
CMD ./scripts/test/e2e/entry
124124

125125
FROM build-base-${BASE_VARIANT} AS dev
126-
COPY . .
126+
COPY --link . .
127127

128128
FROM scratch AS plugins
129129
COPY --from=build-plugins /out .

dockerfiles/Dockerfile.dev

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ CMD bash
4848
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
4949
ENV PATH=$PATH:/go/src/github.com/docker/cli/build
5050

51-
COPY --from=buildx /buildx /usr/libexec/docker/cli-plugins/docker-buildx
52-
COPY --from=gofumpt /go/bin/* /go/bin/
53-
COPY --from=gotestsum /go/bin/* /go/bin/
54-
COPY --from=goversioninfo /go/bin/* /go/bin/
51+
COPY --link --from=buildx /buildx /usr/libexec/docker/cli-plugins/docker-buildx
52+
COPY --link --from=gofumpt /go/bin/* /go/bin/
53+
COPY --link --from=gotestsum /go/bin/* /go/bin/
54+
COPY --link --from=goversioninfo /go/bin/* /go/bin/
5555

5656
WORKDIR /go/src/github.com/docker/cli
5757
ENV GO111MODULE=auto
58-
COPY . .
58+
COPY --link . .

dockerfiles/Dockerfile.lint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ENV GO111MODULE=off
1111
ENV CGO_ENABLED=0
1212
ENV GOGC=75
1313
WORKDIR /go/src/github.com/docker/cli
14-
COPY --from=golangci-lint /usr/bin/golangci-lint /usr/bin/golangci-lint
14+
COPY --link --from=golangci-lint /usr/bin/golangci-lint /usr/bin/golangci-lint
1515
RUN --mount=type=bind,target=. \
1616
--mount=type=cache,target=/root/.cache \
1717
golangci-lint run

0 commit comments

Comments
 (0)