@@ -9,8 +9,9 @@ ARG PRODUCT
9
9
ARG SCALA
10
10
ARG OPA_AUTHORIZER
11
11
ARG JMX_EXPORTER
12
+ ARG STACKABLE_USER_UID
12
13
13
- USER stackable
14
+ USER ${STACKABLE_USER_UID}
14
15
WORKDIR /stackable
15
16
16
17
RUN curl "https://repo.stackable.tech/repository/packages/kafka/kafka-${PRODUCT}-src.tgz" | tar -xzC . && \
@@ -27,35 +28,20 @@ RUN curl "https://repo.stackable.tech/repository/packages/kafka/kafka-${PRODUCT}
27
28
RUN curl https://repo.stackable.tech/repository/packages/kafka-opa-authorizer/opa-authorizer-${OPA_AUTHORIZER}-all.jar \
28
29
-o /stackable/kafka_${SCALA}-${PRODUCT}/libs/opa-authorizer-${OPA_AUTHORIZER}-all.jar
29
30
30
- COPY --chown=stackable:stackable kafka/stackable/jmx/ /stackable/jmx/
31
+ COPY --chown=${STACKABLE_USER_UID}:0 kafka/stackable/jmx/ /stackable/jmx/
31
32
RUN curl https://repo.stackable.tech/repository/packages/jmx-exporter/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar \
32
33
-o /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar && \
33
34
chmod +x /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar && \
34
35
ln -s /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar /stackable/jmx/jmx_prometheus_javaagent.jar
35
36
36
- # For earlier versions this script removes the .class file that contains the
37
- # vulnerable code.
38
- # TODO: This can be restricted to target only versions which do not honor the environment
39
- # varible that has been set above but this has not currently been implemented
40
- COPY shared/log4shell.sh /bin
41
- RUN /bin/log4shell.sh /stackable/kafka_${SCALA}-${PRODUCT}
42
-
43
- # Ensure no vulnerable files are left over
44
- # This will currently report vulnerable files being present, as it also alerts on
45
- # SocketNode.class, which we do not remove with our scripts.
46
- # Further investigation will be needed whether this should also be removed.
47
- COPY shared/log4shell_1.6.1-log4shell_Linux_x86_64 /bin/log4shell_scanner_x86_64
48
- COPY shared/log4shell_1.6.1-log4shell_Linux_aarch64 /bin/log4shell_scanner_aarch64
49
- COPY shared/log4shell_scanner /bin/log4shell_scanner
50
- RUN /bin/log4shell_scanner s /stackable/kafka_${SCALA}-${PRODUCT}
51
- # ===
52
37
53
38
FROM stackable/image/java-base AS final
54
39
55
40
ARG RELEASE
56
41
ARG PRODUCT
57
42
ARG SCALA
58
43
ARG KCAT
44
+ ARG STACKABLE_USER_UID
59
45
60
46
LABEL name="Apache Kafka" \
61
47
maintainer="info@stackable.tech" \
@@ -67,32 +53,38 @@ LABEL name="Apache Kafka" \
67
53
68
54
# This is needed for kubectl
69
55
COPY kafka/kubernetes.repo /etc/yum.repos.d/kubernetes.repo
70
- RUN microdnf update && \
71
- microdnf install \
72
- # needed by kcat for kerberos
73
- cyrus-sasl-gssapi \
74
- # Can be removed once listener-operator integration is used
75
- kubectl && \
76
- microdnf clean all && \
77
- rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE}\n " | sort > /stackable/package_manifest.txt && \
78
- rm -rf /var/cache/yum
79
-
80
- USER stackable
81
- WORKDIR /stackable
82
-
83
- COPY --chown=stackable:stackable kafka/licenses /licenses
56
+ COPY --chown=${STACKABLE_USER_UID}:0 kafka/licenses /licenses
57
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=kafka-builder /stackable/kafka_${SCALA}-${PRODUCT} /stackable/kafka_${SCALA}-${PRODUCT}
58
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=kafka-builder /stackable/jmx/ /stackable/jmx/
59
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=kcat /stackable/kcat-${KCAT}/kcat /stackable/bin/kcat-${KCAT}
60
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=kcat /licenses /licenses
84
61
85
- # We copy opa-authorizer.jar and jmx-exporter through the builder image to have an absolutely minimal final image
86
- # (e.g. we don't even need curl in it).
87
- COPY --chown=stackable:stackable --from=kafka-builder /stackable/kafka_${SCALA}-${PRODUCT} /stackable/kafka_${SCALA}-${PRODUCT}
88
- COPY --chown=stackable:stackable --from=kafka-builder /stackable/jmx/ /stackable/jmx/
89
- COPY --chown=stackable:stackable --from=kcat /stackable/kcat-${KCAT}/kcat /stackable/bin/kcat-${KCAT}
90
- COPY --chown=stackable:stackable --from=kcat /licenses /licenses
62
+ WORKDIR /stackable
91
63
92
- RUN ln -s /stackable/bin/kcat-${KCAT} /stackable/bin/kcat && \
93
- # kcat was located in /stackable/kcat - legacy
94
- ln -s /stackable/bin/kcat /stackable/kcat && \
95
- ln -s /stackable/kafka_${SCALA}-${PRODUCT} /stackable/kafka
64
+ RUN <<EOF
65
+ microdnf update
66
+ # cyrus-sasl-gssapi: needed by kcat for kerberos
67
+ # kubectl: Can be removed once listener-operator integration is used
68
+ microdnf install \
69
+ cyrus-sasl-gssapi \
70
+ kubectl
71
+
72
+ microdnf clean all
73
+ rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE}\n " | sort > /stackable/package_manifest.txt
74
+ rm -rf /var/cache/yum
75
+
76
+ ln -s /stackable/bin/kcat-${KCAT} /stackable/bin/kcat
77
+ # kcat was located in /stackable/kcat - legacy
78
+ ln -s /stackable/bin/kcat /stackable/kcat
79
+ ln -s /stackable/kafka_${SCALA}-${PRODUCT} /stackable/kafka
80
+
81
+ # All files and folders owned by root to support running as arbitrary users
82
+ # This is best practice as all container users will belong to the root group (0)
83
+ chown -R ${STACKABLE_USER_UID}:0 /stackable
84
+ chmod -R g=u /stackable
85
+ EOF
86
+
87
+ USER ${STACKABLE_USER_UID}
96
88
97
89
ENV PATH="${PATH}:/stackable/bin:/stackable/kafka/bin"
98
90
0 commit comments