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