From 75df8174df1489ed8c601a5eadbc94ee505e2747 Mon Sep 17 00:00:00 2001 From: Marian Koreniuk Date: Sun, 8 Nov 2026 01:08:00 +0100 Subject: [PATCH] build(monitoring): respin the Alerta image on a patched base Alerta 9.1.0 is the latest upstream release, and alerta/alerta-web:9.1.0 still carries the Debian packages of its build day, the compiler toolchain and -dev headers it built its wheels with, and Python packages whose fixes came out after the release. The monitoring stack ran that image unpinned. A purge in a layer on top of the upstream image would leave the files in the lower layers, so the result is flattened into an empty image and the upstream image config is restated. cryptography stays below 47 because pyOpenSSL requires it, and lxml stays on 5.x. Assisted-by: LLM Signed-off-by: Marian Koreniuk Co-authored-by: europrinter --- packages/system/monitoring/Makefile | 22 ++++++- .../monitoring/images/alerta/Containerfile | 61 +++++++++++++++++++ .../monitoring/templates/alerta/alerta.yaml | 2 +- .../monitoring/tests/alerta_image_test.yaml | 40 ++++++++++++ packages/system/monitoring/values.yaml | 3 + 5 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 packages/system/monitoring/images/alerta/Containerfile create mode 100644 packages/system/monitoring/tests/alerta_image_test.yaml diff --git a/packages/system/monitoring/Makefile b/packages/system/monitoring/Makefile index c392b0a54..fa5e1dfd6 100644 --- a/packages/system/monitoring/Makefile +++ b/packages/system/monitoring/Makefile @@ -7,7 +7,7 @@ include ../../../hack/package.mk test: helm unittest . -.PHONY: image image-otelcol-tracing +.PHONY: image image-otelcol-tracing image-alerta # The collector is versioned by its upstream release, pinned in the # Containerfile; bump COZYSTACK_REV for a respin on the same release (a new @@ -16,7 +16,14 @@ OTELCOL_VERSION = $(shell awk -F= '/^ARG VERSION=/{print $$2}' images/otelcol-tr COZYSTACK_REV = 0 COMPONENT_VERSION = v$(OTELCOL_VERSION)-cozystack.$(COZYSTACK_REV) -image: image-otelcol-tracing +# Alerta is versioned by the upstream release it respins, pinned in the +# Containerfile; bump ALERTA_COZYSTACK_REV for a respin on the same release. +ALERTA_VERSION = $(shell awk -F= '/^ARG VERSION=/{print $$2}' images/alerta/Containerfile) +ALERTA_COZYSTACK_REV = 0 +ALERTA_COMPONENT_VERSION = v$(ALERTA_VERSION)-cozystack.$(ALERTA_COZYSTACK_REV) + +image: image-otelcol-tracing image-alerta +.NOTPARALLEL: image image-otelcol-tracing: docker buildx build images/otelcol-tracing \ @@ -28,3 +35,14 @@ image-otelcol-tracing: IMAGE="$(REGISTRY)/otelcol-tracing:$(COMPONENT_VERSION)@$$(yq e '."containerimage.digest"' images/otelcol-tracing.json -o json -r)" \ yq -i '.tracingCollector.image = strenv(IMAGE)' values.yaml rm -f images/otelcol-tracing.json + +image-alerta: + docker buildx build images/alerta \ + --file images/alerta/Containerfile \ + $(call image-tags,alerta,$(ALERTA_COMPONENT_VERSION)) \ + $(call cache-args,alerta) \ + --metadata-file images/alerta.json \ + $(BUILDX_ARGS) + IMAGE="$(REGISTRY)/alerta:$(ALERTA_COMPONENT_VERSION)@$$(yq e '."containerimage.digest"' images/alerta.json -o json -r)" \ + yq -i '.alerta.image = strenv(IMAGE)' values.yaml + rm -f images/alerta.json diff --git a/packages/system/monitoring/images/alerta/Containerfile b/packages/system/monitoring/images/alerta/Containerfile new file mode 100644 index 000000000..0c4108b6d --- /dev/null +++ b/packages/system/monitoring/images/alerta/Containerfile @@ -0,0 +1,61 @@ +# Alerta 9.1.0 is the latest upstream release, and its image still carries the +# Debian packages of its build day plus the toolchain it compiled wheels with. +# The respin upgrades the OS packages, drops the build-only ones and lifts the +# Python packages whose fixes postdate the release, within the ranges the +# installed packages declare: cryptography stays below 47 for pyOpenSSL, and +# lxml stays on 5.x. A bump of VERSION needs the digest of the new tag's index +# as well. +ARG VERSION=9.1.0 + +FROM docker.io/alerta/alerta-web:${VERSION}@sha256:693845fb8a95a483c8c9d560786f661f5b6198e5ea0baa6ddf368a7e53c94f39 AS patched + +USER root +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get purge -y build-essential linux-libc-dev libc6-dev python3-dev \ + libpq-dev libldap2-dev libsasl2-dev libxml2-dev libxslt1-dev libexpat1-dev git \ + && apt-get autoremove -y \ + && rm -rf /var/lib/apt/lists/* \ + && /venv/bin/pip install --no-cache-dir --upgrade \ + 'PyJWT>=2.14.0' 'certifi>=2026.10.18' 'brotli>=1.2.1' 'aiohttp>=3.14.4' \ + 'urllib3>=2.8.0' 'pyasn1>=0.6.5' 'pymongo>=4.18.3' 'dnspython>=2.9.0' 'msgpack>=1.2.3' \ + && /venv/bin/pip check \ + && pip install --no-cache-dir --upgrade virtualenv 'filelock>=4.2.1' + +# A purge on top of the upstream layers hides files without removing them, so +# the result is copied into an empty image. That drops the image config with +# the layers; it is restated below exactly as the upstream image declares it, +# because docker-entrypoint.sh renders the nginx, uWSGI and Alerta configs from +# these variables. +FROM scratch + +COPY --from=patched / / + +ENV PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/venv/bin \ + GPG_KEY=7169605F62C751356D054A26A821E680E5FA6305 \ + PYTHON_VERSION=3.13.12 \ + PYTHON_SHA256=2a84cd31dd8d8ea8aaff75de66fc1b4b0127dd5799aa50a64ae9a313885b4593 \ + PYTHONUNBUFFERED=1 \ + PIP_DISABLE_PIP_VERSION_CHECK=1 \ + PIP_NO_CACHE_DIR=1 \ + SERVER_VERSION=9.1.0 \ + CLIENT_VERSION=8.5.3 \ + WEBUI_VERSION=8.7.1 \ + NGINX_WORKER_PROCESSES=1 \ + NGINX_WORKER_CONNECTIONS=1024 \ + UWSGI_PROCESSES=5 \ + UWSGI_LISTEN=100 \ + UWSGI_BUFFER_SIZE=8192 \ + UWSGI_MAX_WORKER_LIFETIME=30 \ + UWSGI_WORKER_LIFETIME_DELTA=3 \ + HEARTBEAT_SEVERITY=major \ + HK_EXPIRED_DELETE_HRS=2 \ + HK_INFO_DELETE_HRS=12 \ + ALERTA_SVR_CONF_FILE=/app/alertad.conf \ + ALERTA_CONF_FILE=/app/alerta.conf \ + ALERTA_WEB_CONF_FILE=/web/config.json + +USER 1001 +EXPOSE 8080 1717 +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["supervisord", "-c", "/app/supervisord.conf"] diff --git a/packages/system/monitoring/templates/alerta/alerta.yaml b/packages/system/monitoring/templates/alerta/alerta.yaml index 6376eaa9e..b6fe55b93 100644 --- a/packages/system/monitoring/templates/alerta/alerta.yaml +++ b/packages/system/monitoring/templates/alerta/alerta.yaml @@ -173,7 +173,7 @@ spec: spec: containers: - name: alerta - image: "alerta/alerta-web:9.1.0" + image: {{ include "cozy-lib.image" (list .Values.alerta.image $) }} imagePullPolicy: IfNotPresent resources: {{- toYaml .Values.alerta.resources | nindent 12 }} env: diff --git a/packages/system/monitoring/tests/alerta_image_test.yaml b/packages/system/monitoring/tests/alerta_image_test.yaml new file mode 100644 index 000000000..cd98e8dfb --- /dev/null +++ b/packages/system/monitoring/tests/alerta_image_test.yaml @@ -0,0 +1,40 @@ +suite: alerta runs the image from values through cozy-lib.image +templates: + - templates/alerta/alerta.yaml + +release: + name: monitoring + namespace: tenant-root + +set: + _cluster: + issuer-name: letsencrypt-prod + solver: http01 + gateway-enabled: "false" + _namespace: + host: example.org + ingress: tenant-root + +tests: + - it: renders alerta.image as the container image + set: + alerta.image: ghcr.io/cozystack/cozystack/alerta:v9.1.0-cozystack.0@sha256:0000000000000000000000000000000000000000000000000000000000000000 + documentSelector: + path: kind + value: Deployment + asserts: + - equal: + path: spec.template.spec.containers[0].image + value: ghcr.io/cozystack/cozystack/alerta:v9.1.0-cozystack.0@sha256:0000000000000000000000000000000000000000000000000000000000000000 + + - it: prefixes the image with the cluster images-registry when set + set: + _cluster.images-registry: mirror.example.com + alerta.image: ghcr.io/cozystack/cozystack/alerta:v9.1.0-cozystack.0@sha256:0000000000000000000000000000000000000000000000000000000000000000 + documentSelector: + path: kind + value: Deployment + asserts: + - equal: + path: spec.template.spec.containers[0].image + value: mirror.example.com/ghcr.io/cozystack/cozystack/alerta:v9.1.0-cozystack.0@sha256:0000000000000000000000000000000000000000000000000000000000000000 diff --git a/packages/system/monitoring/values.yaml b/packages/system/monitoring/values.yaml index 2abaed368..11f03cf03 100644 --- a/packages/system/monitoring/values.yaml +++ b/packages/system/monitoring/values.yaml @@ -68,6 +68,9 @@ tracingCollector: cpu: 100m memory: 256Mi alerta: + # Alerta respun on a patched base (images/alerta); `make image` replaces this + # upstream default with the cozystack build. + image: docker.io/alerta/alerta-web:9.1.0@sha256:693845fb8a95a483c8c9d560786f661f5b6198e5ea0baa6ddf368a7e53c94f39 storage: 10Gi storageClassName: "" resources: