FROM openshift/golang-builder:1.12 AS velero-builder
ADD . .
RUN mkdir -p /go/src/github.com/vmware-tanzu/velero
RUN tar --strip-components=1 -xvf konveyor-1.3.2.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.3.2-MTC' ./cmd/velero

FROM openshift/golang-builder:1.12 AS restic-builder
ADD . .
RUN mkdir -p /go/src/github.com/restic/restic
RUN tar --strip-components=1 -xvf konveyor-v0.9.6.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 ubi8-minimal:8-released
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.2" \
        name="rhcam/openshift-migration-velero" \
        License="BSD 2-Clause" \
        release="4" \
        io.k8s.display-name="Cluster Application Migration" \
        io.openshift.tags="migration" \
        io.k8s.description="Cluster Application Migration Velero Controller" \
        summary="Cluster Application Migration Velero Controller" \
        maintainer="Migration Team <ocp-migrate-team@redhat.com>"
