summaryrefslogtreecommitdiff
path: root/vendor/github.com/docker/distribution/Dockerfile
diff options
context:
space:
mode:
authorAkihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>2023-05-18 00:15:55 +0900
committerGitHub <noreply@github.com>2023-05-18 00:15:55 +0900
commitcb3fd005d470e80eb9076e9d09c04d6784d64d91 (patch)
tree481a763ac51cb60a34ce5de4c7b9aad093fb28c0 /vendor/github.com/docker/distribution/Dockerfile
parent9dbdbd4b6d7681bd18c897a6ba0376073c2a72ff (diff)
parente94c22cc391c6242fd4eeb62b8c0afea24ee2e7e (diff)
downloaddocker-23.0.tar.gz
Merge pull request #45520 from thaJeztah/23.0_backport_vendor_distribution_v2.8.223.0
[23.0 backport] vendor: github.com/docker/distribution v2.8.2
Diffstat (limited to 'vendor/github.com/docker/distribution/Dockerfile')
-rw-r--r--vendor/github.com/docker/distribution/Dockerfile78
1 files changed, 44 insertions, 34 deletions
diff --git a/vendor/github.com/docker/distribution/Dockerfile b/vendor/github.com/docker/distribution/Dockerfile
index ae8c040c73..fb54b68138 100644
--- a/vendor/github.com/docker/distribution/Dockerfile
+++ b/vendor/github.com/docker/distribution/Dockerfile
@@ -1,49 +1,59 @@
-# syntax=docker/dockerfile:1.3
+# syntax=docker/dockerfile:1
-ARG GO_VERSION=1.16.15
-ARG GORELEASER_XX_VERSION=1.2.5
+ARG GO_VERSION=1.19.9
+ARG ALPINE_VERSION=3.16
+ARG XX_VERSION=1.2.1
-FROM --platform=$BUILDPLATFORM crazymax/goreleaser-xx:${GORELEASER_XX_VERSION} AS goreleaser-xx
-FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS base
-COPY --from=goreleaser-xx / /
-RUN apk add --no-cache file git
+FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
+FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
+COPY --from=xx / /
+RUN apk add --no-cache bash coreutils file git
+ENV GO111MODULE=auto
+ENV CGO_ENABLED=0
WORKDIR /go/src/github.com/docker/distribution
+FROM base AS version
+ARG PKG="github.com/docker/distribution"
+RUN --mount=target=. \
+ VERSION=$(git describe --match 'v[0-9]*' --dirty='.m' --always --tags) REVISION=$(git rev-parse HEAD)$(if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi); \
+ echo "-X ${PKG}/version.Version=${VERSION#v} -X ${PKG}/version.Revision=${REVISION} -X ${PKG}/version.Package=${PKG}" | tee /tmp/.ldflags; \
+ echo -n "${VERSION}" | tee /tmp/.version;
+
FROM base AS build
-ENV GO111MODULE=auto
-ENV CGO_ENABLED=0
-# GIT_REF is used by goreleaser-xx to handle the proper git ref when available.
-# It will fallback to the working tree info if empty and use "git tag --points-at"
-# or "git describe" to define the version info.
-ARG GIT_REF
ARG TARGETPLATFORM
-ARG PKG="github.com/distribution/distribution"
+ARG LDFLAGS="-s -w"
ARG BUILDTAGS="include_oss include_gcs"
-RUN --mount=type=bind,rw \
- --mount=type=cache,target=/root/.cache/go-build \
- --mount=target=/go/pkg/mod,type=cache \
- goreleaser-xx --debug \
- --name="registry" \
- --dist="/out" \
- --main="./cmd/registry" \
- --flags="-v" \
- --ldflags="-s -w -X '$PKG/version.Version={{.Version}}' -X '$PKG/version.Revision={{.Commit}}' -X '$PKG/version.Package=$PKG'" \
- --tags="$BUILDTAGS" \
- --files="LICENSE" \
- --files="README.md"
-
-FROM scratch AS artifact
-COPY --from=build /out/*.tar.gz /
-COPY --from=build /out/*.zip /
-COPY --from=build /out/*.sha256 /
+RUN --mount=type=bind,target=/go/src/github.com/docker/distribution,rw \
+ --mount=type=cache,target=/root/.cache/go-build \
+ --mount=target=/go/pkg/mod,type=cache \
+ --mount=type=bind,source=/tmp/.ldflags,target=/tmp/.ldflags,from=version \
+ set -x ; xx-go build -trimpath -ldflags "$(cat /tmp/.ldflags) ${LDFLAGS}" -o /usr/bin/registry ./cmd/registry \
+ && xx-verify --static /usr/bin/registry
FROM scratch AS binary
-COPY --from=build /usr/local/bin/registry* /
+COPY --from=build /usr/bin/registry /
+
+FROM base AS releaser
+ARG TARGETOS
+ARG TARGETARCH
+ARG TARGETVARIANT
+WORKDIR /work
+RUN --mount=from=binary,target=/build \
+ --mount=type=bind,target=/src \
+ --mount=type=bind,source=/tmp/.version,target=/tmp/.version,from=version \
+ VERSION=$(cat /tmp/.version) \
+ && mkdir -p /out \
+ && cp /build/registry /src/README.md /src/LICENSE . \
+ && tar -czvf "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.gz" * \
+ && sha256sum -z "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.gz" | awk '{ print $1 }' > "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.gz.sha256"
+
+FROM scratch AS artifact
+COPY --from=releaser /out /
-FROM alpine:3.14
+FROM alpine:${ALPINE_VERSION}
RUN apk add --no-cache ca-certificates
COPY cmd/registry/config-dev.yml /etc/docker/registry/config.yml
-COPY --from=build /usr/local/bin/registry /bin/registry
+COPY --from=binary /registry /bin/registry
VOLUME ["/var/lib/registry"]
EXPOSE 5000
ENTRYPOINT ["registry"]