From 943df62ff9880c5e4bf265277b169219177f55a6 Mon Sep 17 00:00:00 2001 From: Michael Engel Date: Wed, 27 Mar 2024 17:20:17 +0100 Subject: [PATCH] moved base container images to root directory The BlueChi base images for build and integration test as well as the rpm build image have been moved from tests/containers/ to containers/ directory. It also includes the necessary path changes. The build and push script has also been fixed. Signed-off-by: Michael Engel --- README.developer.md | 2 +- build-scripts/build-push-containers.sh | 12 ++++++++---- .../Containerfile.bluechi-rpm-build | 0 {tests/containers => containers}/build-base | 2 +- .../containers => containers}/integration-test-base | 0 requirements.txt | 3 +-- tests/README.md | 11 +++-------- 7 files changed, 14 insertions(+), 16 deletions(-) rename Containerfile.bluechi-rpm-build => containers/Containerfile.bluechi-rpm-build (100%) rename {tests/containers => containers}/build-base (96%) rename {tests/containers => containers}/integration-test-base (100%) diff --git a/README.developer.md b/README.developer.md index 1dea3b68d8..44cda5dd06 100644 --- a/README.developer.md +++ b/README.developer.md @@ -223,7 +223,7 @@ meson configure -Dwith_analyzer=true builddir ``` Since the result of the analysis is heavily dependent on the compiler version, flags, etc., its recommended to build -and run tests for BlueChi also in the [build-base](./tests/containers/build-base): +and run tests for BlueChi also in the [build-base](./containers/build-base): ```bash # navigate into the bluechi directory diff --git a/build-scripts/build-push-containers.sh b/build-scripts/build-push-containers.sh index 86b581207d..da46edb0a2 100755 --- a/build-scripts/build-push-containers.sh +++ b/build-scripts/build-push-containers.sh @@ -7,21 +7,25 @@ IMAGE="$1" # The 2nd parameter is optional and it specifies the container architecture. If omitted, all archs will be built. ARCHITECTURES="${2:-amd64 arm64}" SCRIPT_DIR=$(dirname "$(readlink -f "$0")") -CONTAINER_FILE_DIR=$SCRIPT_DIR"/../tests/containers" +ROOT_DIR=$SCRIPT_DIR"/../" +CONTAINER_FILE_DIR=$SCRIPT_DIR"/../containers" function push(){ buildah manifest push --all $IMAGE "docker://quay.io/bluechi/$IMAGE" } function build(){ - buildah manifest exists $IMAGE || buildah manifest create $IMAGE + # remove old image, ignore result + buildah manifest rm $IMAGE &> /dev/null + + buildah manifest create $IMAGE for arch in $ARCHITECTURES; do buildah bud --tag "quay.io/bluechi/$IMAGE" \ --manifest $IMAGE \ --arch ${arch} \ - --build-context root_dir=${SCRIPT_DIR}/.. \ - ${CONTAINER_FILE_DIR}/${IMAGE} + -f ${CONTAINER_FILE_DIR}/${IMAGE} \ + ${ROOT_DIR} done } diff --git a/Containerfile.bluechi-rpm-build b/containers/Containerfile.bluechi-rpm-build similarity index 100% rename from Containerfile.bluechi-rpm-build rename to containers/Containerfile.bluechi-rpm-build diff --git a/tests/containers/build-base b/containers/build-base similarity index 96% rename from tests/containers/build-base rename to containers/build-base index 2dfa0bfc1f..c35fffe9f5 100644 --- a/tests/containers/build-base +++ b/containers/build-base @@ -34,7 +34,7 @@ RUN dnf install -y dnf-plugin-config-manager && \ dnf -y clean all # Install python dependencies -COPY --from=root_dir requirements.txt . +COPY requirements.txt . RUN python3 -m venv /opt/bluechi-env && \ . /opt/bluechi-env/bin/activate && \ pip install -r requirements.txt && \ diff --git a/tests/containers/integration-test-base b/containers/integration-test-base similarity index 100% rename from tests/containers/integration-test-base rename to containers/integration-test-base diff --git a/requirements.txt b/requirements.txt index 2803d91fa5..36a652deaa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ -# NOTE: build-base container image needs to be rebuilt after changing this file! +# NOTE: containers/build-base image needs to be rebuilt after changing this file! # Try to keep linter package versions aligned with latest Fedora RPM versions black==24.1.1 flake8==6.0.0 isort==5.13.2 - diff --git a/tests/README.md b/tests/README.md index b9cbfc1f87..97e770c918 100644 --- a/tests/README.md +++ b/tests/README.md @@ -193,12 +193,7 @@ New id 'UUID' added to test '/tests/path_to_your_new_test'. The integration tests rely on containers as separate compute entities. These containers are used to simulate BlueChi's functional behavior on a single runner. -The [containers](./containers/) directory contains two container files. - -The `integration-test-base` file describes the builder base image that is published to -[https://quay.io/repository/bluechi/integration-test-base](https://quay.io/repository/bluechi/integration-test-base). It contains core dependencies such as systemd and devel packages. - -Both, `integration-test-local` as well as `integration-test-snapshot`, are based on the builder base image for the integration tests and contain compiled products and configurations for integration testing. +Both, [integration-test-local](./containers/integration-test-local) as well as [integration-test-snapshot](./containers/integration-test-snapshot), are based on the [integration-base](../containers/integration-test-base) image which contains core dependencies such as systemd and devel packages. The base image is published to [https://quay.io/repository/bluechi/integration-test-base](https://quay.io/repository/bluechi/integration-test-base). ### Updating container images in registry @@ -206,11 +201,11 @@ The base images can either be build and pushed locally or via a github workflow #### Building and pushing via workflow -The base images [build-base](./containers/build-base) and [integration-test-base](./containers/integration-test-base) can be built and pushed to quay by using the [Container Image Workflow](../.github/workflows/images.yml). It can be found and triggered here in the [Actions tab](https://github.com/eclipse-bluechi/bluechi/actions/workflows/images.yml) of the BlueChi repo. +The base images [build-base](../containers/build-base) and [integration-test-base](../containers/integration-test-base) can be built and pushed to quay by using the [Container Image Workflow](../.github/workflows/images.yml). It can be found and triggered here in the [Actions tab](https://github.com/eclipse-bluechi/bluechi/actions/workflows/images.yml) of the BlueChi repo. #### Building and pushing locally -The base images [build-base](./containers/build-base) and [integration-test-base](./containers/integration-test-base) are built for multiple architectures (arm64 and amd64) using the [build-containers.sh](../build-scripts/build-containers.sh) script. It'll build the images for the supported architectures as well as a manifest, which can then be pushed to the registry. +The base images [build-base](../containers/build-base) and [integration-test-base](../containers/integration-test-base) are built for multiple architectures (arm64 and amd64) using the [build-containers.sh](../build-scripts/build-containers.sh) script. It'll build the images for the supported architectures as well as a manifest, which can then be pushed to the registry. Building for multiple architectures, the following packages are required: