Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ARM images #332

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Dockerfile-velero-restore-helper.ubi
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
FROM quay.io/konveyor/builder:latest AS builder
FROM quay.io/konveyor/builder:ubi9-latest AS builder
Copy link
Member

@kaovilai kaovilai Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FROM quay.io/konveyor/builder:ubi9-latest AS builder
FROM --platform=$BUILDPLATFORM quay.io/konveyor/builder:ubi9-latest AS builder
ARG BUILDPLATFORM

Since we are optimizing, and golang can cross compile binary, and this is not the final stage, we can set BUILDPLATFORM to get more optimum performance.

ref: cross-compilation

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but this would make only multi platform builds faster, not?

since multi platform builds are CI responsibility (and I do not know how PROW does it), I think we do not need this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right do not need. but doesn't hurt to add for local dev builds either when building for dev/customers who are on arch other than the dev machine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im on arm, so this would speed up builds of amd64 images to use on amd64 cluster.

Copy link
Member

@kaovilai kaovilai Aug 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would make single platform build faster if the OS building (ie. laptop is arm64) is different than intended image platform (for amd64 cluster)

ARG TARGETOS
ARG TARGETARCH

ENV GOPATH=$APP_ROOT

COPY . $APP_ROOT/src/github.com/vmware-tanzu/velero

WORKDIR $APP_ROOT/src/github.com/vmware-tanzu/velero
RUN CGO_ENABLED=0 GOOS=linux go build -a -mod=mod -ldflags '-extldflags "-static"' -o $APP_ROOT/src/velero-restore-helper github.com/vmware-tanzu/velero/cmd/velero-restore-helper

FROM registry.access.redhat.com/ubi8-minimal
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -mod=mod -ldflags '-extldflags "-static"' -o $APP_ROOT/src/velero-restore-helper github.com/vmware-tanzu/velero/cmd/velero-restore-helper

FROM registry.access.redhat.com/ubi9-minimal
RUN microdnf -y update && microdnf clean all

COPY --from=builder /opt/app-root/src/velero-restore-helper velero-restore-helper
Expand Down
23 changes: 17 additions & 6 deletions Dockerfile.ubi
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
# TODO! Find a real ubi8 image for golang 1.16
FROM quay.io/konveyor/builder:ubi9-latest AS builder
Copy link
Member

@kaovilai kaovilai Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FROM quay.io/konveyor/builder:ubi9-latest AS builder
FROM --platform=$BUILDPLATFORM quay.io/konveyor/builder:ubi9-latest AS builder
ARG BUILDPLATFORM

ARG TARGETOS
ARG TARGETARCH

ENV GOPATH=$APP_ROOT

COPY . /go/src/github.com/vmware-tanzu/velero

WORKDIR /go/src/github.com/vmware-tanzu/velero
RUN CGO_ENABLED=0 GOOS=linux go build -a -mod=mod -ldflags '-extldflags "-static" -X github.com/vmware-tanzu/velero/pkg/buildinfo.Version=konveyor-dev' -o /go/src/velero github.com/vmware-tanzu/velero/cmd/velero
RUN CGO_ENABLED=0 GOOS=linux go build -a -mod=mod -ldflags '-extldflags "-static"' -o /go/src/velero-helper github.com/vmware-tanzu/velero/cmd/velero-helper

RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -mod=mod -ldflags '-extldflags "-static" -X github.com/vmware-tanzu/velero/pkg/buildinfo.Version=konveyor-dev' -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 '-extldflags "-static"' -o /go/src/velero-helper github.com/vmware-tanzu/velero/cmd/velero-helper

FROM quay.io/konveyor/builder:ubi9-latest AS restic-builder
Copy link
Member

@kaovilai kaovilai Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FROM quay.io/konveyor/builder:ubi9-latest AS restic-builder
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
&& 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=linux go build -a -mod=mod -ldflags '-extldflags "-static"' -o $APP_ROOT/src/restic github.com/restic/restic/cmd/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
Expand Down