diff --git a/Dockerfile.ubi b/Dockerfile.ubi new file mode 100644 index 0000000000..30ea36953b --- /dev/null +++ b/Dockerfile.ubi @@ -0,0 +1,56 @@ +FROM --platform=$BUILDPLATFORM quay.io/konveyor/builder:ubi9-latest AS builder +ARG BUILDPLATFORM +ARG TARGETOS +ARG TARGETARCH +ARG GIT_SHA +ARG GIT_TREE_STATE +ARG PKG +ARG VERSION +ARG REGISTRY +ARG TARGETARCH +ARG TARGETVARIANT +ARG GOPROXY +ARG BIN + +ENV GOPATH=$APP_ROOT \ + GOPROXY=${GOPROXY} \ + GOOS=${TARGETOS} \ + GOARCH=${TARGETARCH} \ + GOARM=${TARGETVARIANT} \ + LDFLAGS="-X ${PKG}/pkg/buildinfo.Version=${VERSION} -X ${PKG}/pkg/buildinfo.GitSHA=${GIT_SHA} -X ${PKG}/PKG/BUILDINFO.GitTreeState=${GIT_TREE_STATE} -X ${PKG}/pkg/buildinfo.ImageRegistry=${REGISTRY} -extldflags '-static'" + +COPY . /go/src/github.com/vmware-tanzu/velero + +WORKDIR /go/src/github.com/vmware-tanzu/velero + +RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -mod=mod -ldflags "${LDFLAGS}" -o /go/src/velero github.com/vmware-tanzu/velero/cmd/velero +RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -mod=mod -ldflags "${LDFLAGS}" -o /go/src/velero-helper github.com/vmware-tanzu/velero/cmd/velero-helper + +FROM --platform=$BUILDPLATFORM quay.io/konveyor/builder:ubi9-latest AS restic-builder +ARG BUILDPLATFORM +ARG TARGETOS +ARG TARGETARCH + +ENV GOPATH=$APP_ROOT + +RUN mkdir -p $APP_ROOT/src/github.com/restic \ + && cd $APP_ROOT/src/github.com/restic \ + && git clone https://github.com/konveyor/restic -b konveyor-dev + +WORKDIR $APP_ROOT/src/github.com/restic/restic + +RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -mod=mod -ldflags '-extldflags "-static"' -o $APP_ROOT/src/restic github.com/restic/restic/cmd/restic + +FROM registry.access.redhat.com/ubi9-minimal +RUN microdnf -y update && microdnf -y install nmap-ncat && microdnf -y reinstall tzdata && microdnf clean all +COPY --from=builder /go/src/velero velero +COPY --from=builder /go/src/velero-helper velero-helper +COPY --from=restic-builder /opt/app-root/src/restic /usr/bin/restic + +RUN mkdir -p /home/velero +RUN chmod -R 777 /home/velero + +USER 65534:65534 +ENV HOME=/home/velero + +ENTRYPOINT ["/velero"] diff --git a/Makefile b/Makefile index 5686881992..54c9d70fcf 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ GCR_IMAGE ?= $(GCR_REGISTRY)/$(BIN) # We allow the Dockerfile to be configurable to enable the use of custom Dockerfiles # that pull base images from different registries. -VELERO_DOCKERFILE ?= Dockerfile +VELERO_DOCKERFILE ?= Dockerfile.ubi BUILDER_IMAGE_DOCKERFILE ?= hack/build-image/Dockerfile # Calculate the realpath of the build-image Dockerfile as we `cd` into the hack/build @@ -197,6 +197,7 @@ ifneq ($(BUILDX_ENABLED), true) $(error $(BUILDX_ERROR)) endif @docker buildx build --pull \ + --no-cache \ --output=type=$(BUILDX_OUTPUT_TYPE) \ --platform $(BUILDX_PLATFORMS) \ $(addprefix -t , $(IMAGE_TAGS)) \ @@ -209,7 +210,7 @@ endif --build-arg=GIT_TREE_STATE=$(GIT_TREE_STATE) \ --build-arg=REGISTRY=$(REGISTRY) \ --build-arg=RESTIC_VERSION=$(RESTIC_VERSION) \ - -f $(VELERO_DOCKERFILE) . + -f$(VELERO_DOCKERFILE) . @echo "container: $(IMAGE):$(VERSION)" ifeq ($(BUILDX_OUTPUT_TYPE)_$(REGISTRY), registry_velero) docker pull $(IMAGE):$(VERSION)