Skip to content

Commit e6606ef

Browse files
committed
More tools now migrated but not tested yet:
- Kafka Testing Tools - KCat - NiFi - Omid
1 parent e7e3283 commit e6606ef

File tree

4 files changed

+68
-67
lines changed

4 files changed

+68
-67
lines changed

kafka-testing-tools/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ FROM stackable/image/stackable-base AS final
88
ARG PRODUCT
99
ARG KCAT
1010
ARG RELEASE
11+
ARG STACKABLE_USER_UID
1112

1213
LABEL name="Kafka Testing Tools" \
1314
maintainer="info@stackable.tech" \
@@ -29,11 +30,11 @@ RUN microdnf install \
2930
&& rm -rf /var/cache/yum
3031

3132
# Store kcat version with binary name and add softlink
32-
COPY --chown=stackable:stackable --from=kcat /stackable/kcat-${KCAT}/kcat /stackable/kcat-${KCAT}
33+
COPY --chown=${STACKABLE_USER_UID}:0 --from=kcat /stackable/kcat-${KCAT}/kcat /stackable/kcat-${KCAT}
3334
RUN ln -s /stackable/kcat-${KCAT} /stackable/kcat
34-
COPY --chown=stackable:stackable --from=kcat /licenses /licenses
35+
COPY --chown=${STACKABLE_USER_UID}:0 --from=kcat /licenses /licenses
3536

3637

37-
COPY --chown=stackable:stackable kafka-testing-tools/licenses /licenses
38+
COPY --chown=${STACKABLE_USER_UID}:0 kafka-testing-tools/licenses /licenses
3839

3940
ENTRYPOINT ["/stackable/kcat"]

kcat/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
FROM stackable/image/java-base AS builder
88

99
ARG PRODUCT
10+
ARG STACKABLE_USER_UID
1011

1112
RUN microdnf update \
1213
&& microdnf install \
@@ -32,7 +33,7 @@ RUN curl -O https://repo.stackable.tech/repository/packages/kcat/kcat-${PRODUCT}
3233
&& cd kcat-${PRODUCT} \
3334
&& ./bootstrap.sh
3435

35-
COPY --chown=stackable:stackable kcat/licenses /licenses
36+
COPY --chown=${STACKABLE_USER_UID}:0 kcat/licenses /licenses
3637

3738
# SNIPPET 1
3839
# 145.2 gcc -I/stackable/kcat-1.7.0/tmp-bootstrap/usr/include -I/stackable/kcat-1.7.0/tmp-bootstrap/usr/include -g -O2 -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -L/stackable/kcat-1.7.0/tmp-bootstrap/usr/lib -Wl,-rpath-link=/stackable/kcat-1.7.0/tmp-bootstrap/usr/lib -L/stackable/kcat-1.7.0/tmp-bootstrap/usr/lib -Wl,-rpath-link=/stackable/kcat-1.7.0/tmp-bootstrap/usr/lib kcat.o format.o tools.o input.o json.o avro.o -o kcat -lm -ldl -lpthread -lrt -lpthread -lrt -L/stackable/kcat-1.7.0/tmp-bootstrap/usr/lib /stackable/kcat-1.7.0/tmp-bootstrap/usr/lib/libavro.a /stackable/kcat-1.7.0/tmp-bootstrap/usr/lib/libjansson.a -lcurl /stackable/kcat-1.7.0/tmp-bootstrap/usr/lib/libserdes.a -Wl,-Bstatic -lavro -Wl,-Bdynamic /stackable/kcat-1.7.0/tmp-bootstrap/usr/lib/libyajl_s.a -L/stackable/kcat-1.7.0/tmp-bootstrap/usr/lib //stackable/kcat-1.7.0/tmp-bootstrap/usr/lib/librdkafka.a -lm -ldl -lpthread -lrt -lz -lcrypto -lssl -lsasl2 -lm -ldl -lpthread -lrt -lpthread -lrt -L/stackable/kcat-1.7.0/tmp-bootstrap/usr/lib /stackable/kcat-1.7.0/tmp-bootstrap/usr/lib/libavro.a /stackable/kcat-1.7.0/tmp-bootstrap/usr/lib/libjansson.a -lcurl

nifi/Dockerfile

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ FROM stackable/image/java-devel AS nifi-builder
55

66
ARG PRODUCT
77
ARG MAVEN_VERSION="3.9.8"
8+
ARG STACKABLE_USER_UID
89

910
RUN microdnf update && \
1011
microdnf clean all && \
@@ -22,10 +23,10 @@ RUN if [[ "${PRODUCT}" == 2.* ]] ; then \
2223
ln -sf /tmp/apache-maven-${MAVEN_VERSION}/bin/mvn /usr/bin/mvn ; \
2324
fi
2425

25-
USER stackable
26+
USER ${STACKABLE_USER_UID}
2627
WORKDIR /stackable
2728

28-
COPY --chown=stackable:stackable nifi/stackable/patches /stackable/patches
29+
COPY --chown=${STACKABLE_USER_UID}:0 nifi/stackable/patches /stackable/patches
2930

