FROM openshift/golang-builder:1.12 AS velero-builder
COPY . /go/src/github.com/heptio/velero
RUN cd /go/src/github.com/heptio/velero \
&& CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' ./cmd/velero

FROM openshift/golang-builder:1.12 AS restic-builder
COPY restic-fusor-v0.9.4/ /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
COPY --from=velero-builder /go/src/github.com/heptio/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.0" \
        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>"
