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: build all binaries for the target OS/ARCH #49

Merged
merged 1 commit into from
May 15, 2023

Conversation

tjohnson31415
Copy link
Contributor

Motivation

Fix the multi-arch builds so that all binaries are built for the target OS/ARCH. Currently, only the puller is built for the target.

Modifications

  • export GOOS and GOARCH within multi-command RUN that builds the binaries

Result

Signed-off-by: Travis Johnson <tsjohnso@us.ibm.com>
Copy link
Member

@njhill njhill left a comment

Choose a reason for hiding this comment

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

Thanks @tjohnson31415!

@kserve-oss-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: njhill, tjohnson31415

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [njhill,tjohnson31415]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@njhill
Copy link
Member

njhill commented May 15, 2023

/lgtm

@kserve-oss-bot kserve-oss-bot merged commit 600f092 into kserve:main May 15, 2023
@tjohnson31415 tjohnson31415 deleted the fix-multiarch branch May 15, 2023 20:59
@@ -116,8 +116,8 @@ ARG TARGETARCH
# https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
GOOS=${TARGETOS:-linux} \
GOARCH=${TARGETARCH:-amd64} \
export GOOS=${TARGETOS:-linux} && \
Copy link
Member

Choose a reason for hiding this comment

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

@tjohnson31415 -- I know I missed the review window on this one, but would it not have been more Docker-esque to pull the two variables out into a Dockerfile ENV declaration?

ENV GOOS=${TARGETOS:-linux} \
    GOARCH=${TARGETARCH:-amd64}
RUN --mount=... \
    go build -o ...

Only RUN, COPY, and ADD create layers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, these two environment variables are configurations only for the single RUN command. If this docker stage was FROM'd in a final pushed image, I'd think it better avoid the extra env vars created by ENV, but this is an intermediate stage so 🤷

@ckadner ckadner mentioned this pull request May 18, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants