Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .github/workflows/publish-kafka-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ jobs:
uses: docker/build-push-action@v7
with:
context: docker/kafka
secrets: |
JAVA_DOWNLOAD_APIKEY=${{ secrets.JAVA_DOWNLOAD_APIKEY }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
Expand All @@ -106,6 +108,8 @@ jobs:
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
BUILT_AT=${{ needs.prepare.outputs.built_at }}
COMMIT=${{ github.sha }}
java_download_base_url=${{ secrets.JAVA_DOWNLOAD_BASE_URL }}/21
java_version=21.0.13.1

build-and-push-jmx-agent-image:
runs-on: ubuntu-latest
Expand Down
32 changes: 24 additions & 8 deletions docker/kafka/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# syntax=docker/dockerfile:1

ARG scala_version=2.13
# Renovate is pinned to the 3.x line (see the apache/kafka packageRule in renovate.json).
# Kafka 4.x removes ZooKeeper support entirely (KRaft-only) and needs an operator-side
# migration; when this repo is ready for that, drop the allowedVersions constraint too.
# Also bump java_version to 25 (next LTS after 21) as part of that migration.
ARG KAFKA_VERSION=3.9.2 # renovate: datasource=github-tags depName=apache/kafka
ARG java_version=21
ARG java_download_version=${java_version}
ARG java_download_base_url=https://download.oracle.com/java

FROM alpine:latest@sha256:be2656061b536c1883c4034790e21d0a09c5aaaf51968b89368a3c0371ea2c9a AS kafka_dist

Expand Down Expand Up @@ -39,6 +43,8 @@ FROM debian:trixie-slim@sha256:f6b08b09a05725f9431502d3b5714f5c4576e82c1a84fa1de
ARG scala_version
ARG KAFKA_VERSION
ARG java_version
ARG java_download_version
ARG java_download_base_url
ARG VERSION
ARG BUILT_AT
ARG COMMIT
Expand All @@ -57,30 +63,40 @@ ENV PATH=$JAVA_HOME/bin:$PATH
ENV LANG=C.UTF-8
ENV JAVA_VERSION=${java_version}

RUN set -eux; \
RUN --mount=type=secret,id=JAVA_DOWNLOAD_APIKEY,env=JAVA_DOWNLOAD_APIKEY \
set -eux; \
\
case "$java_download_base_url" in \
https://download.oracle.com/*) java_download_base_url="${java_download_base_url}/${java_version}/latest" ;; \
*) java_download_base_url="${java_download_base_url}/${java_version}" ;; \
esac; \
\
arch="$(dpkg --print-architecture)"; \
case "$arch" in \
'amd64') \
downloadUrl="https://download.oracle.com/java/${java_version}/latest/jdk-${java_version}_linux-x64_bin.tar.gz"; \
downloadSha256="https://download.oracle.com/java/${java_version}/latest/jdk-${java_version}_linux-x64_bin.tar.gz.sha256"; \
downloadUrl="${java_download_base_url}/jdk-${java_download_version}_linux-x64_bin.tar.gz"; \
downloadSha256="${downloadUrl}.sha256"; \
;; \
'arm64') \
downloadUrl="https://download.oracle.com/java/${java_version}/latest/jdk-${java_version}_linux-aarch64_bin.tar.gz"; \
downloadSha256="https://download.oracle.com/java/${java_version}/latest/jdk-${java_version}_linux-aarch64_bin.tar.gz.sha256"; \
downloadUrl="${java_download_base_url}/jdk-${java_download_version}_linux-aarch64_bin.tar.gz"; \
downloadSha256="${downloadUrl}.sha256"; \
;; \
*) echo >&2 "error: unsupported architecture: '$arch'"; exit 1 ;; \
esac; \
\
savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
apt-get install -y --no-install-recommends \
wget \
curl \
; \
rm -rf /var/lib/apt/lists/*; \
\
wget --progress=dot:giga -O openjdk.tgz "$downloadUrl"; \
SHA256=$(wget -qO- $downloadSha256) ; \
set --; \
if [ -n "${JAVA_DOWNLOAD_APIKEY:+set}" ]; then \
set -- --variable '%JAVA_DOWNLOAD_APIKEY' --expand-header 'Authorization: Bearer {{JAVA_DOWNLOAD_APIKEY}}'; \
fi; \
curl --fail --location "$@" --output openjdk.tgz "$downloadUrl"; \
SHA256="$(curl --fail --silent --show-error --location "$@" "$downloadSha256")"; \
echo "$SHA256 *openjdk.tgz" | sha256sum --strict --check -; \
\
mkdir -p "$JAVA_HOME"; \
Expand Down
24 changes: 24 additions & 0 deletions docker/kafka/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,27 @@ Tags should be `kafka-<scala_version>-<kafka_version>` e.g `kafak-2.13-2.6.2`
This is based on [wurstmeister/kafka-docker](https://github.com/wurstmeister/kafka-docker) with the following additions:
1. Use `openjdk 21` in order to support container based resource monitoring
2. Use custom `log4j.properties` to get all kafka logs to stdout only

## Alternate JDK downloads

The Dockerfile defaults to Oracle's public download URL without authentication.
Override `java_download_base_url` and `java_download_version` to use another source.
The Dockerfile appends `java_version` and `latest` for Oracle, or only
`java_version` for alternate sources. Neither version belongs in the base URL.
`java_download_version` selects the archive filename, not a directory. Alternate
sources must provide the Oracle-style archive filenames and matching `.sha256`
files for each architecture.

For authenticated downloads, pass an optional API key as a BuildKit secret:

```bash
--secret id=JAVA_DOWNLOAD_APIKEY,env=JAVA_DOWNLOAD_APIKEY
```

The key is sent as an `Authorization: Bearer` header, is not stored in the image,
and is not forwarded to a different host on redirects.
Release builds also default to Oracle. To use an alternate source, add the
commented overrides to the release workflow's `build-args`, configure the GitHub
Actions secret `JAVA_DOWNLOAD_BASE_URL`, and select a matching `java_download_version`.
For authenticated downloads, also enable the commented `secrets` input and
configure `JAVA_DOWNLOAD_APIKEY`.
Loading