Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] CPBR-1835: ksql image size POC #177

Draft
wants to merge 16 commits into
base: 7.8.x
Choose a base branch
from
Draft
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
8 changes: 4 additions & 4 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ blocks:
- ci-tools ci-update-version
- export OS_PACKAGES_URL=$(echo "$PACKAGES_URL" | sed "s/PACKAGE_TYPE/rpm/g")
- export PACKAGING_BUILD_ARGS="$PACKAGING_BUILD_ARGS -DCONFLUENT_PACKAGES_REPO=$OS_PACKAGES_URL"
- mvn -Dmaven.wagon.http.retryHandler.count=3 --batch-mode -P jenkins,docker clean package integration-test dependency:analyze validate -U -Ddocker.registry=$DOCKER_DEV_REGISTRY -Ddocker.upstream-registry=$DOCKER_UPSTREAM_REGISTRY
- mvn -Dmaven.wagon.http.retryHandler.count=3 --batch-mode -P jenkins,docker clean package -DskipTests dependency:analyze validate -U -Ddocker.registry=$DOCKER_DEV_REGISTRY -Ddocker.upstream-registry=$DOCKER_UPSTREAM_REGISTRY
-DBUILD_NUMBER=$BUILD_NUMBER -DGIT_COMMIT=$GIT_COMMIT -Ddocker.tag=$DOCKER_DEV_TAG$OS_TAG$AMD_ARCH -Ddocker.upstream-tag=$DOCKER_UPSTREAM_TAG$OS_TAG -Darch.type=$AMD_ARCH -Ddocker.os_type=ubi8
$PACKAGING_BUILD_ARGS -Ddependency.check.skip=true
$PACKAGING_BUILD_ARGS -Ddependency.check.skip=true -Dexec.skip=true
- . cache-maven store
- >-
for dev_image in $AMD_DOCKER_DEV_FULL_IMAGES;
Expand Down Expand Up @@ -133,9 +133,9 @@ blocks:
- export OS_PACKAGES_URL=$(echo "$PACKAGES_URL" | sed "s/PACKAGE_TYPE/rpm/g")
- export PACKAGING_BUILD_ARGS="$PACKAGING_BUILD_ARGS -DCONFLUENT_PACKAGES_REPO=$OS_PACKAGES_URL"
- ci-tools ci-update-version
- mvn -Dmaven.wagon.http.retryHandler.count=3 --batch-mode -P jenkins,docker clean package integration-test dependency:analyze validate -U -Ddocker.registry=$DOCKER_DEV_REGISTRY -Ddocker.upstream-registry=$DOCKER_UPSTREAM_REGISTRY
- mvn -Dmaven.wagon.http.retryHandler.count=3 --batch-mode -P jenkins,docker clean package -DskipTests dependency:analyze validate -U -Ddocker.registry=$DOCKER_DEV_REGISTRY -Ddocker.upstream-registry=$DOCKER_UPSTREAM_REGISTRY
-DBUILD_NUMBER=$BUILD_NUMBER -DGIT_COMMIT=$GIT_COMMIT -Ddocker.tag=$DOCKER_DEV_TAG$OS_TAG$ARM_ARCH -Ddocker.upstream-tag=$DOCKER_UPSTREAM_TAG$OS_TAG -Darch.type=$ARM_ARCH -Ddocker.os_type=ubi8
$PACKAGING_BUILD_ARGS -Ddependency.check.skip=true
$PACKAGING_BUILD_ARGS -Ddependency.check.skip=true -Dexec.skip=true
- . cache-maven store
- for image in $ARM_DOCKER_DEV_FULL_IMAGES; do echo "Pushing $image" && docker push $image; done
epilogue:
Expand Down
108 changes: 54 additions & 54 deletions cp-ksqldb-cli/Dockerfile.ubi8
Original file line number Diff line number Diff line change
Expand Up @@ -25,62 +25,62 @@ ARG CONFLUENT_VERSION
ARG CONFLUENT_PACKAGES_REPO
ARG CONFLUENT_PLATFORM_LABEL

USER root

COPY --chown=appuser:appuser target/${ARTIFACT_ID}-${PROJECT_VERSION}-package/share/java/${ARTIFACT_ID}/* /usr/share/java/${COMPONENT}/
COPY --chown=appuser:appuser target/${ARTIFACT_ID}-${PROJECT_VERSION}-package/share/doc/* /usr/share/doc/${ARTIFACT_ID}/
COPY --chown=appuser:appuser target/dependency/ksqldb-console-scripts-*/* /usr/bin/
COPY --chown=appuser:appuser target/dependency/ksqldb-etc-*/* /etc/ksqldb/

COPY --chown=appuser:appuser include/etc/confluent/docker /etc/confluent/docker

RUN mkdir -p /etc/${COMPONENT} /etc/${COMPONENT}/secrets /var/log/${COMPONENT} /usr/logs \
&& chown appuser:root -R /etc/${COMPONENT} /var/log/${COMPONENT} /usr/logs \
&& chmod ug+w -R /etc/${COMPONENT} /var/log/${COMPONENT} /usr/logs

RUN echo "===> Adding confluent repository...${CONFLUENT_PACKAGES_REPO}" \
&& rpm --import ${CONFLUENT_PACKAGES_REPO}/archive.key \
&& printf "[Confluent.dist] \n\
name=Confluent repository (dist) \n\
baseurl=${CONFLUENT_PACKAGES_REPO}/\$releasever \n\
gpgcheck=1 \n\
gpgkey=${CONFLUENT_PACKAGES_REPO}/archive.key \n\
enabled=1 \n\
\n\
[Confluent] \n\
name=Confluent repository \n\
baseurl=${CONFLUENT_PACKAGES_REPO}/ \n\
gpgcheck=1 \n\
gpgkey=${CONFLUENT_PACKAGES_REPO}/archive.key \n\
enabled=1 " > /etc/yum.repos.d/confluent.repo

RUN echo "===> Installing Confluent Hub client ${CONFLUENT_VERSION}..." \
&& yum install -y confluent-hub-client-${CONFLUENT_VERSION}

RUN echo "===> HACK to make cc-role-definitions available in docker image..." \
&& yum install -y yum-utils \
&& yum install -y cpio \
&& cd /tmp \
&& yumdownloader confluent-ksqldb --resolve \
&& CONFLUENT_KSQLDB_RPM=$(ls /tmp/confluent-ksqldb-*.rpm) \
&& echo "===> Extracting the rpm ${CONFLUENT_KSQLDB_RPM} to get the cc-role-definitions jar" \
&& mkdir /tmp/extracted-ksqldb \
&& cd /tmp/extracted-ksqldb \
&& rpm2cpio ${CONFLUENT_KSQLDB_RPM} | cpio -idmv \
&& cp /tmp/extracted-ksqldb/usr/share/java/ksqldb/cc-role-definitions*.jar /usr/share/java/${COMPONENT}/ \
&& echo "====> Removing the tmp files" \
&& rm -rf /tmp/extracted-ksqldb ${CONFLUENT_KSQLDB_RPM} \
&& chown appuser:appuser /usr/share/java/${COMPONENT}/cc-role-definitions*.jar \
&& echo "===> Cleaning up ..." \
&& yum clean all \
&& rm -rf /tmp/* /etc/yum.repos.d/confluent.repo \
&& mkdir -p /usr/share/confluent-hub-components \
&& chown appuser:appuser -R /usr/share/confluent-hub-components
#USER root
#
#COPY --chown=appuser:appuser target/${ARTIFACT_ID}-${PROJECT_VERSION}-package/share/java/${ARTIFACT_ID}/* /usr/share/java/${COMPONENT}/
#COPY --chown=appuser:appuser target/${ARTIFACT_ID}-${PROJECT_VERSION}-package/share/doc/* /usr/share/doc/${ARTIFACT_ID}/
#COPY --chown=appuser:appuser target/dependency/ksqldb-console-scripts-*/* /usr/bin/
#COPY --chown=appuser:appuser target/dependency/ksqldb-etc-*/* /etc/ksqldb/
#
#COPY --chown=appuser:appuser include/etc/confluent/docker /etc/confluent/docker
#
#RUN mkdir -p /etc/${COMPONENT} /etc/${COMPONENT}/secrets /var/log/${COMPONENT} /usr/logs \
# && chown appuser:root -R /etc/${COMPONENT} /var/log/${COMPONENT} /usr/logs \
# && chmod ug+w -R /etc/${COMPONENT} /var/log/${COMPONENT} /usr/logs
#
#RUN echo "===> Adding confluent repository...${CONFLUENT_PACKAGES_REPO}" \
# && rpm --import ${CONFLUENT_PACKAGES_REPO}/archive.key \
# && printf "[Confluent.dist] \n\
#name=Confluent repository (dist) \n\
#baseurl=${CONFLUENT_PACKAGES_REPO}/\$releasever \n\
#gpgcheck=1 \n\
#gpgkey=${CONFLUENT_PACKAGES_REPO}/archive.key \n\
#enabled=1 \n\
#\n\
#[Confluent] \n\
#name=Confluent repository \n\
#baseurl=${CONFLUENT_PACKAGES_REPO}/ \n\
#gpgcheck=1 \n\
#gpgkey=${CONFLUENT_PACKAGES_REPO}/archive.key \n\
#enabled=1 " > /etc/yum.repos.d/confluent.repo
#
#RUN echo "===> Installing Confluent Hub client ${CONFLUENT_VERSION}..." \
# && yum install -y confluent-hub-client-${CONFLUENT_VERSION}
#
#RUN echo "===> HACK to make cc-role-definitions available in docker image..." \
# && yum install -y yum-utils \
# && yum install -y cpio \
# && cd /tmp \
# && yumdownloader confluent-ksqldb --resolve \
# && CONFLUENT_KSQLDB_RPM=$(ls /tmp/confluent-ksqldb-*.rpm) \
# && echo "===> Extracting the rpm ${CONFLUENT_KSQLDB_RPM} to get the cc-role-definitions jar" \
# && mkdir /tmp/extracted-ksqldb \
# && cd /tmp/extracted-ksqldb \
# && rpm2cpio ${CONFLUENT_KSQLDB_RPM} | cpio -idmv \
# && cp /tmp/extracted-ksqldb/usr/share/java/ksqldb/cc-role-definitions*.jar /usr/share/java/${COMPONENT}/ \
# && echo "====> Removing the tmp files" \
# && rm -rf /tmp/extracted-ksqldb ${CONFLUENT_KSQLDB_RPM} \
# && chown appuser:appuser /usr/share/java/${COMPONENT}/cc-role-definitions*.jar \
# && echo "===> Cleaning up ..." \
# && yum clean all \
# && rm -rf /tmp/* /etc/yum.repos.d/confluent.repo \
# && mkdir -p /usr/share/confluent-hub-components \
# && chown appuser:appuser -R /usr/share/confluent-hub-components

