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

Add support for setting target architecture for images #5209

Merged

Conversation

beni0888
Copy link
Collaborator

Description of the change

This PR adds support for specifying the target CPU architecture for the docker images through a parameter in the call to the corresponding make target. This PR doesn't modify the CI, it just adds support for building the docker images for different platforms through Make.

Benefits

Docker images can be built for different CPU architectures (others than AMD64), so developers using computers with those architectures can take advantage of it.

Possible drawbacks

N/A

Applicable issues

Additional information

N/A

@beni0888 beni0888 added component/ci Issue related to kubeapps ci system kind/enhancement An issue that reports an enhancement for an implemented feature labels Aug 11, 2022
@netlify
Copy link

netlify bot commented Aug 11, 2022

Deploy Preview for kubeapps-dev canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit 06929cb
🔍 Latest deploy log https://app.netlify.com/sites/kubeapps-dev/deploys/630f2947dd614e000895ee6e

Copy link
Contributor

@antgamdia antgamdia left a comment

Choose a reason for hiding this comment

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

See the comment about generalizing the target arch and adding a comment. Otherwise, +1

@@ -27,10 +28,10 @@ all: kubeapps/dashboard kubeapps/apprepository-controller kubeapps/kubeops kubea
# Currently the go projects include the whole repository as the docker context
# only because the shared pkg/ directories?
kubeapps/%:
DOCKER_BUILDKIT=1 docker build -t kubeapps/$*$(IMG_MODIFIER):$(IMAGE_TAG) --build-arg "VERSION=${VERSION}" -f cmd/$*/Dockerfile .
DOCKER_BUILDKIT=1 docker build --platform "linux/$(TARGET_ARCHITECTURE)" -t kubeapps/$*$(IMG_MODIFIER):$(IMAGE_TAG) --build-arg "VERSION=${VERSION}" -f cmd/$*/Dockerfile .
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd do --platform "$(TARGET_ARCHITECTURE)" instead. If Windows containers are ever supported in buildkit, we'd like to also have them.

Besides, I'd rather add some notes commenting the following:

The target platforms supported by buildkit are linux/amd64, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6

However, if a user happens to use Windows Containers (not WSL or VM), it won't work as buildkit doesn't support Windows (see microsoft/Windows-Containers#34)

Note that it refers to the container architecture. For instance, a Docker for Windows or Docker for Mac usually runs Linux containers,so we only need to build these two target platforms: linux/amd64 and linux/arm64

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After discussing this topic, we've agreed on just providing the TARGET_ARCHITECTURE and keeping hardcoded the operating system, as we won't likely support Windows containers in the near future and have to provide the whole platform string (eg. linux/arm64) would add more complexity.

In addition, instead of adding a not regarding the supported platforms, I've decided to add a validation in the code, so Make will fail with a descriptive error if an unsupported architecture is provided.

@beni0888 beni0888 force-pushed the support-docker-target-architecture branch from 40b142f to b553849 Compare August 31, 2022 06:03
Copy link
Collaborator

@castelblanque castelblanque left a comment

Choose a reason for hiding this comment

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

Excellent, thanks for the improvement!

Jesús Benito Calzada added 2 commits August 31, 2022 11:25
Signed-off-by: Jesús Benito Calzada <bjesus@vmware.com>
Signed-off-by: Jesús Benito Calzada <bjesus@vmware.com>
@beni0888 beni0888 force-pushed the support-docker-target-architecture branch from b553849 to 06929cb Compare August 31, 2022 09:26
@beni0888 beni0888 merged commit 2403fcf into vmware-tanzu:main Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-not-required component/ci Issue related to kubeapps ci system kind/enhancement An issue that reports an enhancement for an implemented feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support building docker images for ARM architectures
4 participants