2022-02-14 12:23:58 +01:00
|
|
|
# syntax=docker/dockerfile:1.3
|
|
|
|
|
2022-09-05 13:23:56 +02:00
|
|
|
ARG BCI_MICRO=registry.suse.com/bci/bci-micro
|
|
|
|
ARG BCI_GO=registry.suse.com/bci/golang
|
|
|
|
ARG GO_VERSION=1.18
|
2022-02-14 12:23:58 +01:00
|
|
|
ARG GORELEASER_XX_VERSION=1.2.5
|
|
|
|
|
|
|
|
FROM crazymax/goreleaser-xx:${GORELEASER_XX_VERSION} AS goreleaser-xx
|
2022-09-05 13:23:56 +02:00
|
|
|
FROM ${BCI_GO}:${GO_VERSION} AS base
|
2022-02-14 12:23:58 +01:00
|
|
|
COPY --from=goreleaser-xx / /
|
2022-09-05 13:23:56 +02:00
|
|
|
RUN zypper --non-interactive install -y file git-core
|
2022-02-14 12:23:58 +01:00
|
|
|
WORKDIR /src
|
|
|
|
|
|
|
|
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/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-17 16:05:17 +01:00
|
|
|
FROM scratch AS artifact
|
2022-02-14 12:23:58 +01:00
|
|
|
COPY --from=build /out/*.tar.gz /
|
|
|
|
COPY --from=build /out/*.zip /
|
|
|
|
COPY --from=build /out/*.sha256 /
|
|
|
|
|
2022-02-17 16:05:17 +01:00
|
|
|
FROM scratch AS binary
|
2022-02-14 12:23:58 +01:00
|
|
|
COPY --from=build /usr/local/bin/registry* /
|
|
|
|
|
2022-09-05 13:23:56 +02:00
|
|
|
FROM ${BCI_MICRO}
|
2022-02-14 12:23:58 +01:00
|
|
|
COPY cmd/registry/config-dev.yml /etc/docker/registry/config.yml
|
|
|
|
COPY --from=build /usr/local/bin/registry /bin/registry
|
|
|
|
VOLUME ["/var/lib/registry"]
|
|
|
|
EXPOSE 5000
|
|
|
|
ENTRYPOINT ["registry"]
|
|
|
|
CMD ["serve", "/etc/docker/registry/config.yml"]
|