Skip to content

Instantly share code, notes, and snippets.

@dmc5179
Last active October 7, 2022 14:31
Show Gist options
  • Save dmc5179/1e99e9ba5fa6130654add81c813b3a39 to your computer and use it in GitHub Desktop.
Save dmc5179/1e99e9ba5fa6130654add81c813b3a39 to your computer and use it in GitHub Desktop.
Dockerfile to build Docker registry on RHEL UBI Images
FROM registry.redhat.io/ubi8/go-toolset:latest AS build
ENV DISTRIBUTION_DIR /opt/app-root/src/go/src/github.com/docker/distribution
ENV BUILDTAGS include_oss include_gcs
ENV GOPATH /opt/app-root/src/go
ENV GOBIN /usr/lib/golang/bin
ARG GOOS=linux
ARG GOARCH=s390x
#ARG GOARM=6
WORKDIR $DISTRIBUTION_DIR
COPY . $DISTRIBUTION_DIR
USER root
RUN chown -R default.root /opt/app-root/src/go
USER default
RUN go get -v . \
&& CGO_ENABLED=0 make PREFIX=/opt/app-root/src/go clean binaries && file ./bin/registry | grep "statically linked"
FROM registry.redhat.io/ubi8/ubi-minimal:latest
USER root
RUN microdnf clean all \
&& microdnf -y update \
&& microdnf clean all \
&& rm -rf /var/cache/dnf
COPY cmd/registry/config-dev.yml /etc/docker/registry/config.yml
COPY --from=build /opt/app-root/src/go/src/github.com/docker/distribution/bin/registry /bin/registry
#USER default
VOLUME ["/var/lib/registry"]
EXPOSE 5000
ENTRYPOINT ["registry"]
CMD ["serve", "/etc/docker/registry/config.yml"]
@dmc5179
Copy link
Author

dmc5179 commented May 26, 2020

To build:

  • Clone the docker registry repository
git clone https://github.com/docker/distribution.git
  • Switch to a release like 2.7 (which is what this was tested against)
cd distribution
git checkout release/2.7
  • Download this Dockerfile to the repository location
wget https://gist.githubusercontent.com/dmc5179/1e99e9ba5fa6130654add81c813b3a39/raw/4af5e22f0e50973aad5da5a7a337e1836a68010c/Dockerfile.rhel
  • Build the image
podman build -t <imageName> -f Dockerfile.rhel .

Note that this image is based on the UBI images from Red Hat. This should support platforms like s390x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment