-
Notifications
You must be signed in to change notification settings - Fork 149
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
Specify platform as linux/${ARCH}
when cross-building docker images
#2503
Conversation
docker run --rm ${mount_cmd} \ | ||
--platform linux/${ARCH}\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also have a way to override default linux
os with something like ${OS}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but do we anticipate that somebody ever changes base image in the dockerfile? Is there any use-case for that?
When using arch specific dockerfiles it's also necessary to specify `--platform` flag. Otherwise dockerx can build arm image with x86_64 binaries, which may not work properly in deployment.
dbd7d0a
to
46ec8bd
Compare
@@ -66,5 +71,5 @@ sed \ | |||
-e "s|ARG_ARCH|${ARCH}|g" \ | |||
-e "s|ARG_SOURCE_BIN|${SOURCE_BIN}|g" \ | |||
Dockerfile.in > .dockerfile-${ARCH} | |||
docker buildx build --push --pull --sbom=true ${baseimagearg:-} --build-arg kanister_version=${VERSION} -t ${IMAGE}:${VERSION} -f .dockerfile-${ARCH} . | |||
docker buildx build --push --pull --sbom=true ${baseimagearg:-} --build-arg kanister_version=${VERSION} -t ${IMAGE}:${VERSION} --platform linux/${ARCH} -f .dockerfile-${ARCH} . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for @PrasadG193: We should make the SBOM flag configurable. --sbom={ENABLE_SBOM}
or something like that. The packaging will fail if someone doesn't have the correct buildkit enabled.
Change Overview
When using arch specific dockerfiles it's also necessary to specify
--platform
flag. Otherwise dockerx can build arm image with x86_64 binaries, which may not work properly in deployment.Pull request type
Please check the type of change your PR introduces:
Issues
Test Plan
To test run on arm64 arch (M1/M2 mac):
Then check produced image:
Without changes:
With changes
To run full test follow the steps in #2091