USER appuser

RUN bash /etc/confluent/docker/configure
ENV KSQL_LOG4J_OPTS=-Dlog4j.configuration=file:/etc/${COMPONENT}/log4j.properties
#
#RUN bash /etc/confluent/docker/configure
#ENV KSQL_LOG4J_OPTS=-Dlog4j.configuration=file:/etc/${COMPONENT}/log4j.properties

ENTRYPOINT ["ksql"]
CMD ["http://localhost:8088"]
137 changes: 137 additions & 0 deletions cp-ksqldb-server/Dockerfile.temurin17.poc
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
ARG DOCKER_UPSTREAM_REGISTRY
ARG DOCKER_UPSTREAM_TAG
ARG GOLANG_VERSION=1.22.7-bullseye

FROM docker.io/golang:${GOLANG_VERSION} AS build_package_dedupe
WORKDIR /build
RUN useradd --no-log-init --create-home --shell /bin/bash appuser
COPY --chown=appuser:appuser package_dedupe/package_dedupe.go ./
RUN go build -ldflags="-w -s" ./package_dedupe.go

FROM ${DOCKER_UPSTREAM_REGISTRY}confluentinc/cp-base-lite:${DOCKER_UPSTREAM_TAG} as cp-base-lite

FROM ${DOCKER_UPSTREAM_REGISTRY}confluentinc/cp-base-new:${DOCKER_UPSTREAM_TAG} as cp-base-new

FROM registry.access.redhat.com/ubi8/ubi-minimal as ksqldb-server-ubi-minimal

ARG RPM_PACKAGES_DIR="/root/rpms"

