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

Specify platform as linux/${ARCH} when cross-building docker images #2503

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion build/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ build_licenses_info_image() {
elif grep docker /proc/1/cgroup -qa; then
mount_cmd="--volumes-from $(grep docker -m 1 /proc/self/cgroup|cut -d/ -f3)"
fi
if [ -z "${ARCH:-""}" ]; then
echo "ARCH must be set"
exit 1
fi
docker run --rm ${mount_cmd} \
--platform linux/${ARCH}\
Copy link
Contributor

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} ?

Copy link
Contributor Author

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?

"ghcr.io/kanisterio/license-extractor:4e0a91a" \
--mode merge \
--source ${src_dir} \
Expand Down Expand Up @@ -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} .
Copy link
Contributor

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.

docker images -q ${IMAGE}:${VERSION}