Skip to content

Migrate cp-kafka-rest to UBI9 micro base image#131

Draft
Krish Vora (KrishVora01) wants to merge 1 commit intomasterfrom
micro-migration-ubi9
Draft

Migrate cp-kafka-rest to UBI9 micro base image#131
Krish Vora (KrishVora01) wants to merge 1 commit intomasterfrom
micro-migration-ubi9

Conversation

@KrishVora01
Copy link
Contributor

Summary

  • Switch from single-stage cp-base-java to 3-stage multi-stage build using cp-base-java-micro
  • Stage 1: Extract package_dedupe tool from cp-base-java-micro
  • Stage 2: Install confluent-kafka-rest, confluent-telemetry, confluent-security RPMs into /microdir using dnf --installroot
  • Stage 3: Selectively COPY to cp-base-java-micro final image
  • Remove unused confluent-security subdirs (schema-registry, connect, ksql)
  • User migration: appuser hardcoded -> ${APP_UID}/${APP_GID} variables
  • Add UBI9_VERSION build arg to pom.xml for both spotify and fabric8 plugins

Test plan

  • CI build passes (Maven + Docker)
  • Image starts and REST endpoint is reachable on port 8082
  • Container runs as non-root user
  • CFK e2e-plaintext-kraft test passes with overridden cp-kafka-rest image
  • Kind local test script: ./run-kind-e2e-kafka-rest.sh

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings February 22, 2026 12:08
@KrishVora01 Krish Vora (KrishVora01) requested a review from a team as a code owner February 22, 2026 12:08
@KrishVora01 Krish Vora (KrishVora01) marked this pull request as draft February 22, 2026 12:09
Switch from single-stage cp-base-java to 3-stage multi-stage build
using cp-base-java-micro:
- Stage 1: Extract package_dedupe tool from cp-base-java-micro
- Stage 2: Install confluent-kafka-rest, confluent-telemetry,
  confluent-security RPMs into /microdir using dnf --installroot
- Stage 3: Selectively COPY to cp-base-java-micro final image

Key changes:
- Base image: cp-base-java -> cp-base-java-micro
- Package manager: microdnf -> dnf --installroot=/microdir
- User: appuser hardcoded -> ${APP_UID}/${APP_GID} variables
- COPY: --chown=appuser:appuser -> separate RUN chown
- Remove unused confluent-security subdirs (schema-registry, connect, ksql)
- Remove user database files to preserve base image's appuser
- Consolidate /usr/bin/ COPYs into single layer for RedHat cert (<40 layers)
- Add UBI9_VERSION build arg to pom.xml for both spotify and fabric8 plugins

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates the cp-kafka-rest image build to a UBI9-based multi-stage approach to reduce final image size by installing RPMs into an installroot and selectively copying artifacts into a cp-base-java-micro final image.

Changes:

  • Convert kafka-rest/Dockerfile.ubi9 from single-stage cp-base-java to a 3-stage build (tools → builder → final) using cp-base-java-micro.
  • Install confluent-kafka-rest, confluent-telemetry, and confluent-security into /microdir, remove unused security subdirs, and dedupe jars before copying into the final image.
  • Pass UBI9_VERSION as a Docker build arg via both spotify and fabric8 Maven Docker plugins.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
kafka-rest/pom.xml Adds UBI9_VERSION build-arg wiring for spotify + fabric8 Docker build plugins.
kafka-rest/Dockerfile.ubi9 Implements multi-stage UBI9 builder installroot flow and switches final image to cp-base-java-micro with selective copies and UID/GID-based ownership.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +18 to +25
ARG UBI9_VERSION

FROM ${DOCKER_UPSTREAM_REGISTRY}confluentinc/cp-base-java:${DOCKER_UPSTREAM_TAG}
# Stage 1: Get package_dedupe tool from base image
FROM ${DOCKER_UPSTREAM_REGISTRY}confluentinc/cp-base-java-micro:${DOCKER_UPSTREAM_TAG} AS tools

# Stage 2: Install packages using ubi9 with dnf to /microdir
FROM registry.access.redhat.com/ubi9:${UBI9_VERSION} AS builder

Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UBI9_VERSION is used in the FROM registry.access.redhat.com/ubi9:${UBI9_VERSION} instruction but the ARG UBI9_VERSION has no default. If the build arg isn’t provided (e.g., local docker build), the build will fail due to an invalid base image reference. Consider providing a safe default (or switching to a pinned default) and/or documenting/enforcing the required build arg in the build tooling.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants