diff --git a/Makefile b/Makefile index 08214405..e5ebf5f2 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,9 @@ render-docs: docker-build: docker build --force-rm --build-arg VERSION=${VERSION} -t "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}-${ARCH}" -f docker/Dockerfile . +docker-build-humm: + docker build --force-rm --build-arg VERSION=${VERSION} -t "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}-${ARCH}-humm" -f hummingbird-spike/Dockerfile . + ## Chart related targets compile-chart: version crds crd-annotation diff --git a/hummingbird-spike/Dockerfile b/hummingbird-spike/Dockerfile new file mode 100644 index 00000000..eaf156fe --- /dev/null +++ b/hummingbird-spike/Dockerfile @@ -0,0 +1,166 @@ +# syntax=docker/dockerfile:1.16.0@sha256:e2dd261f92e4b763d789984f6eab84be66ab4f5f08052316d8eb8f173593acf7 +# NOTE: The syntax directive needs to be the first line in a Dockerfile + +# SPIKE: Stackable Operator for Apache ZooKeeper on Red Hat Hummingbird, without any UBI stage. +# +# +# Differences to docker/Dockerfile: +# - The `ubi10-rust-builder` and `ubi10-minimal` stages are replaced by a Hummingbird builder and by +# a Hummingbird runtime image (`RUNTIME_BASE`, default `hi/core-runtime`). +# - The final image is built FROM the Hummingbird runtime image and only adds files on top of it. +# The runtime image has bash and coreutils but no package manager, so nothing is installed in it. +# - No user is created. The image runs as a numeric UID without a passwd entry (works in Kubernetes and OpenShift), +# which avoids editing /etc/passwd and /etc/group, files that belong to RPMs of the base image. +# - Not part of the image (they were in the UBI image and in the previous `FROM scratch` version of this spike): +# bash profile and aliases, `nano`, `iputils`, `libkadm5`, `krb5-libs` and the other tools from `ubi10-minimal`. +# - The builder is `hi/rust:latest-builder`, which ships the Rust toolchain and dnf. Nothing here installs or pins Rust, so the +# image's Rust version must match rust-toolchain.toml (the build prints both, see the `builder` stage). +# +# Build from the repository root (the build context must be the repo root and contain `.git`, +# the `built` crate reads the commit hash from it): +# +# docker build -f hummingbird-spike/Dockerfile --build-arg VERSION=0.0.0-dev -t zookeeper-operator-hum:spike . +# +# To try another runtime base (it must be a glibc based, certified Hummingbird image): +# +# docker build -f hummingbird-spike/Dockerfile --build-arg VERSION=0.0.0-dev \ +# --build-arg RUNTIME_BASE=registry.access.redhat.com/hi/core-runtime: -t zookeeper-operator-hum:spike . +# +# Useful intermediate target: builder +# +# docker build -f hummingbird-spike/Dockerfile --target builder -t zk-op-hum-builder . + +# https://docs.docker.com/build/checks/#fail-build-on-check-violations +# check=error=true + +# TODO: pin the bases by digest, like the other Dockerfiles in this repo do +# The `-builder` variant of hi/rust. The plain `hi/rust:latest` has no dnf. The builder variants add +# bash, dnf5 and shadow-utils (default_rpm_packages.builder in the Hummingbird containers repo, +# images/variables.yml), on top of cargo, rust, git-core, make, glibc-devel and openssl-devel (images/rust/properties.yml). +# The image also has gcc (gcc-16.2.1 when checked), which rustc needs as linker and the build scripts of +# `ring` and the vendored libgit2 (via `git2` in the `built` crate) need as C compiler. +ARG BUILDER_BASE=registry.access.redhat.com/hi/rust:latest-builder +# The base of the final image. The final image must share its layers, so this has to be an image that +# Red Hat certified. It must be glibc based, the operator is dynamically linked. `hi/static` has no glibc. +# The binary is built against the glibc of BUILDER_BASE. Keep both bases on the same Hummingbird release. +ARG RUNTIME_BASE=registry.access.redhat.com/hi/core-runtime:latest + +# ============================================================================== +# builder: Hummingbird Rust image, builds the operator binary + +# We want to automatically use the latest. +# hadolint ignore=DL3007 +FROM ${BUILDER_BASE} AS builder + +ARG CARGO_AUDITABLE_CRATE_VERSION=0.7.7 + +# Build stage only, nothing from it is shipped as is. The final image runs as an unprivileged user. +# Root is needed for dnf and to create /src and /app. hi/rust already +# runs as root (`user: root` in its properties.yml), this makes it explicit. +# hadolint ignore=DL3002 +USER 0 +SHELL ["/bin/bash", "-euo", "pipefail", "-c"] + +WORKDIR /src +COPY . /src + +# The image's Rust must match what the repo pins, nothing else enforces that here +RUN < /README.md <= 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 +# PATH is left to the base image, the entrypoint below uses an absolute path. +ENV HOME=/stackable + +USER ${STACKABLE_USER_UID} + +ENTRYPOINT ["/usr/local/bin/stackable-zookeeper-operator"] +CMD ["run"] diff --git a/tests/test-definition.yaml b/tests/test-definition.yaml index bcd5a455..5487b7b8 100644 --- a/tests/test-definition.yaml +++ b/tests/test-definition.yaml @@ -2,13 +2,13 @@ dimensions: - name: zookeeper values: - - 3.9.5 - - 3.9.6 + # - 3.9.5 + - 3.9.6,localhost/zookeeper-hum:spike # To use a custom image, add a comma and the full name after the product version # - x.x.x,oci.stackable.tech/sdp/zookeeper:x.x.x-stackable0.0.0-dev - name: zookeeper-latest values: - - 3.9.6 + - 3.9.6,localhost/zookeeper-hum:spike # To use a custom image, add a comma and the full name after the product version # - x.x.x,oci.stackable.tech/sdp/zookeeper:x.x.x-stackable0.0.0-dev - name: use-server-tls