3031
# NOTE: NiFi 1.21.0 source build does not work with the current arm64 git runners due to java heap issues:
3132
#
@@ -82,28 +83,11 @@ RUN if [[ "${PRODUCT}" == "1.21.0" ]] ; then \
8283
rm -rf /stackable/nifi-${PRODUCT}/docs ; \
8384
fi
8485

85-
# ===
86-
# For earlier versions this script removes the .class file that contains the
87-
# vulnerable code.
88-
# TODO: This can be restricted to target only versions which do not honor the environment
89-
# varible that has been set above but this has not currently been implemented
90-
COPY shared/log4shell.sh /bin
91-
RUN /bin/log4shell.sh /stackable/nifi-${PRODUCT}
92-
93-
# Ensure no vulnerable files are left over
94-
# This will currently report vulnerable files being present, as it also alerts on
95-
# SocketNode.class, which we do not remove with our scripts.
96-
# Further investigation will be needed whether this should also be removed.
97-
COPY shared/log4shell_1.6.1-log4shell_Linux_x86_64 /bin/log4shell_scanner_x86_64
98-
COPY shared/log4shell_1.6.1-log4shell_Linux_aarch64 /bin/log4shell_scanner_aarch64
99-
COPY shared/log4shell_scanner /bin/log4shell_scanner
100-
RUN /bin/log4shell_scanner s /stackable/nifi-${PRODUCT}
101-
# ===
102-
10386
FROM stackable/image/java-base AS final
10487

10588
ARG PRODUCT
10689
ARG RELEASE
90+
ARG STACKABLE_USER_UID
10791

10892
LABEL name="Apache NiFi" \
10993
maintainer="info@stackable.tech" \
@@ -113,28 +97,39 @@ LABEL name="Apache NiFi" \
11397
summary="The Stackable image for Apache NiFi." \
11498
description="This image is deployed by the Stackable Operator for Apache NiFi."
11599

116-
RUN microdnf update && \
117-
microdnf install \
118-
# Required to install nipyapi
119-
python-pip && \
120-
microdnf clean all && \
121-
rm -rf /var/cache/yum && \
122-
# The nipyapi is required for the ReportingTaskJob
123-
pip install --no-cache-dir nipyapi==0.19.1 && \
124-
# For backwards compatibility we create a softlink in /bin where the jar used to be as long as we are root
125-
# This can be removed once older versions / operators using this are no longer supported
126-
ln -s /stackable/stackable-bcrypt.jar /bin/stackable-bcrypt.jar
100+
COPY --chown=${STACKABLE_USER_UID}:0 --from=nifi-builder /stackable/nifi-${PRODUCT} /stackable/nifi-${PRODUCT}/
101+
COPY --chown=${STACKABLE_USER_UID}:0 --from=nifi-builder /stackable/stackable-bcrypt.jar /stackable/stackable-bcrypt.jar
102+
103+
COPY --chown=${STACKABLE_USER_UID}:0 nifi/stackable/bin /stackable/bin
104+
COPY --chown=${STACKABLE_USER_UID}:0 nifi/licenses /licenses
105+
COPY --chown=${STACKABLE_USER_UID}:0 nifi/python /stackable/python
106+
107+
RUN <<EOF
108+
ln -s /stackable/nifi-${PRODUCT} /stackable/nifi
109+
110+
microdnf update
111+
112+
# python-pip: Required to install nipyapi
113+
microdnf install \
114+
python-pip
115+
116+
microdnf clean all
117+
rm -rf /var/cache/yum
127118

128-
USER stackable
119+
# The nipyapi is required for the ReportingTaskJob
120+
pip install --no-cache-dir nipyapi==0.19.1 && \
129121

130-
COPY --chown=stackable:stackable --from=nifi-builder /stackable/nifi-${PRODUCT} /stackable/nifi-${PRODUCT}/
131-
COPY --chown=stackable:stackable --from=nifi-builder /stackable/stackable-bcrypt.jar /stackable/stackable-bcrypt.jar
122+
# For backwards compatibility we create a softlink in /bin where the jar used to be as long as we are root
123+
# This can be removed once older versions / operators using this are no longer supported
124+
ln -s /stackable/stackable-bcrypt.jar /bin/stackable-bcrypt.jar
132125

133-
COPY --chown=stackable:stackable nifi/stackable/bin /stackable/bin
134-
COPY --chown=stackable:stackable nifi/licenses /licenses
135-
COPY --chown=stackable:stackable nifi/python /stackable/python
126+
# All files and folders owned by root to support running as arbitrary users
127+
# This is best practice as all container users will belong to the root group (0)
128+
chown -R ${STACKABLE_USER_UID}:0 /stackable
129+
chmod -R g=u /stackable
130+
EOF
136131

137-
RUN ln -s /stackable/nifi-${PRODUCT} /stackable/nifi
132+
USER ${STACKABLE_USER_UID}
138133

139134
ENV HOME=/stackable
140135
ENV NIFI_HOME=/stackable/nifi

omid/Dockerfile

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ FROM stackable/image/java-devel AS builder
55

66
ARG PRODUCT
77
ARG DELETE_CACHES="true"
8+
ARG STACKABLE_USER_UID
89

