FROM openshift/golang-builder:1.16 AS velero-builder
ADD . .
RUN mkdir -p /go/src/github.com/vmware-tanzu/velero
RUN tar --strip-components=1 -xvf release-1.4.5.tar.gz -C /go/src/github.com/vmware-tanzu/velero
RUN cd /go/src/github.com/vmware-tanzu/velero \
&& CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static" -X github.com/vmware-tanzu/velero/pkg/buildinfo.Version=v1.5.2-MTC' ./cmd/velero

FROM openshift/golang-builder:1.16 AS restic-builder
ADD . .
RUN mkdir -p /go/src/github.com/restic/restic
RUN tar --strip-components=1 -xvf restic-release-1.4.5.tar.gz -C /go/src/github.com/restic/restic
RUN cd /go/src/github.com/restic/restic \
&& CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' ./cmd/restic

FROM registry.redhat.io/ubi8/ubi-minimal
RUN microdnf -y install nmap-ncat procps-ng && microdnf clean all
COPY --from=velero-builder /go/src/github.com/vmware-tanzu/velero/velero velero
COPY --from=restic-builder /go/src/github.com/restic/restic/restic /usr/bin/restic

USER nobody:nobody

ENTRYPOINT ["/velero"]

LABEL \
        com.redhat.component="openshift-migration-velero-container" \
        version="v1.4.5" \
        name="rhmtc/openshift-migration-velero" \
        summary="Migration Toolkit for Containers Velero Controller" \
        maintainer="Migration Team <ocp-migrate-team@redhat.com>" \
        License="BSD 2-Clause" \
        io.k8s.display-name="Migration Toolkit for Containers" \
        io.openshift.tags="migration" \
        io.k8s.description="Migration Toolkit for Containers Velero Controller" \
        io.openshift.build.commit.id="6e664dc7a1cb3abea72c58cb44340028f6ba44ef" \
        io.openshift.build.source-location="https://github.com/konveyor/velero" \
        io.openshift.build.commit.url="https://github.com/konveyor/velero/commit/6e664dc7a1cb3abea72c58cb44340028f6ba44ef"
