FROM rhel8/go-toolset:1.13.4 AS builder

WORKDIR /opt/app-root/src/go/src/github.com/tektoncd/pipeline
COPY . .
RUN CGO_ENABLED=0 \
    go build -mod=vendor -v -o /tmp/openshift-pipelines-creds-init \
    ./cmd/creds-init

FROM ubi8-minimal:8-released

ENV BINARY=creds-init.orig \
    KO_APP=/ko-app \
    USER_UID=1001 \
    USER_NAME=openshift-pipelines-creds-init

COPY --from=builder /tmp/openshift-pipelines-creds-init ${KO_APP}/${BINARY}
COPY openshift/ci-operator/uidwrapper ${KO_APP}/creds-init

RUN chgrp -R 0 ${KO_APP} && \
    chmod -R g=u ${KO_APP} /etc/passwd

LABEL \
      com.redhat.component="openshift-pipelines-creds-init-rhel8-container" \
      name="openshift-pipelines-tech-preview/pipelines-creds-init-rhel8" \
      version="v1.0.0" \
      summary="Red Hat OpenShift Pipelines Creds-init" \
      maintainer="vdemeest@redhat.com" \
      description="Red Hat OpenShift Pipelines Creds-init" \
      io.k8s.display-name="Red Hat OpenShift Pipelines Creds-init"

ENTRYPOINT ["/ko-app/creds-init"]
