Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.25
uses: actions/setup-go@v2
uses: actions/setup-go@v6
with:
go-version: 1.25
id: go
- name: Set up Go for root
run: |
sudo ln -sf `which go` `sudo which go` || true
sudo go version
- uses: actions/checkout@v2
- uses: actions/checkout@v5
- name: get go version
run: go version
- name: Gofmt and License checks
run: make check
- name: Build script regression tests
run: python3 -B -m unittest discover -s scripts -p 'test_*.py'
- name: unit tests
run: make test
- name: Build Docker image (no push)
Expand Down
45 changes: 36 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
cancel-in-progress: false

env:
# GitHub Container Registry
Expand All @@ -26,14 +26,22 @@ jobs:
outputs:
tag: ${{ steps.vars.outputs.tag }}
built_at: ${{ steps.date.outputs.built_at }}
zk_version: ${{ steps.zk.outputs.zk_version }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Get tag name
id: vars
run: echo "tag=${GITHUB_REF:10}" >> $GITHUB_OUTPUT
- name: Set Release Date
id: date
run: |
echo "built_at=$(date --rfc-3339=date)" >> $GITHUB_OUTPUT
- name: Resolve Apache ZooKeeper version
id: zk
run: |
zk_version="$(./scripts/zookeeper-version.sh)"
echo "zk_version=$zk_version" >> "$GITHUB_OUTPUT"

operator-test:
runs-on: ubuntu-latest
Expand All @@ -43,7 +51,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Go 1.25
uses: actions/setup-go@v2
uses: actions/setup-go@v6
with:
go-version: 1.25
id: go
Expand All @@ -60,14 +68,22 @@ jobs:

build-zookeeper-apache:
runs-on: ubuntu-latest
needs: prepare
if: ${{ startsWith(github.ref, 'refs/tags/zk') }}
needs: [prepare, operator-test]
outputs:
digest: ${{ steps.build-zk-apache.outputs.digest }}
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Check emergency JDK download configuration
env:
JAVA_DOWNLOAD_BASE_URL: ${{ secrets.JAVA_DOWNLOAD_BASE_URL }}
JAVA_DOWNLOAD_APIKEY: ${{ secrets.JAVA_DOWNLOAD_APIKEY }}
run: |
: "${JAVA_DOWNLOAD_BASE_URL:?Set the approved JDK mirror repository secret}"
: "${JAVA_DOWNLOAD_APIKEY:?Set the JDK mirror credential repository secret}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand All @@ -91,13 +107,22 @@ jobs:
${{ env.DOCKERHUB_ZK_IMAGE }}
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}/zookeeper
tags: |
type=raw,value=3.8.4-apache-${{ needs.prepare.outputs.tag }}
type=raw,value=${{ needs.prepare.outputs.zk_version }}-apache-${{ needs.prepare.outputs.tag }}
labels: |
org.opencontainers.image.description=Apache Zookeeper 3.8.4 with OpenJDK 21
org.opencontainers.image.description=Apache Zookeeper ${{ needs.prepare.outputs.zk_version }}
# Rebuilt on every release with Debian security updates and the selected JDK.
- name: Build and push zookeeper Apache image
id: build-zk-apache
uses: docker/build-push-action@v6
with:
context: docker/zookeeper-image
secrets: |
JAVA_DOWNLOAD_APIKEY=${{ secrets.JAVA_DOWNLOAD_APIKEY }}
build-args: |
ZK_VERSION=${{ needs.prepare.outputs.zk_version }}
java_version=21
java_download_version=21.0.13.1
java_download_base_url=${{ secrets.JAVA_DOWNLOAD_BASE_URL }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta-zk-apache.outputs.tags }}
labels: ${{ steps.meta-zk-apache.outputs.labels }}
Expand All @@ -106,7 +131,7 @@ jobs:

build-zookeeper:
runs-on: ubuntu-latest
needs: [prepare, operator-test]
needs: [prepare, operator-test, build-zookeeper-apache]
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
permissions:
contents: read
Expand Down Expand Up @@ -137,14 +162,16 @@ jobs:
${{ env.DOCKERHUB_ZK_IMAGE }}
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}/zookeeper
tags: |
type=raw,value=3.8.4-${{ needs.prepare.outputs.tag }}
type=raw,value=${{ needs.prepare.outputs.zk_version }}-${{ needs.prepare.outputs.tag }}
labels: |
org.opencontainers.image.description=Apache Zookeeper image build with java-21
org.opencontainers.image.description=Apache Zookeeper image
- name: Build and push zookeeper image
uses: docker/build-push-action@v6
with:
context: docker
platforms: linux/amd64,linux/arm64
build-args: |
BASE_IMAGE=${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}/zookeeper@${{ needs.build-zookeeper-apache.outputs.digest }}
tags: ${{ steps.meta-zk.outputs.tags }}
labels: ${{ steps.meta-zk.outputs.labels }}
annotations: ${{ steps.meta-zk.outputs.annotations }}
Expand Down
106 changes: 106 additions & 0 deletions .github/workflows/zookeeper-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Validate authenticated emergency builds only on explicitly reviewed refs.
name: zookeeper-images

on:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
build:
name: build (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
# Native runners per architecture: no QEMU emulation needed.
- arch: amd64
runner: ubuntu-latest
- arch: arm64
runner: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false

- name: Resolve ZooKeeper version
id: zk
run: |
zk_version="$(./scripts/zookeeper-version.sh)"
echo "zk_version=${zk_version}" >> "$GITHUB_OUTPUT"

- uses: docker/setup-buildx-action@v4
- name: Check emergency JDK download configuration
env:
JAVA_DOWNLOAD_BASE_URL: ${{ secrets.JAVA_DOWNLOAD_BASE_URL }}
JAVA_DOWNLOAD_APIKEY: ${{ secrets.JAVA_DOWNLOAD_APIKEY }}
run: |
: "${JAVA_DOWNLOAD_BASE_URL:?Set the approved JDK mirror repository secret}"
: "${JAVA_DOWNLOAD_APIKEY:?Set the JDK mirror credential repository secret}"

- name: Build Apache ZooKeeper base image
uses: docker/build-push-action@v7
with:
context: docker/zookeeper-image
platforms: linux/${{ matrix.arch }}
secrets: |
JAVA_DOWNLOAD_APIKEY=${{ secrets.JAVA_DOWNLOAD_APIKEY }}
build-args: |
ZK_VERSION=${{ steps.zk.outputs.zk_version }}
java_version=21
java_download_version=21.0.13.1
java_download_base_url=${{ secrets.JAVA_DOWNLOAD_BASE_URL }}
outputs: type=oci,dest=${{ runner.temp }}/zookeeper-apache,tar=false
cache-from: type=gha,scope=zookeeper-apache-${{ matrix.arch }}
cache-to: ${{ github.event_name == 'push' && format('type=gha,mode=max,scope=zookeeper-apache-{0}', matrix.arch) || '' }}

# Same pairing as the release job: docker/Dockerfile is built FROM the
# base image just built (via BASE_IMAGE), here resolved from the local
# OCI layout through a named build context instead of a registry.
- name: Build ZooKeeper image on top of the freshly built base
uses: docker/build-push-action@v7
with:
context: docker
platforms: linux/${{ matrix.arch }}
build-args: |
BASE_IMAGE=zookeeper-apache:ci
build-contexts: |
zookeeper-apache:ci=oci-layout://${{ runner.temp }}/zookeeper-apache
tags: zookeeper:ci
load: true
cache-from: type=gha,scope=zookeeper-${{ matrix.arch }}
cache-to: ${{ github.event_name == 'push' && format('type=gha,mode=max,scope=zookeeper-{0}', matrix.arch) || '' }}

- name: Smoke test image
env:
ZK_VERSION: ${{ steps.zk.outputs.zk_version }}
run: |
docker run --rm --entrypoint bash -e ZK_VERSION zookeeper:ci -ec '
java -version
java -XshowSettings:properties -version 2>&1 | grep -Eq "^[[:space:]]*java.specification.version = ${JAVA_VERSION}$"
zkServer.sh version 2>/dev/null | tee /dev/stderr | grep -q "${ZK_VERSION}"
test -s /opt/libs/zu.jar
set +e
zu_output="$(java -jar /opt/libs/zu.jar 2>&1)"
zu_status=$?
set -e
printf "%s\n" "$zu_output"
test "$zu_status" -eq 1
grep -q "^Usage: zu " <<<"$zu_output"
for s in zookeeperStart.sh zookeeperReady.sh zookeeperLive.sh zookeeperTeardown.sh zookeeperMetrics.sh; do
test -x "/usr/local/bin/${s}"
done
command -v dig curl socat pgrep >/dev/null
'
- name: Verify patched JVM in the running ZooKeeper process
run: |
docker run --rm --entrypoint bash \
-v "${PWD}/scripts/test-zookeeper-image.sh:/test-zookeeper-image.sh:ro" \
zookeeper:ci /test-zookeeper-image.sh
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,18 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
- docker buildx rm zookeeper-builder
rm Dockerfile.cross

build-zk-image:
JAVA_DOWNLOAD_BASE_URL ?= https://download.oracle.com/java
JAVA_DOWNLOAD_VERSION ?= 21

docker build --build-arg VERSION=$(VERSION) --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) --build-arg GIT_SHA=$(GIT_SHA) -t $(APP_REPO):$(VERSION) ./docker
build-zk-image:
zk_version="$$(./scripts/zookeeper-version.sh)" && \
docker build --build-arg ZK_VERSION="$$zk_version" \
--build-arg java_download_base_url="$(JAVA_DOWNLOAD_BASE_URL)" \
--build-arg java_download_version="$(JAVA_DOWNLOAD_VERSION)" \
--secret id=JAVA_DOWNLOAD_APIKEY,env=JAVA_DOWNLOAD_APIKEY \
-t $(APP_REPO):$(VERSION)-apache ./docker/zookeeper-image
docker build --build-arg VERSION=$(VERSION) --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) --build-arg GIT_SHA=$(GIT_SHA) \
--build-arg BASE_IMAGE=$(APP_REPO):$(VERSION)-apache -t $(APP_REPO):$(VERSION) ./docker
docker tag $(APP_REPO):$(VERSION) $(APP_REPO):latest

