Skip to content

Commit

Permalink
Build changes for upstream Velero with OpenShift
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Fruchtman <[email protected]>
  • Loading branch information
msfrucht committed Oct 23, 2024
1 parent c53ab20 commit 4746a3d
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 2 deletions.
56 changes: 56 additions & 0 deletions Dockerfile.ubi
Original file line number Diff line number Diff line change
@@ -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"]
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)) \
Expand All @@ -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)
Expand Down

0 comments on commit 4746a3d

Please sign in to comment.