ENV COMPONENT=ksqldb-server
ENV KSQL_CLASSPATH=/usr/share/java/${COMPONENT}/*

ARG PROJECT_VERSION
ARG ARTIFACT_ID
ARG GIT_COMMIT

ARG CONFLUENT_VERSION
ARG CONFLUENT_PACKAGES_REPO
ARG CONFLUENT_PLATFORM_LABEL

RUN printf "[temurin-jdk] \n\
name=temurin-jdk \n\
baseurl=https://packages.adoptium.net/artifactory/rpm/rhel/\$releasever/\$basearch \n\
enabled=1 \n\
gpgcheck=1 \n\
gpgkey=https://packages.adoptium.net/artifactory/api/gpg/key/public \n\
" > /etc/yum.repos.d/adoptium.repo

RUN microdnf --nodocs install yum \
&& yum --nodocs update -y \
&& yum --nodocs install -y --setopt=install_weak_deps=False \
wget yum-utils \
"temurin-17-jre"

# Download all the RPM packages
RUN printf "[Confluent] \n\
name=Confluent repository \n\
baseurl=${CONFLUENT_PACKAGES_REPO}/ \n\
gpgcheck=1 \n\
gpgkey=${CONFLUENT_PACKAGES_REPO}/archive.key \n\
enabled=1 " > /etc/yum.repos.d/confluent.repo \
&& yum makecache --refresh \
&& mkdir -p ${RPM_PACKAGES_DIR} \
&& cd ${RPM_PACKAGES_DIR} \
&& wget ${CONFLUENT_PACKAGES_REPO}/archive.key \
&& yumdownloader confluent-security confluent-hub-client confluent-telemetry --resolve

RUN rpm --import ${RPM_PACKAGES_DIR}/archive.key \
&& rpm --install ${RPM_PACKAGES_DIR}/confluent-common-*.noarch.rpm \
&& rpm --install ${RPM_PACKAGES_DIR}/confluent-security-*.noarch.rpm \
&& rpm --install ${RPM_PACKAGES_DIR}/confluent-hub-client-*.noarch.rpm \
&& rpm --install ${RPM_PACKAGES_DIR}/confluent-telemetry-*.noarch.rpm

COPY --from=cp-base-new /usr/share/java/cp-base-new /usr/share/java/cp-base-new
COPY --from=build_package_dedupe /build/package_dedupe /usr/bin

COPY --chown=1001:1001 target/${ARTIFACT_ID}-${PROJECT_VERSION}-package/share/java/${ARTIFACT_ID}/* /usr/share/java/${COMPONENT}/

RUN cd /usr/share/java \
&& rm -rf confluent-security/schema* confluent-security/connect confluent-security/kafka-rest \
&& package_dedupe $(pwd)

RUN yum remove wget -y \
&& yum clean all \
&& yum autoremove -y

RUN microdnf clean all

FROM registry.access.redhat.com/ubi8/ubi-micro as ksqldb-server-ubi-micro-intermediate

ARG RPM_PACKAGES_DIR="/root/rpms"

USER root

COPY --from=ksqldb-server-ubi-minimal /usr/lib/jvm /usr/lib/jvm
COPY --from=ksqldb-server-ubi-minimal /usr/lib/rpm /usr/lib/rpm
COPY --from=ksqldb-server-ubi-minimal /usr/bin/rpm* /usr/bin/
# libz.so is required by java
COPY --from=ksqldb-server-ubi-minimal /usr/lib64/libz.so.1* \
/usr/lib64/librpm.so.8* \
/usr/lib64/librpmio.so.8* \
/usr/lib64/libdb-5.*.so \
/usr/lib64/ libsqlite3.so.0* \
/usr/lib64/

# Optionally, you can copy other necessary files for rpm functionality
COPY --from=ksqldb-server-ubi-minimal /etc/rpm /etc/rpm

COPY --from=ksqldb-server-ubi-minimal ${RPM_PACKAGES_DIR}/* ${RPM_PACKAGES_DIR}/
COPY --from=cp-base-lite /usr/bin/ub /usr/bin/ub

RUN rpm --import ${RPM_PACKAGES_DIR}/archive.key \
&& rpm --install ${RPM_PACKAGES_DIR}/confluent-common-*.noarch.rpm \
&& rpm --install ${RPM_PACKAGES_DIR}/confluent-security-*.noarch.rpm \
&& rpm --install ${RPM_PACKAGES_DIR}/confluent-hub-client-*.noarch.rpm \
&& rpm --install ${RPM_PACKAGES_DIR}/confluent-telemetry-*.noarch.rpm

RUN rm -rf /usr/bin/rpm* /usr/lib/rpm /usr/lib64/librpm.so.8* \
/usr/lib64/librpmio.so.8* \
/usr/lib64/libdb-5.*.so \
/usr/lib64/libsqlite3.so.0* \
${RPM_PACKAGES_DIR}

RUN rm -rf /usr/share/java/* /usr/lib64/python3*

COPY --from=ksqldb-server-ubi-minimal /usr/share/java /usr/share/java

RUN ln -s /usr/lib/jvm/temurin-17-jre/bin/java /usr/bin/java


FROM registry.access.redhat.com/ubi8/ubi-micro as ksqldb-server-final

ENV COMPONENT=ksqldb-server
ENV KSQL_CLASSPATH=/usr/share/java/${COMPONENT}/*
ENV PATH="${PATH}:/usr/lib/jvm/java-11-zulu-openjdk:/usr/bin"

COPY --chown=1001:1001 target/dependency/ksqldb-console-scripts-*/* /usr/bin/
COPY --chown=1001:1001 target/dependency/ksqldb-etc-*/* /etc/ksqldb/
COPY --chown=1001:1001 target/dependency/ksqldb-etc-*/* /etc/confluent/docker/
COPY --chown=1001:1001 include/etc/confluent/docker/* /etc/confluent/docker/

RUN mkdir -p /etc/${COMPONENT} /etc/${COMPONENT}/secrets /usr/logs \
&& chown 1001:root -R /etc/${COMPONENT} /usr/logs \
&& chmod ug+w -R /etc/${COMPONENT} /usr/logs

COPY --from=ksqldb-server-ubi-micro-intermediate / /

USER 1001
Loading