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

Update WORKSPACE #3368

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 0 additions & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
75 changes: 75 additions & 0 deletions doc/build-the-builder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# 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 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 | <nothing> | 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:
```
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.