From e3a37a6d845a96051027b145fa2458b8cb7e67b8 Mon Sep 17 00:00:00 2001 From: cfillekes Date: Fri, 1 Dec 2023 11:42:50 -0500 Subject: [PATCH 1/3] Create build-the-builder.md Document the manual build of CDI builder helper container and typical make targets Signed-off-by: cfillekes --- doc/build-the-builder.md | 74 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 doc/build-the-builder.md diff --git a/doc/build-the-builder.md b/doc/build-the-builder.md new file mode 100644 index 0000000000..d0621c8377 --- /dev/null +++ b/doc/build-the-builder.md @@ -0,0 +1,74 @@ +# Build The KubeVirt CDI Builder Container + +## Native Build toolchain + +1. Install the [prerequisites](https://github.com/kubevirt/kubevirt/blob/main/docs/build-the-builder.md#prerequisites) as in the instructions for building the KubeVirt builder container. +2. Also install `jq` if the docker build utility you use is `podman-buildah`. +3. Build the KubeVirt builder container if you haven't already + + +## Environment Variables and defaults + + + | env variable | default | option or example | + | ------------ | ------- | -------- | + | BUILD_ARCH | amd64 | s390x arm64 amd64 | + | DOCKER_PREFIX | quay.io/kubevirt | icr.io/kubevirt, docker.io/ibm, ... | + | QUAY_REPOSITORY | kubevirt-cdi-bazel-builder | | + | UNTAGGED_BUILDER_IMAGE | quay.io/kubevirt/kubevirt-cdi-bazel-builder | ${DOCKER_PREFIX}/${QUAY_REPOSITORY} | + | BUILDER_TAG | | s390xTest01 | + + +An example of setting these environment variables would be: +``` +export BUILD_ARCH=s390x +export DOCKER_PREFIX="icr.io/kubevirt" +export QUAY_REPOSITORY=kubevirt-cdi-bazel-builder +export UNTAGGED_BUILDER_IMAGE=${DOCKER_PREFIX}/${QUAY_REPOSITORY} +export BUILDER_TAG=s390xTest01 +``` + +## Manual build of the builder container + +The point of this step is to build the CDI builder/helper container described in `hack/build/docker/builder/Dockerfile`. + +``` +cd hack/build/docker/builder +``` + +The build can be conducted with either `podman-buildah` or `docker`. + +### With Podman-buildah + +With podman-buildah the builder image can be built and pushed with: + +``` +buildah build --platform linux/${BUILD_ARCH} --manifest ${UNTAGGED_BUILDER_IMAGE}:${BUILDER_TAG} . +buildah manifest push --all ${UNTAGGED_BUILDER_IMAGE}:${BUILDER_TAG} docker://${UNTAGGED_BUILDER_IMAGE}:${BUILDER_TAG} +``` +and you can check the digest with: +``` +podman inspect $(podman images | grep ${UNTAGGED_BUILDER_IMAGE} | grep ${BUILDER_TAG} | awk '{ print $3 }') | jq '.[]["Digest"]' +``` + +### With docker + +With docker, the builder image can be built and pushed with: + +``` +docker build --tag ${UNTAGGED_BUILDER_IMAGE}:${BUILDER_TAG} . +``` +and you can check the digest with: +``` +docker images --digests | grep ${UNTAGGED_BUILDER_IMAGE} | grep ${BUILDER_TA +G} | awk '{ print $4 }' +``` + +## Make Target + + +`make builder-push` both builds the KubeVirt CDI builder image and pushes it to the registry you specified in the environment variables (above); however the script only works when the following condition is false: +``` +git diff-index --quiet HEAD~1 hack/build/docker +``` +since the make target to build the builder is only intended to run during a post-submit job where the PR has squashed the candidate into a single commit. From 938d25c636f7e2e1e626a201207199f52f301605 Mon Sep 17 00:00:00 2001 From: Gxliu <74167178+kpol-lgx@users.noreply.github.com> Date: Tue, 6 Aug 2024 18:05:19 +0800 Subject: [PATCH 2/3] Update WORKSPACE Delete one of the two identical lines. Signed-off-by: Gxliu <74167178+kpol-lgx@users.noreply.github.com> --- WORKSPACE | 5 ----- 1 file changed, 5 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index f177c3585c..68f452a9f8 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,11 +1,6 @@ register_toolchains("//:python_toolchain") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") -load( - "@bazel_tools//tools/build_defs/repo:http.bzl", - "http_archive", - "http_file", -) load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") http_archive( From 8120a03516689c6d209cb51414ab005aeb955d1a Mon Sep 17 00:00:00 2001 From: Gxliu <74167178+kpol-lgx@users.noreply.github.com> Date: Wed, 7 Aug 2024 02:25:42 +0800 Subject: [PATCH 3/3] Update build-the-builder.md change the option of BUILD_ARCH. cover arm64 with aarch64. Signed-off-by: Gxliu <74167178+kpol-lgx@users.noreply.github.com> --- doc/build-the-builder.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/build-the-builder.md b/doc/build-the-builder.md index d0621c8377..2bf080a1dc 100644 --- a/doc/build-the-builder.md +++ b/doc/build-the-builder.md @@ -12,12 +12,13 @@ | env variable | default | option or example | | ------------ | ------- | -------- | - | BUILD_ARCH | amd64 | s390x arm64 amd64 | + | BUILD_ARCH | amd64 | s390x aarch64 amd64 | | DOCKER_PREFIX | quay.io/kubevirt | icr.io/kubevirt, docker.io/ibm, ... | | QUAY_REPOSITORY | kubevirt-cdi-bazel-builder | | | UNTAGGED_BUILDER_IMAGE | quay.io/kubevirt/kubevirt-cdi-bazel-builder | ${DOCKER_PREFIX}/${QUAY_REPOSITORY} | | BUILDER_TAG | | s390xTest01 | +Note: although `arm64` is equal to `aarch64` in CPU, this project only use `aarch64` in souce code. An example of setting these environment variables would be: ```