From be7a7b63be830c6c85d95709f0bf9cad90b39d04 Mon Sep 17 00:00:00 2001 From: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com> Date: Tue, 24 Nov 2026 12:22:19 +0100 Subject: [PATCH 1/3] spike(zookeeper): hummingbird based image --- hummingbird-spike/zookeeper.Dockerfile | 545 +++++++++++++++++++++++++ 1 file changed, 545 insertions(+) create mode 100644 hummingbird-spike/zookeeper.Dockerfile diff --git a/hummingbird-spike/zookeeper.Dockerfile b/hummingbird-spike/zookeeper.Dockerfile new file mode 100644 index 000000000..fea261892 --- /dev/null +++ b/hummingbird-spike/zookeeper.Dockerfile @@ -0,0 +1,545 @@ +# SPIKE: Apache ZooKeeper on Red Hat Hummingbird, without any UBI9 stage. +# +# UNTESTED. Self-contained replacement for the chain +# zookeeper -> java-base -> vector -> stackable-base -> ubi9-minimal +# zookeeper (builder) -> java-devel -> stackable-devel -> ubi9-minimal +# Local images (local-image/...) are replaced by named stages in this file. +# +# Build from the repository root (the build context must be the repo root): +# +# podman build -f hummingbird-spike/zookeeper.Dockerfile -t zookeeper-hum:spike . +# +# Useful intermediate targets: devel, java-devel, rust-binaries, vector-builder, zookeeper-builder, rootfs +# +# podman build -f hummingbird-spike/zookeeper.Dockerfile --target rootfs -t zk-hum-rootfs . +# +# Not covered yet (see hummingbird-findings.md): +# - nano / iputils (not in the Hummingbird repo) +# - inotify-tools is not in the Hummingbird repo either. As in vector/Dockerfile we install the +# RPM from the Stackable package repo, but that is an el9 build on a Fedora-derived system. +# - arm64 (only amd64 was inspected) +# - SBOM (CycloneDX) for the JRE: the portable JRE is a tarball and does not appear in the rpmdb + +ARG DEVEL_BASE=registry.access.redhat.com/hi/openjdk:21-builder +# TODO: pin the base by digest, like the other Dockerfiles in this repo do + +ARG PRODUCT_VERSION=3.9.6 +ARG RELEASE_VERSION=0.0.0-dev +ARG STACKABLE_USER_NAME=stackable +ARG STACKABLE_USER_UID=1000 +ARG STACKABLE_USER_GID=1000 +ARG JMX_EXPORTER_VERSION=1.4.0 +ARG LOGBACK_VERSION=1.3.15 +ARG JVMKILL_VERSION=0e410d8 +ARG CONFIG_UTILS_VERSION=0.5.1 +ARG CONTAINERDEBUG_VERSION=0.5.0 +ARG CERT_TOOLS_VERSION=0.1.1 +# From vector/boil-config.toml and stackable-devel/boil-config.toml (the "vector-build" variant) +ARG VECTOR_VERSION=0.58.0 +ARG VECTOR_RUST_TOOLCHAIN_VERSION=1.95.0 +ARG PROTOC_VERSION=36.2 +ARG INOTIFY_TOOLS=3.22.1.0-1.el9 + +# ============================================================================== +# devel: replaces stackable-devel. Hummingbird builder variant + user + Rust + patchable +# NOTE: this base also ships a JDK 21 that we do not use (JAVA_HOME is overridden below). + +FROM ${DEVEL_BASE} AS devel + +ARG STACKABLE_USER_NAME +ARG STACKABLE_USER_UID +ARG STACKABLE_USER_GID + +# Build stage only, nothing from it is shipped as is. The final image is FROM scratch and +# runs as ${STACKABLE_USER_UID}. root is needed because the base image defaults to UID 65532. +# hadolint ignore=DL3002 +USER 0 +SHELL ["/bin/bash", "-euo", "pipefail", "-c"] +# The base image sets HOME=/home/build +ENV HOME=/root + +COPY stackable-base/stackable/dnf.conf /etc/dnf/dnf.conf +COPY stackable-base/stackable/curlrc /root/.curlrc + +# Copied from stackable-devel/Dockerfile +ARG RUST_DEFAULT_TOOLCHAIN_VERSION=1.99.0 +ENV RUST_DEFAULT_TOOLCHAIN_VERSION=${RUST_DEFAULT_TOOLCHAIN_VERSION} +ENV CARGO_CYCLONEDX_CRATE_VERSION=0.5.9 +ENV CARGO_AUDITABLE_CRATE_VERSION=0.7.7 + +# tar, xz and gzip are not part of the builder image +# pkgconf-pkg-config provides the `pkg-config` command (package name unverified) +RUN <> /rootfs/stackable/.bashrc +printf 'if [ -f ~/.bashrc ]; then\n\tsource ~/.bashrc\nfi\n' >> /rootfs/stackable/.profile +EOF + +COPY stackable-base/stackable/curlrc /rootfs/stackable/.curlrc + +# Rust utilities, jvmkill, licenses, permission check script +COPY --chown=${STACKABLE_USER_UID}:0 --from=rust-binaries /config-utils/target/release/config-utils /rootfs/stackable/config-utils +COPY --chown=${STACKABLE_USER_UID}:0 --from=rust-binaries /config-utils/crates/config-utils/config-utils_bin.cdx.xml /rootfs/stackable/config-utils.cdx.xml +COPY --chown=${STACKABLE_USER_UID}:0 --from=rust-binaries /containerdebug/target/release/containerdebug /rootfs/stackable/containerdebug +COPY --chown=${STACKABLE_USER_UID}:0 --from=rust-binaries /containerdebug/crates/containerdebug/containerdebug_bin.cdx.xml /rootfs/stackable/containerdebug_bin.cdx.xml +COPY --chown=${STACKABLE_USER_UID}:0 --from=rust-binaries /secret-operator/target/release/cert-tools /rootfs/stackable/cert-tools +COPY --chown=${STACKABLE_USER_UID}:0 --from=rust-binaries /secret-operator/rust/cert-tools/cert-tools_bin.cdx.xml /rootfs/stackable/cert-tools_bin.cdx.xml +COPY --chown=${STACKABLE_USER_UID}:0 --from=jvmkill-builder /stackable/libjvmkill.so /rootfs/stackable/libjvmkill.so +COPY --chown=${STACKABLE_USER_UID}:0 shared/checks/check-permissions-ownership.sh /rootfs/usr/bin/check-permissions-ownership.sh + +# vector (same layering order for /licenses as the original chain: vector, java-base, zookeeper) +COPY --chown=${STACKABLE_USER_UID}:0 vector/licenses /rootfs/licenses +COPY --chown=${STACKABLE_USER_UID}:0 vector/stackable/bin /rootfs/stackable/bin +COPY --chown=${STACKABLE_USER_UID}:0 --from=vector-builder /app/* /rootfs/usr/local/bin/ +COPY java-base/licenses /rootfs/licenses +COPY zookeeper/licenses /rootfs/licenses + +# ZooKeeper +COPY --chown=${STACKABLE_USER_UID}:0 --from=zookeeper-builder /stackable/apache-zookeeper-${PRODUCT_VERSION}-stackable${RELEASE_VERSION}-bin /rootfs/stackable/apache-zookeeper-${PRODUCT_VERSION}-stackable${RELEASE_VERSION}-bin/ +COPY --chown=${STACKABLE_USER_UID}:0 --from=zookeeper-builder /stackable/zookeeper-${PRODUCT_VERSION}-stackable${RELEASE_VERSION}-src.tar.gz /rootfs/stackable/ +COPY --chown=${STACKABLE_USER_UID}:0 --from=zookeeper-builder /stackable/jmx /rootfs/stackable/jmx/ +COPY --chown=${STACKABLE_USER_UID}:0 --from=patched-logback /stackable/*-src.tar.gz /rootfs/stackable/ + +RUN < /rootfs/stackable/package_manifest.txt + +# dnf state and caches have no use in the final image (the rpmdb is kept) +rm -rf /rootfs/var/cache /rootfs/var/lib/dnf /rootfs/var/log/* + +chown -R ${STACKABLE_USER_UID}:0 /rootfs/stackable +chown -h ${STACKABLE_USER_UID}:0 /rootfs/stackable/zookeeper +chmod -R g=u /rootfs/stackable + +chroot /rootfs /usr/bin/check-permissions-ownership.sh /stackable ${STACKABLE_USER_UID} 0 +EOF + +# ============================================================================== +# FINAL ZOOKEEPER IMAGE + +FROM scratch + +ARG PRODUCT_VERSION +ARG RELEASE_VERSION +ARG STACKABLE_USER_UID + +COPY --from=rootfs /rootfs / + +LABEL \ + name="Apache ZooKeeper" \ + maintainer="info@stackable.tech" \ + vendor="Stackable GmbH" \ + version="${PRODUCT_VERSION}" \ + release="${RELEASE_VERSION}" \ + summary="The Stackable image for Apache ZooKeeper." \ + description="This image is deployed by the Stackable Operator for Apache ZooKeeper." + +LABEL org.opencontainers.image.authors="info@stackable.tech" +LABEL org.opencontainers.image.url="https://stackable.tech" +LABEL org.opencontainers.image.source="https://github.com/stackabletech/docker-images/" +LABEL org.opencontainers.image.vendor="Stackable GmbH" +LABEL org.opencontainers.image.licenses="Apache-2.0" + +# C.UTF-8 is built into glibc >= 2.35, so no langpack is needed (the Hummingbird images +# set LANG=en_US.UTF-8 but do not ship that locale) +ENV LANG=C.UTF-8 +ENV JAVA_HOME=/usr/lib/jvm/java-17 +ENV PATH="/usr/lib/jvm/java-17/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/stackable:/stackable/zookeeper/bin" +ENV ZOOKEEPER_HOME=/stackable/zookeeper +ENV HOME=/stackable +ENV LOG4J_FORMAT_MSG_NO_LOOKUPS=true + +# Mitigation for CVE-2026-114938, copied from java-base/Dockerfile +ARG TARGETARCH +ARG IS_AMD64=${TARGETARCH%arm64} +ENV JAVA_TOOL_OPTIONS="${IS_AMD64:+-XX:-UseBASE64Intrinsics}" + +USER ${STACKABLE_USER_UID} +WORKDIR /stackable/zookeeper +CMD ["bin/zkServer.sh", "start-foreground", "conf/zoo_sample.cfg"] From 84229192bd85ed757542d9add0bbd6d35a62ca35 Mon Sep 17 00:00:00 2001 From: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com> Date: Fri, 27 Nov 2026 12:07:28 +0100 Subject: [PATCH 2/3] refactor: migrate the final stage from "scratch" to "core-runtime" --- hummingbird-spike/zookeeper.Dockerfile | 123 +++++++++++++++---------- 1 file changed, 72 insertions(+), 51 deletions(-) diff --git a/hummingbird-spike/zookeeper.Dockerfile b/hummingbird-spike/zookeeper.Dockerfile index fea261892..521846f10 100644 --- a/hummingbird-spike/zookeeper.Dockerfile +++ b/hummingbird-spike/zookeeper.Dockerfile @@ -1,17 +1,8 @@ # SPIKE: Apache ZooKeeper on Red Hat Hummingbird, without any UBI9 stage. # -# UNTESTED. Self-contained replacement for the chain -# zookeeper -> java-base -> vector -> stackable-base -> ubi9-minimal -# zookeeper (builder) -> java-devel -> stackable-devel -> ubi9-minimal -# Local images (local-image/...) are replaced by named stages in this file. -# # Build from the repository root (the build context must be the repo root): # -# podman build -f hummingbird-spike/zookeeper.Dockerfile -t zookeeper-hum:spike . -# -# Useful intermediate targets: devel, java-devel, rust-binaries, vector-builder, zookeeper-builder, rootfs -# -# podman build -f hummingbird-spike/zookeeper.Dockerfile --target rootfs -t zk-hum-rootfs . +# docker image build -f hummingbird-spike/zookeeper.Dockerfile -t oci.stackable.tech/sandbox/zookeeper:3.9.6-humm . # # Not covered yet (see hummingbird-findings.md): # - nano / iputils (not in the Hummingbird repo) @@ -21,7 +12,11 @@ # - SBOM (CycloneDX) for the JRE: the portable JRE is a tarball and does not appear in the rpmdb ARG DEVEL_BASE=registry.access.redhat.com/hi/openjdk:21-builder -# TODO: pin the base by digest, like the other Dockerfiles in this repo do +# The base of the final image. The final image shares its layers with it, so this has to be an image +# that Red Hat certified (`preflight check container`, BasedOnUbi). It must be glibc based. +# Keep it on the same Hummingbird release as DEVEL_BASE. +ARG RUNTIME_BASE=registry.access.redhat.com/hi/core-runtime:latest +# TODO: pin the bases by digest, like the other Dockerfiles in this repo do ARG PRODUCT_VERSION=3.9.6 ARG RELEASE_VERSION=0.0.0-dev @@ -50,8 +45,8 @@ ARG STACKABLE_USER_NAME ARG STACKABLE_USER_UID ARG STACKABLE_USER_GID -# Build stage only, nothing from it is shipped as is. The final image is FROM scratch and -# runs as ${STACKABLE_USER_UID}. root is needed because the base image defaults to UID 65532. +# Build stage only, nothing from it is shipped as is. The final image runs as ${STACKABLE_USER_UID}. +# root is needed because the base image defaults to UID 65532. # hadolint ignore=DL3002 USER 0 SHELL ["/bin/bash", "-euo", "pipefail", "-c"] @@ -356,23 +351,27 @@ chmod -R g=u /stackable EOF # ============================================================================== -# rootfs: assembles the runtime filesystem from the Hummingbird RPM repo into /rootfs +# runtime-base: the base of the final image, only used to copy its filesystem + +FROM ${RUNTIME_BASE} AS runtime-base + +# ============================================================================== +# rootfs: assembles the runtime filesystem into /rootfs # (replaces stackable-base + java-base + the final RUN steps of zookeeper). -# The final image is FROM scratch because the distroless runtime has no shell to run -# any of these steps in. +# /rootfs starts as a copy of the runtime base (including its rpmdb) and the packages are installed on top +# of it. core-runtime has bash and coreutils but no rpm (checked, `dnf` not checked), so packages cannot be installed in the final stage. +# The last step of this stage extracts what differs from the runtime base into /additions. FROM ${DEVEL_BASE} AS rootfs ARG PRODUCT_VERSION ARG RELEASE_VERSION -ARG STACKABLE_USER_NAME ARG STACKABLE_USER_UID -ARG STACKABLE_USER_GID ARG TARGETARCH ARG INOTIFY_TOOLS -# Build stage only, nothing from it is shipped as is. The final image is FROM scratch and -# runs as ${STACKABLE_USER_UID}. root is needed because the base image defaults to UID 65532. +# Build stage only, nothing from it is shipped as is. The final image runs as ${STACKABLE_USER_UID}. +# root is needed because the base image defaults to UID 65532. # hadolint ignore=DL3002 USER 0 SHELL ["/bin/bash", "-euo", "pipefail", "-c"] @@ -380,33 +379,34 @@ ENV HOME=/root COPY stackable-base/stackable/dnf.conf /etc/dnf/dnf.conf +COPY --from=runtime-base / /rootfs + # Package list is a first guess based on what stackable-base, java-base and zkServer.sh use. # grep/sed/gawk are unverified (zkServer.sh and friends are bash scripts). +# bash and coreutils are already in the runtime base. # The JRE is installed on the build host only; we extract its tarball into the rootfs. RUN <> /rootfs/stackable/.bashrc -printf 'if [ -f ~/.bashrc ]; then\n\tsource ~/.bashrc\nfi\n' >> /rootfs/stackable/.profile -EOF - COPY stackable-base/stackable/curlrc /rootfs/stackable/.curlrc # Rust utilities, jvmkill, licenses, permission check script @@ -500,16 +485,52 @@ chmod -R g=u /rootfs/stackable chroot /rootfs /usr/bin/check-permissions-ownership.sh /stackable ${STACKABLE_USER_UID} 0 EOF +# The `additions` part: everything in /rootfs that is not in the runtime base, or that differs from it, goes +# to /additions. Only this is added on top of the runtime base, its layers stay unchanged. +# Files that were changed (the rpmdb, the ca-trust files) are included. The base is mounted, not copied. +# The stage's SHELL is bash, hadolint does not take it into account for process substitution here +# hadolint ignore=SC3001 +RUN --mount=type=bind,from=runtime-base,target=/base < /tmp/delta.lst +while IFS= read -r -d '' p; do + b="/base/$p" + if [ ! -e "$b" ] && [ ! -L "$b" ]; then + printf '%s\0' "$p" >> /tmp/delta.lst + elif [ -L "$p" ]; then + if [ ! -L "$b" ] || [ "$(readlink "$p")" != "$(readlink "$b")" ]; then printf '%s\0' "$p" >> /tmp/delta.lst; fi + elif [ -d "$p" ]; then + if [ ! -d "$b" ] || [ "$(meta "$p")" != "$(meta "$b")" ]; then printf '%s\0' "$p" >> /tmp/delta.lst; fi + elif [ -f "$p" ]; then + if [ ! -f "$b" ] || [ "$(meta "$p")" != "$(meta "$b")" ] || ! cmp -s "$p" "$b"; then printf '%s\0' "$p" >> /tmp/delta.lst; fi + else + printf '%s\0' "$p" >> /tmp/delta.lst + fi +done < <(find . -mindepth 1 -print0) + +echo "Entries added or changed compared to the runtime base: $(tr -cd '\0' < /tmp/delta.lst | wc -c)" +tar -C /rootfs --null --no-recursion -T /tmp/delta.lst -cf - | tar -C /additions --same-owner -xpf - + +# Files of the runtime base that are replaced (preflight may report them as modified files) +echo "Files of the runtime base that were changed:" +tr '\0' '\n' < /tmp/delta.lst | while IFS= read -r p; do + if [ -e "/base/$p" ] && [ ! -d "/base/$p" ]; then echo " $p"; fi +done +EOF + # ============================================================================== # FINAL ZOOKEEPER IMAGE -FROM scratch +# hadolint ignore=DL3006,DL3007 +FROM ${RUNTIME_BASE} ARG PRODUCT_VERSION ARG RELEASE_VERSION ARG STACKABLE_USER_UID -COPY --from=rootfs /rootfs / +COPY --from=rootfs /additions / LABEL \ name="Apache ZooKeeper" \ From 63ea1ac9c4c34d8ddb1eff3ccfd734f0e12ebb67 Mon Sep 17 00:00:00 2001 From: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com> Date: Fri, 27 Nov 2026 17:06:42 +0100 Subject: [PATCH 3/3] spike: Airflow image based on Hummingbird core-runtime --- hummingbird-spike/airflow.Dockerfile | 739 +++++++++++++++++++++++++++ 1 file changed, 739 insertions(+) create mode 100644 hummingbird-spike/airflow.Dockerfile diff --git a/hummingbird-spike/airflow.Dockerfile b/hummingbird-spike/airflow.Dockerfile new file mode 100644 index 000000000..9643ddf73 --- /dev/null +++ b/hummingbird-spike/airflow.Dockerfile @@ -0,0 +1,739 @@ +# SPIKE: Apache Airflow on Red Hat Hummingbird, without any UBI9 stage. +# +# Same approach as zookeeper.Dockerfile: named stages instead of the local-image chain, and a final +# image that is `FROM core-runtime` plus a delta. Build from the repository root (the build context +# must be the repo root): +# +# docker build -f hummingbird-spike/airflow.Dockerfile -t oci.stackable.tech/sandbox/airflow:3.3.2-humm . +# +# The defaults below are the values of airflow 3.3.2 in airflow/boil-config.toml and its dependencies. +# +# Not covered yet: +# - Which of the packages below exist in the Hummingbird repo is partly unverified, see the comments at +# the `dnf install` steps. The build fails on missing build dependencies and only reports missing +# optional runtime packages. +# - nano / iputils (not in the Hummingbird repo) +# - inotify-tools is not in the Hummingbird repo either, see zookeeper.Dockerfile +# - arm64 (only amd64 was inspected) +# - Python comes from `uv` (a python-build-standalone download), as in airflow/Dockerfile. It is not an RPM, +# so it does not appear in the rpmdb. The alternative would be the `python3.12` RPM of the Hummingbird repo. + +ARG DEVEL_BASE=registry.access.redhat.com/hi/rust:latest-builder +# The base of the final image, see zookeeper.Dockerfile. Must be glibc based. +ARG RUNTIME_BASE=registry.access.redhat.com/hi/core-runtime:latest +# TODO: pin the bases by digest, like the other Dockerfiles in this repo do + +ARG PRODUCT_VERSION=3.3.2 +ARG RELEASE_VERSION=0.0.0-dev +ARG STACKABLE_USER_NAME=stackable +ARG STACKABLE_USER_UID=1000 +ARG STACKABLE_USER_GID=1000 + +# airflow/boil-config.toml, version 3.3.2 +ARG PYTHON_VERSION=3.14 +ARG GIT_SYNC_VERSION=v4.7.1 +ARG S3FS_VERSION=2026.7.0 +ARG CYCLONEDX_BOM_VERSION=7.3.0 +ARG CDXGEN_VERSION=13.1.0 +ARG CDXGEN_NODEJS_VERSION=24.19.0 +# boil.toml +ARG CDXGEN_SPEC_VERSION=1.6 +ARG TINI_VERSION=0.19.0 +ARG UV_VERSION=0.13.4 +ARG OPA_AUTH_MANAGER=airflow-3 +ARG NODEJS_VERSION=22 + +# shared/statsd-exporter/boil-config.toml, version 0.31.0 +ARG SHARED_STATSD_EXPORTER_VERSION=0.31.0 +ARG GOLANG_VERSION=1.25.14 +ARG CYCLONEDX_GOMOD_VERSION=1.12.0 + +# stackable-base/boil-config.toml, vector/boil-config.toml and stackable-devel/boil-config.toml (the "vector-build" variant) +ARG CONFIG_UTILS_VERSION=0.5.1 +ARG CONTAINERDEBUG_VERSION=0.5.0 +ARG CERT_TOOLS_VERSION=0.1.1 +ARG VECTOR_VERSION=0.58.0 +ARG VECTOR_RUST_TOOLCHAIN_VERSION=1.95.0 +ARG PROTOC_VERSION=36.2 +ARG INOTIFY_TOOLS=3.22.1.0-1.el9 + +# The extras of airflow 3.3.2, see the links in airflow/boil-config.toml +ARG AIRFLOW_EXTRAS_CORE="async,graphviz,kerberos,memray,otel,sentry,standard,statsd" +ARG AIRFLOW_EXTRAS_META="aiobotocore,amazon-aws-auth,cloudpickle,github-enterprise,google-auth,graphviz,gunicorn,ldap,leveldb,pandas,polars,rabbitmq,s3fs,saml,uv" +ARG AIRFLOW_EXTRAS_PROVIDER_APACHE="apache-drill,apache-druid,apache-flink,apache-hdfs,apache-hive,apache-iceberg,apache-impala,apache-kafka,apache-kylin,apache-livy,apache-pig,apache-pinot,apache-tinkerpop" +ARG AIRFLOW_EXTRAS_EXTERNAL_SERVICES="airbyte,akeyless,alibaba,apprise,amazon,asana,atlassian-jira,microsoft-azure,clickhousedb,cloudant,cohere,databricks,datadog,dbt-cloud,dingding,discord,facebook,github,google,hashicorp,openai,opsgenie,pagerduty,pgvector,pinecone,qdrant,salesforce,sendgrid,segment,slack,snowflake,tableau,telegram,vertica,vespa,weaviate,yandex,ydb,zendesk" +ARG AIRFLOW_EXTRAS_LOCALLY_INSTALLED_SOFTWARE="arangodb,celery,cncf-kubernetes,docker,edge3,elasticsearch,exasol,fab,git,github,influxdb,jenkins,mongo,microsoft-mssql,neo4j,odbc,openfaas,oracle,postgres,presto,redis,samba,singularity,teradata,trino" +ARG AIRFLOW_EXTRAS_OTHER="common-ai,common-compat,common-io,common-messaging,common-sql,ftp,grpc,http,imap,jdbc,keycloak,microsoft-psrp,microsoft-winrm,openlineage,opensearch,papermill,sftp,smtp,sqlite,ssh,informatica" + +# For updated versions check https://github.com/kubernetes/git-sync/releases +FROM oci.stackable.tech/sdp/git-sync/git-sync:${GIT_SYNC_VERSION} AS gitsync-image + +FROM oci.stackable.tech/stackable/astral-sh/uv:${UV_VERSION} AS uv-image + +FROM oci.stackable.tech/sdp/library/golang:${GOLANG_VERSION} AS golang-image + +# ============================================================================== +# devel: replaces stackable-devel. Hummingbird builder variant + user + Rust + patchable +# (same as in zookeeper.Dockerfile) + +FROM ${DEVEL_BASE} AS devel + +ARG STACKABLE_USER_NAME +ARG STACKABLE_USER_UID +ARG STACKABLE_USER_GID + +# Build stage only, nothing from it is shipped as is. The final image runs as ${STACKABLE_USER_UID}. +# root is needed because the base image defaults to UID 65532. +# hadolint ignore=DL3002 +USER 0 +SHELL ["/bin/bash", "-euo", "pipefail", "-c"] +# The base image sets HOME=/home/build +ENV HOME=/root +# The Rust builder image ships its own Rust and (probably) sets these to its own paths. rustup would then +# install there, and the `. "$HOME/.cargo/env"` of all the stages below would not find it. +ENV CARGO_HOME=/root/.cargo +ENV RUSTUP_HOME=/root/.rustup + +COPY stackable-base/stackable/dnf.conf /etc/dnf/dnf.conf +COPY stackable-base/stackable/curlrc /root/.curlrc + +ARG RUST_DEFAULT_TOOLCHAIN_VERSION=1.99.0 +ENV RUST_DEFAULT_TOOLCHAIN_VERSION=${RUST_DEFAULT_TOOLCHAIN_VERSION} +ENV CARGO_CYCLONEDX_CRATE_VERSION=0.5.9 +ENV CARGO_AUDITABLE_CRATE_VERSION=0.7.7 + +# tar, xz and gzip are not part of the builder image +RUN < 0 {if (!seen[$0]++) print $0}' | tr '\n' ',' | sed 's/,$//') + +# Pin virtualenv due to a breaking change in 21.0.0 which is pulled in by hatch. +# See https://github.com/pypa/hatch/issues/2193 +uv tool install hatch --with "virtualenv<21" + +cd "$(/stackable/patchable --images-repo-root=src checkout airflow ${PRODUCT_VERSION})" + +tar -czf /stackable/airflow-${PRODUCT_VERSION}-src.tar.gz . + +cd airflow-core/src/airflow/ui + +# build front-end assets +npm install -g --ignore-scripts --before="$(date --utc --date='-7 days' --iso-8601=seconds)" pnpm@10.18.2 +pnpm install --frozen-lockfile +pnpm run build + +# SBOM for the frontend assets, see airflow/Dockerfile for the options +PATH="/opt/node-cdxgen/bin:$PATH" cdxgen \ + --type js \ + --required-only \ + --no-babel \ + --spec-version "${CDXGEN_SPEC_VERSION}" \ + --project-version "${PRODUCT_VERSION}" \ + --output "/stackable/app/airflow-ui-${PRODUCT_VERSION}.cdx.json" + +# build airflow wheel from airflow root folder +cd ../../.. +/root/.local/bin/hatch build -t wheel +uv pip install --python ${VIRTUAL_ENV}/bin/python apache-airflow[${AIRFLOW_EXTRAS}]==${PRODUCT_VERSION} --constraint /tmp/constraints.txt --build-constraints /tmp/build-constraints.txt +uv pip install --python ${VIRTUAL_ENV}/bin/python dist/apache_airflow_core-${PRODUCT_VERSION}-py3-none-any.whl[${AIRFLOW_EXTRAS}] --constraint /tmp/constraints.txt --build-constraints /tmp/build-constraints.txt + +uv pip install --python ${VIRTUAL_ENV}/bin/python s3fs==${S3FS_VERSION} +uv pip install --python ${VIRTUAL_ENV}/bin/python Flask_OIDC==2.2.0 Flask-OpenID==1.3.1 + +uv pip install --python ${VIRTUAL_ENV}/bin/python /tmp/opa_auth_manager-0.1.0-py3-none-any.whl + +# Create the SBOM for Airflow +# Important: All `pip install` commands must be above this line, otherwise the SBOM will be incomplete +uv venv /tmp/sbom-venv +uv pip install --python /tmp/sbom-venv/bin/python cyclonedx-bom==${CYCLONEDX_BOM_VERSION} +/tmp/sbom-venv/bin/cyclonedx-py environment --spec-version 1.5 --output-file /tmp/sbom.json "${VIRTUAL_ENV}" +rm -rf /tmp/sbom-venv + +# Post-process the SBOM, see airflow/Dockerfile for the reasons +jq 'def normalize_name: ascii_downcase | gsub("[-_.]+"; "-"); +.dependencies |= map(if .ref | test("^apache-airflow-providers-") then + .dependsOn |= map(select(. != "apache-airflow=='${PRODUCT_VERSION}'")) +else + . +end) +| .components |= map(if (.purl | not) and (.name != null) and (.version != null) then + .purl = "pkg:pypi/" + (.name | normalize_name) + "@" + .version +else + . +end +| if (.purl // "") | startswith("pkg:pypi/") then + .purl |= sub("^pkg:pypi/(?[^@]+)"; "pkg:pypi/" + (.name | normalize_name)) +else + . +end)' /tmp/sbom.json > /stackable/app/airflow-${PRODUCT_VERSION}.cdx.json + +cd /stackable +rm -rf ./src +EOF + +RUN < /dev/null || echo "WARNING: optional package $p is not in the Hummingbird repo, it is missing from the image" +done + +# See zookeeper.Dockerfile: the full package replaces the ca-certificates-bundle of the runtime base +dnf --installroot=/rootfs --use-host-config install --allowerasing ca-certificates + +# Unlike in the ZooKeeper image, the user has to have a passwd entry: Airflow resolves the user name +# (getpass.getuser() falls back to the passwd database) and entrypoint.sh only creates an entry if +# /etc/passwd is writable. `-R` edits the files below /rootfs, shadow-utils is not installed there. +groupadd -R /rootfs --gid ${STACKABLE_USER_GID} --system ${STACKABLE_USER_NAME} +useradd -R /rootfs \ + --no-log-init \ + --gid ${STACKABLE_USER_GID} \ + --uid ${STACKABLE_USER_UID} \ + --system \ + --no-create-home \ + --home-dir /stackable \ + ${STACKABLE_USER_NAME} +mkdir -p /rootfs/stackable + +dnf clean all +EOF + +# The vector sidecar waits for a shutdown file using `inotifywait`, see zookeeper.Dockerfile +RUN < /tmp/delta.lst +while IFS= read -r -d '' p; do + b="/base/$p" + if [ ! -e "$b" ] && [ ! -L "$b" ]; then + printf '%s\0' "$p" >> /tmp/delta.lst + elif [ -L "$p" ]; then + if [ ! -L "$b" ] || [ "$(readlink "$p")" != "$(readlink "$b")" ]; then printf '%s\0' "$p" >> /tmp/delta.lst; fi + elif [ -d "$p" ]; then + if [ ! -d "$b" ] || [ "$(meta "$p")" != "$(meta "$b")" ]; then printf '%s\0' "$p" >> /tmp/delta.lst; fi + elif [ -f "$p" ]; then + if [ ! -f "$b" ] || [ "$(meta "$p")" != "$(meta "$b")" ] || ! cmp -s "$p" "$b"; then printf '%s\0' "$p" >> /tmp/delta.lst; fi + else + printf '%s\0' "$p" >> /tmp/delta.lst + fi +done < <(find . -mindepth 1 -print0) + +echo "Entries added or changed compared to the runtime base: $(tr -cd '\0' < /tmp/delta.lst | wc -c)" +tar -C /rootfs --null --no-recursion -T /tmp/delta.lst -cf - | tar -C /additions --same-owner -xpf - + +# Files of the runtime base that are replaced (preflight may report them as modified files) +echo "Files of the runtime base that were changed:" +tr '\0' '\n' < /tmp/delta.lst | while IFS= read -r p; do + if [ -e "/base/$p" ] && [ ! -d "/base/$p" ]; then echo " $p"; fi +done +EOF + +# ============================================================================== +# FINAL AIRFLOW IMAGE + +# hadolint ignore=DL3006,DL3007 +FROM ${RUNTIME_BASE} + +ARG PRODUCT_VERSION +ARG RELEASE_VERSION +ARG STACKABLE_USER_UID + +COPY --from=rootfs /additions / + +LABEL name="Apache Airflow" \ + maintainer="info@stackable.tech" \ + vendor="Stackable GmbH" \ + version="${PRODUCT_VERSION}" \ + release="${RELEASE_VERSION}" \ + summary="The Stackable image for Apache Airflow." \ + description="This image is deployed by the Stackable Operator for Apache Airflow." + +LABEL org.opencontainers.image.authors="info@stackable.tech" +LABEL org.opencontainers.image.url="https://stackable.tech" +LABEL org.opencontainers.image.source="https://github.com/stackabletech/docker-images/" +LABEL org.opencontainers.image.vendor="Stackable GmbH" +LABEL org.opencontainers.image.licenses="Apache-2.0" + +# C.UTF-8 is built into glibc >= 2.35, see zookeeper.Dockerfile +ENV LANG=C.UTF-8 +ENV HOME=/stackable +ENV VIRTUAL_ENV=$HOME/app +ENV AIRFLOW_USER_HOME_DIR=$HOME +ENV PATH=$HOME/app/bin:$PATH:/bin:/stackable +ENV AIRFLOW_HOME=$HOME/airflow +# grpcio bundles its own roots.pem instead of using the system trust store. Point it to the system +# trust store, so it does not trust the compromised "emSign ECC Root CA - G3" root certificate +# (GHSA-6q48-6c7w-9gw2), which the system trust store no longer contains. +ENV GRPC_DEFAULT_SSL_ROOTS_FILE_PATH=/etc/pki/tls/certs/ca-bundle.crt + +USER ${STACKABLE_USER_UID} +WORKDIR /stackable + +ENTRYPOINT ["/usr/bin/tini", "--", "/run-airflow.sh"] +CMD []