# --- Build Stage --- #
FROM rhel8/go-toolset:1.13 AS builder

ENV PATH "$PATH:/go/bin"
ENV GOPATH="/go"
ENV GOBIN="/go/bin"

COPY quay-operator.tar.gz /tmp
RUN cd /tmp && tar xf quay-operator.tar.gz
WORKDIR /tmp/quay-operator
RUN go build -mod=vendor -o /tmp/build/quay-operator cmd/manager/main.go


# --- Deployment Stage --- #
FROM registry.redhat.io/ubi8/ubi:latest

LABEL com.redhat.component="quay-setup-operator-container"
LABEL name="quay-setup-operator"
LABEL version="v3.3.4"
LABEL io.k8s.display-name="Red Hat Quay Operator"
LABEL io.k8s.description="Deploys and manages Red Hat Quay"
LABEL summary="Deploys and manages Red Hat Quay"
LABEL maintainer "Red Hat <support@redhat.com>"

COPY --from=builder /tmp/build/quay-operator /usr/bin/quay-operator

# Does not require root
USER 1001

ENTRYPOINT ["/usr/bin/quay-operator"]
