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

Added support for s390x and ppc64le for multi-arch image build #956

Open
wants to merge 2 commits into
base: incubation
Choose a base branch
from

Conversation

satyamg1620
Copy link

Description

For creating multi-arch build image, use command make docker-buildx. For creating bundle build multi-arch image, use command make bundle-docker-build. Above commands build multi-arch images and will push into your provided image registry.

How Has This Been Tested?

This has been tested by deploying the build images on openshift cluster and the Opendatahub operator is running up successfully. Our openshift cluster is running upon s390x architecture, so we have used corresponding image generated by the commands provided in Description section. Our changes will not affect other areas of the code. It is just adding support for s390x and ppc64le for multi-arch image build

Merge criteria:

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Copy link

openshift-ci bot commented Apr 5, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign lavlas for approval. For more information see the Kubernetes Code Review Process.

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

Needs approval from an approver in each of these files:

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

Copy link

openshift-ci bot commented Apr 5, 2024

Hi @satyamg1620. Thanks for your PR.

I'm waiting for a opendatahub-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@satyamg1620
Copy link
Author

@zdtsw , can you please add the required reviewers for this PR?

@zdtsw
Copy link
Member

zdtsw commented Apr 10, 2024

@zdtsw , can you please add the required reviewers for this PR?

@satyamg1620 previous 2 auto assigned reviewers were wrongly added, thus I removed them from the list.
we are still internally discussing how to deal with multi-arch requests before we start code review process.

@satyamg1620
Copy link
Author

@zdtsw , can you please provide update ?

Makefile Outdated
.PHONY: docker-buildx
docker-buildx: ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' ./Dockerfiles/Dockerfile > ./Dockerfiles/Dockerfile.cross
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to replace all ^FROM with FROM --platform=${BUILDPLATFORM} here?

Choose a reason for hiding this comment

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

Yes

Makefile Outdated

.PHONY: bundle-docker-buildx
bundle-docker-buildx: ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
Copy link
Contributor

Choose a reason for hiding this comment

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

Move the recipe to a variable. (Different --tag, so probably, a function)

Choose a reason for hiding this comment

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

I agree to this.

Copy link
Author

Choose a reason for hiding this comment

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

@ykaliuta Can you please verify the changes as requested?

Makefile Outdated
PLATFORMS ?= linux/amd64,linux/s390x,linux/ppc64le
.PHONY: docker-buildx
docker-buildx: ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to have universal Dockerfile for both types of builds?

Choose a reason for hiding this comment

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

We have tried to use the same Dockerfile for all platform & only use buildx to invoke it with different platform . So Dockerfile is generic. Dockerfile.cross is generated just to handle the platform option passed as a run type argument during buildx command execution. Once its job is done , we are deleting Dockerfile.cross & maintaining only single Dockerfile

Makefile Outdated
PLATFORMS ?= linux/amd64,linux/s390x,linux/ppc64le
.PHONY: docker-buildx
docker-buildx: ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
Copy link
Contributor

Choose a reason for hiding this comment

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

Make Dockerfile.cross target and dependency of it.

Choose a reason for hiding this comment

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

Since its generated on the fly & removed after execution , i don't understand the use of keeping it as target.

Makefile Outdated
docker-buildx: ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' ./Dockerfiles/Dockerfile > ./Dockerfiles/Dockerfile.cross
- docker buildx create --name project-v3-builder
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably makes sense to have BUILDX_BILDER or something.

Choose a reason for hiding this comment

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

buildx is an idle solution for multicross platform build & push operation with minimal code change

@satyamg1620
Copy link
Author

@ykaliuta can you please review the requested changes?

3 similar comments
@satyamg1620
Copy link
Author

@ykaliuta can you please review the requested changes?

@satyamg1620
Copy link
Author

@ykaliuta can you please review the requested changes?

@satyamg1620
Copy link
Author

@ykaliuta can you please review the requested changes?

@modassarrana89
Copy link

@satyamg1620 Can you please rebase

@satyamg1620
Copy link
Author

@ykaliuta can you please review the requested changes?

Comment on lines +5 to +6
ARG TARGETOS
ARG TARGETARCH

Choose a reason for hiding this comment

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

we don't need these ARGs here, because they are default one get assigned while building.

# Buildx function for building multi-arch image
define func_buildx
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' $1 > Dockerfile.cross

Choose a reason for hiding this comment

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

I'm wondering instead of this can we feed the platform tag directly into the Dockerfile.cross itself(will not make any difference for the non-buildx flow)

Copy link

openshift-ci bot commented May 29, 2024

@mkumatag: changing LGTM is restricted to collaborators

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

None yet

6 participants