build-zk-image-swarm:
Expand Down
27 changes: 20 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# syntax=docker/dockerfile:1
# check=skip=InvalidDefaultArgInFrom
#
# Copyright (c) 2018 Dell Inc., or its subsidiaries. All Rights Reserved.
#
Expand All @@ -8,26 +10,37 @@
# http://www.apache.org/licenses/LICENSE-2.0
#

FROM gradle:jdk21
# Base Apache ZooKeeper + OpenJDK image built from docker/zookeeper-image.
# It is not pinned here: the build-zookeeper release job builds that image
# first and passes its digest in, so both always come from the same commit
# and shared zookeeperVersion. For local builds use `make build-zk-image`.
ARG BASE_IMAGE

FROM ${BASE_IMAGE} AS runtime

# zu.jar is architecture-independent bytecode, so build it once on the native
# build platform instead of re-running Gradle under emulation for every target.
FROM --platform=$BUILDPLATFORM gradle:jdk25 AS zu-builder

RUN mkdir /zu
COPY zu /zu
WORKDIR /zu
RUN ./gradlew shadowJar --no-daemon
RUN --mount=type=bind,from=runtime,source=/usr/local,target=/runtime-java \
java_version="$(sed -n 's/^JAVA_VERSION="\([0-9][0-9]*\).*/\1/p' /runtime-java/openjdk-*/release)" && \
test -n "$java_version" && \
./gradlew -PjavaVersion="$java_version" shadowJar --no-daemon

# use forked base zookeeper 3.8.4 docker image
# that runs on openjdk-21
FROM adobe/zookeeper:3.8.4-apache-zk-20250914
FROM runtime
COPY bin /usr/local/bin
RUN chmod +x /usr/local/bin/*
COPY --from=0 /zu/build/libs/zu.jar /opt/libs/
COPY --from=zu-builder /zu/build/libs/zu.jar /opt/libs/

RUN apt-get -q update && \
apt-get install --no-install-recommends -y dnsutils curl procps socat

# OCI standard labels
LABEL org.opencontainers.image.title="Apache Zookeeper"
LABEL org.opencontainers.image.description="Apache Zookeeper image build with java-21"
LABEL org.opencontainers.image.description="Apache Zookeeper image build with java-${JAVA_VERSION}"
LABEL org.opencontainers.image.source="https://github.com/adobe/zookeeper-operator"
LABEL org.opencontainers.image.url="https://github.com/adobe/zookeeper-operator"
LABEL org.opencontainers.image.documentation="https://github.com/adobe/zookeeper-operator"
Expand Down
8 changes: 8 additions & 0 deletions docker/bin/zookeeperFunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@

set -ex

function zkRunZu() {
# JVM option variables intentionally contain multiple arguments.
# shellcheck disable=SC2086
java -Xmx"${ZK_CLIENT_HEAP:-256}m" ${CLIENT_JVMFLAGS:-} \
-Dlogback.configurationFile=/conf/logback-quiet.xml ${ZK_OPTIONS:-} \
-jar /opt/libs/zu.jar "$@"
}

function zkConfig() {
if [ -n "$1" ]; then
FQDN="$1"
Expand Down
Loading
Loading