XrcDPNG66HtreJDo

Docker Images

Introduction

This directory contains:

Github Actions

Repository Setup

Make sure the DOCKERHUB_USER and DOCKERHUB_TOKEN secrets are added and made available to Github Actions in Github Repository settings. This is required for pushing the docker image.

Building image and running tests using github actions

Promoting a Release Candidate using github actions

Cron job for checking CVEs in supported docker images

Local Setup

Make sure you have python (>= 3.7.x) and java (>= 17) (java needed only for running tests) installed before running the tests and scripts.

Run pip install -r requirements.txt to get all the requirements for running the scripts.

Make sure you have docker installed with support for buildx enabled. (For pushing multi-architecture image to docker registry)

Building image and running tests locally

Creating a Release Candidate

python docker_release.py kafka/test:3.6.0 –image-type=jvm –kafka-url=https://archive.apache.org/dist/kafka/3.6.0/kafka_2.13-3.6.0.tgz

- Example(native):- To push an image named test under kafka-native dockerhub namespace with 3.8.0 tag and native image type ensuring kafka to be containerised should be https://archive.apache.org/dist/kafka/3.8.0/kafka_2.13-3.8.0.tgz (it is recommended to use scala 2.13 binary tarball), following command can be used. (Make sure you have push access to the docker repo)

kafka-native/test is an example repo. Please replace with the docker hub repo you have push access to.

python docker_release.py kafka-native/test:3.8.0 –image-type=native –kafka-url=https://archive.apache.org/dist/kafka/3.8.0/kafka_2.13-3.8.0.tgz


- Please note that we use docker buildx for preparing the multi-architecture image and pushing it to docker registry. It's possible to encounter build failures because of buildx. Please retry the command in case some buildx related error occurs.

Promoting a Release Candidate
-----------------------------

- It's not recommended to promote the docker image locally, as we have github actions doing it in a convenient way, but if needed following command can be used to promote a Release Candidate image.
- Example(jvm):- If you want to promote RC image apache/kafka:3.6.0-rc0 to apache/kafka:3.6.0, following command can be used

Ensure docker buildx is enabled in your system and you have access to apache/kafka

docker buildx imagetools create –tag apache/kafka:3.6.0 apache/kafka:3.6.0-rc0

- Example(native):- If you want to promote RC image apache/kafka-native:3.8.0-rc0 to apache/kafka-native:3.8.0, following command can be used

Ensure docker buildx is enabled in your system and you have access to apache/kafka-native

docker buildx imagetools create –tag apache/kafka-native:3.8.0 apache/kafka-native:3.8.0-rc0


Using the image in a docker container
-------------------------------------

Please check [this](/docker/examples/) for usage guide of the docker image.

Releasing the Docker Official Image
-----------------------------------

- This is the recommended way to release docker official image.
- Ensure these steps are being run for a particular version, only once the AK release process for that version has been completed.

- Provide the image type and kafka version to `Docker Prepare Docker Official Image Source` workflow. It will generate a artifact containing the static Dockerfile and assets for that specific version. Download the same from the workflow.

image_type: jvm kafka_version: 3.7.0


- Run the `docker/extract_docker_official_image_artifact.py` script, by providing it the path to the downloaded artifact. This will create a new directory under `docker/docker_official_images/kafka_version`. 

python extract_docker_official_image_artifact.py –path_to_downloaded_artifact=path/to/downloaded/artifact


- If there any versions for which Docker Official Images should not be supported, remove the corresponding directories under `docker/docker_official_images`.
- Commit these changes to AK trunk.

- Provide the image type and kafka version to `Docker Official Image Build Test` workflow. It will generate a test report and CVE report that can be shared with the community.

image_type: jvm kafka_version: 3.7.0


- Run the `docker/generate_kafka_pr_template.py` script from trunk, by providing it the image type. Update the existing entry, and raise a new PR in [Docker Hub's Docker Official Repo](https://github.com/docker-library/official-images/tree/master/library/kafka) by using this new PR template.

python generate_kafka_pr_template.py –image-type=jvm ```