910
RUN <<EOF
1011
microdnf update
@@ -17,13 +18,13 @@ microdnf clean all
1718
rm -rf /var/cache/yum
1819
EOF
1920

20-
USER stackable
21+
USER ${STACKABLE_USER_UID}
2122
WORKDIR /stackable
2223

23-
COPY --chown=stackable:stackable omid/stackable/patches/apply_patches.sh /stackable/phoenix-omid-${PRODUCT}/patches/apply_patches.sh
24-
COPY --chown=stackable:stackable omid/stackable/patches/${PRODUCT} /stackable/phoenix-omid-${PRODUCT}/patches/${PRODUCT}
24+
COPY --chown=${STACKABLE_USER_UID}:0 omid/stackable/patches/apply_patches.sh /stackable/phoenix-omid-${PRODUCT}/patches/apply_patches.sh
25+
COPY --chown=${STACKABLE_USER_UID}:0 omid/stackable/patches/${PRODUCT} /stackable/phoenix-omid-${PRODUCT}/patches/${PRODUCT}
2526

26-
RUN --mount=type=cache,id=maven-omid-${PRODUCT},uid=1000,target=/stackable/.m2/repository <<EOF
27+
RUN --mount=type=cache,id=maven-omid-${PRODUCT},uid=${STACKABLE_USER_UID},target=/stackable/.m2/repository <<EOF
2728
set -x
2829
curl https://repo.stackable.tech/repository/packages/omid/phoenix-omid-${PRODUCT}-src.tar.gz | tar -xzC .
2930
cd /stackable/phoenix-omid-${PRODUCT} || exit
@@ -62,6 +63,7 @@ FROM stackable/image/java-base
6263
ARG PRODUCT
6364
ARG RELEASE
6465
ARG JMX_EXPORTER
66+
ARG STACKABLE_USER_UID
6567

6668
LABEL name="Apache Phoenix Omid" \
6769
maintainer="info@stackable.tech" \
@@ -73,31 +75,33 @@ LABEL name="Apache Phoenix Omid" \
7375

7476
COPY omid/licenses /licenses
7577

76-
COPY --chown=stackable:stackable omid/stackable /stackable
77-
COPY --chown=stackable:stackable --from=builder /stackable/omid-tso-server-${PRODUCT} /stackable/omid-tso-server-${PRODUCT}
78-
COPY --chown=stackable:stackable --from=builder /stackable/omid-examples-${PRODUCT} /stackable/omid-examples-${PRODUCT}
78+
COPY --chown=${STACKABLE_USER_UID}:0 omid/stackable /stackable
79+
COPY --chown=${STACKABLE_USER_UID}:0 --from=builder /stackable/omid-tso-server-${PRODUCT} /stackable/omid-tso-server-${PRODUCT}
80+
COPY --chown=${STACKABLE_USER_UID}:0 --from=builder /stackable/omid-examples-${PRODUCT} /stackable/omid-examples-${PRODUCT}
7981

8082
RUN <<EOF
81-
microdnf update
82-
microdnf clean all
83-
rm -rf /var/cache/yum
84-
85-
ln -s /stackable/omid-tso-server-${PRODUCT} /stackable/omid-tso-server
86-
ln -s /stackable/omid-examples-${PRODUCT} /stackable/omid-examples
87-
curl https://repo.stackable.tech/repository/packages/jmx-exporter/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar \
88-
-o /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar
89-
chmod -x /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar
90-
# omid.sh places this file at the front of the classpath: remove it to allow the config map entry to take precedence
91-
rm /stackable/omid-tso-server/conf/hbase-site.xml
92-
93-
# To support arbitrary user ids on OpenShift, this folder must belong to the root group.
94-
mkdir /stackable/logs
95-
chown -R 1000:0 /stackable/logs
96-
chgrp -R 0 /stackable/logs
97-
chmod -R g=u /stackable/logs
83+
microdnf update
84+
microdnf clean all
85+
rm -rf /var/cache/yum
86+
87+
ln -s /stackable/omid-tso-server-${PRODUCT} /stackable/omid-tso-server
88+
ln -s /stackable/omid-examples-${PRODUCT} /stackable/omid-examples
89+
curl https://repo.stackable.tech/repository/packages/jmx-exporter/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar \
90+
-o /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar
91+
chmod -x /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar
92+
# omid.sh places this file at the front of the classpath: remove it to allow the config map entry to take precedence
93+
rm /stackable/omid-tso-server/conf/hbase-site.xml
94+
95+
# To support arbitrary user ids on OpenShift, this folder must belong to the root group.
96+
mkdir /stackable/logs
97+
98+
# All files and folders owned by root to support running as arbitrary users
99+
# This is best practice as all container users will belong to the root group (0)
100+
chown -R ${STACKABLE_USER_UID}:0 /stackable
101+
chmod -R g=u /stackable
98102
EOF
99103

100-
USER 1000
104+
USER ${STACKABLE_USER_UID}
101105
WORKDIR /stackable/omid-tso-server
102106

103107
ENV HOME=/stackable

0 commit comments

Comments
 (0)