FROM openshift/golang-builder:1.16 AS builder
ENV DISTRIBUTION_DIR /go/src/github.com/docker/distribution
ENV BUILDTAGS include_oss include_gcs
ARG GOOS=linux
ARG GOARCH=amd64
ARG GOARM=6
ARG VERSION
ARG REVISION
COPY release-1.4.7.tar.gz $DISTRIBUTION_DIR/release-1.4.7.tar.gz
WORKDIR $DISTRIBUTION_DIR
RUN tar --strip-components=1 -xvf release-1.4.7.tar.gz
RUN CGO_ENABLED=0 make PREFIX=/go clean binaries && file ./bin/registry | grep "statically linked"

FROM registry.redhat.io/ubi8/ubi-minimal
RUN microdnf -y install  ca-certificates httpd-tools
COPY --from=builder /go/src/github.com/docker/distribution/cmd/registry/config-dev.yml /etc/docker/registry/config.yml
COPY --from=builder /go/src/github.com/docker/distribution/bin/registry /bin/registry
VOLUME ["/var/lib/registry"]
EXPOSE 5000
ENTRYPOINT ["registry"]
CMD ["serve", "/etc/docker/registry/config.yml"]

LABEL \
        com.redhat.component="openshift-migration-registry-container" \
        version="v1.4.7" \
        name="rhmtc/openshift-migration-registry" \
        summary="Migration Toolkit for Containers Registry" \
        maintainer="Migration Team <ocp-migrate-team@redhat.com>" \
        License="Apache License 2.0" \
        io.k8s.display-name="Migration Toolkit for Containers" \
        io.openshift.tags="migration" \
        io.k8s.description="Migration Toolkit for Containers Registry" \
        io.openshift.build.commit.id="494dcd04e5c2aff0ce866b4d262e5f6595cdca08" \
        io.openshift.build.source-location="https://github.com/konveyor/distribution" \
        io.openshift.build.commit.url="https://github.com/konveyor/distribution/commit/494dcd04e5c2aff0ce866b4d262e5f6595cdca08"
