2022-01-12 15:34:08 +00:00
|
|
|
# syntax=docker/dockerfile:1.3
|
2015-06-01 10:15:53 +00:00
|
|
|
|
2021-07-06 03:43:13 +00:00
|
|
|
ARG GO_VERSION=1.17
|
2022-01-12 15:34:08 +00:00
|
|
|
ARG GORELEASER_XX_VERSION=1.2.5
|
2015-01-29 23:37:22 +00:00
|
|
|
|
2022-01-12 15:34:08 +00:00
|
|
|
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
|
|
|
|
WORKDIR /go/src/github.com/docker/distribution
|
2017-05-23 08:58:05 +00:00
|
|
|
|
2022-01-12 15:34:08 +00:00
|
|
|
FROM base AS build
|
|
|
|
ENV GO111MODULE=auto
|
|
|
|
ENV CGO_ENABLED=0
|
2022-02-08 11:53:38 +00:00
|
|
|
# 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
|
2022-01-12 15:34:08 +00:00
|
|
|
ARG TARGETPLATFORM
|
2023-05-09 08:24:36 +00:00
|
|
|
ARG PKG="github.com/docker/distribution"
|
2022-01-12 15:34:08 +00:00
|
|
|
ARG BUILDTAGS="include_oss include_gcs"
|
2023-05-09 08:24:36 +00:00
|
|
|
RUN --mount=type=bind,target=/go/src/github.com/docker/distribution,rw \
|
2022-01-12 15:34:08 +00:00
|
|
|
--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"
|
2016-07-21 23:14:32 +00:00
|
|
|
|
2022-02-08 11:53:38 +00:00
|
|
|
FROM scratch AS artifact
|
2022-01-19 15:54:25 +00:00
|
|
|
COPY --from=build /out/*.tar.gz /
|
|
|
|
COPY --from=build /out/*.zip /
|
|
|
|
COPY --from=build /out/*.sha256 /
|
|
|
|
|
2022-01-12 15:34:08 +00:00
|
|
|
FROM scratch AS binary
|
|
|
|
COPY --from=build /usr/local/bin/registry* /
|
2014-12-10 23:57:41 +00:00
|
|
|
|
2022-05-25 14:22:25 +00:00
|
|
|
FROM alpine:3.16
|
2022-01-12 15:34:08 +00:00
|
|
|
RUN apk add --no-cache ca-certificates
|
2018-10-15 22:46:01 +00:00
|
|
|
COPY cmd/registry/config-dev.yml /etc/docker/registry/config.yml
|
2022-01-12 15:34:08 +00:00
|
|
|
COPY --from=build /usr/local/bin/registry /bin/registry
|
2015-06-11 04:24:16 +00:00
|
|
|
VOLUME ["/var/lib/registry"]
|
2014-12-10 23:57:41 +00:00
|
|
|
EXPOSE 5000
|
2015-04-06 14:05:11 +00:00
|
|
|
ENTRYPOINT ["registry"]
|
2016-01-19 22:26:15 +00:00
|
|
|
CMD ["serve", "/etc/docker/registry/config.yml"]
|