Skip to content
Commits on Source (8)
......@@ -10,7 +10,7 @@ stages:
- tag
variables:
CI_REGISTRY_IMAGE_VERSION: "2.1.0"
CI_REGISTRY_IMAGE_VERSION: "2.1.1"
CI_CONTAINER_BUILD_ARCHS: "amd64:arm64"
container-test:
......
......@@ -10,7 +10,7 @@ The utility allows for multi-architecture builds of container images and their o
Basic usage
---
The CI-pipeline of this project illustrates how the template and it's container are used. A minimal x86
The CI-pipeline of this project illustrates how the template and it's container are used.
```yaml
include:
......@@ -28,6 +28,16 @@ Multi-arch example
The variable `CI_CONTAINER_BUILD_ARCHS` controls which architectures to include. It's a `:`-separated list of supported architectures. If the job is picked up by a runner of differing architectures, QEMU is used to cross-compile the container image. On matching architectures the build is done natively. Which runner executes a certain job can be controlled via the jobs `tags`.
**Note:** QEMU requires some kernel configuration on the host this container is running on. On a Fedora 36 host it is enough to install the `qemu-user-static` package on the host (not in the CI) and start the `systemd-binfmt` service. **Additionally** the container used for this pipeline has to run `--privileged` as it needs access to the virtualization features of the kernel and the host.
Supported architectures:
- amd64
- arm64/aarch64
- arm32
Example:
```yaml
include:
# On same gitlab instance
......@@ -37,7 +47,7 @@ include:
variables:
CI_REGISTRY_IMAGE_VERSION: "1.0.0"
CI_CONTAINER_BUILD_ARCHS: "amd64:arm64"
CI_CONTAINER_BUILD_ARCHS: "amd64:arm64:arm32"
container-build-x86_64:
tags:
......@@ -46,4 +56,11 @@ container-build-x86_64:
container-build-arm64:
tags:
- arm64
# arm32 is cross-compiled on a amd64 host
# the host has qemu-user-static installed and qemu-arm registered
container-build-arm32:
tags:
- x86_64
- qemu
```
......@@ -13,7 +13,7 @@ variables:
inherit:
default: false
variables: true
image: quay.io/sheogorath/build-ah-engine:2.1.0
image: quay.io/sheogorath/build-ah-engine:2.1.1
before_script:
- podman login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- export VCS_REF="$CI_COMMIT_SHA"
......@@ -30,7 +30,7 @@ variables:
$CI_REGISTRY_BUILD_ARGS
-t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-$CI_REGISTRY_IMAGE_ARCH"
--format docker
.
"${CI_REGISTRY_BUILD_CONTEXT:-.}"
- podman push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-$CI_REGISTRY_IMAGE_ARCH"
- podman push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-$CI_REGISTRY_IMAGE_ARCH" "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-latest-$CI_REGISTRY_IMAGE_ARCH"
......@@ -66,7 +66,7 @@ container-tagging:
inherit:
default: false
variables: true
image: quay.io/sheogorath/build-ah-engine:2.1.0
image: quay.io/sheogorath/build-ah-engine:2.1.1
before_script:
- podman login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- export BUILD_DATE="$(date --rfc-3339 ns)"
......
......@@ -83,6 +83,11 @@ podman pull "$CONTAINER_IMAGE_NAME-arm64" || \
IMAGE_PULL_SUCCESS=1 || \
true
# shellcheck disable=SC2015
podman pull "$CONTAINER_IMAGE_NAME-arm32" && \
IMAGE_PULL_SUCCESS=1 || \
true
if [ "$IMAGE_PULL_SUCCESS" == "0" ]; then
echo "Error: No images pulled" >&2
exit 1
......
......@@ -50,7 +50,7 @@ PREFIX=""
SUFFIX=""
LATEST=0
LOCAL=0
MULTIARCH_SUPPORTED="amd64|arm64|aarch64"
MULTIARCH_SUPPORTED="amd64|arm64|aarch64|arm32"
if ! command -v "$CONTAINER_CMD" >/dev/null 2>&1; then
CONTAINER_CMD=docker
......
......@@ -11,6 +11,9 @@ EOF
podman build --format docker -t mytest-latest:test-arm64 -f- <<EOF
FROM scratch
EOF
podman build --format docker -t mytest-latest:test-arm32 -f- <<EOF
FROM scratch
EOF
TEST_OUTPUT="$(mktemp)"
TEST_VERIFY_OUTPUT="$(mktemp)"
......@@ -40,5 +43,6 @@ podman rmi -f registry.example.com/latest-test:1 \
registry.example.com/latest-test:latest
podman rmi -f "$(podman images -q mytest-latest:test-amd64)"
podman rmi -f "$(podman images -q mytest-latest:test-arm64)"
podman rmi -f "$(podman images -q mytest-latest:test-arm32)"
exit $EXIT_CODE