@@ -27,30 +27,35 @@ WORKDIR /stackable
27
27
28
28
COPY --chown=${STACKABLE_USER_UID}:0 kafka/stackable/patches/apply_patches.sh /stackable/kafka-${PRODUCT}-src/patches/apply_patches.sh
29
29
COPY --chown=${STACKABLE_USER_UID}:0 kafka/stackable/patches/${PRODUCT} /stackable/kafka-${PRODUCT}-src/patches/${PRODUCT}
30
+ COPY --chown=${STACKABLE_USER_UID}:0 kafka/stackable/jmx/ /stackable/jmx/
30
31
31
- RUN curl "https://repo.stackable.tech/repository/packages/kafka/kafka-${PRODUCT}-src.tgz" | tar -xzC . && \
32
- cd kafka-${PRODUCT}-src && \
33
- ./patches/apply_patches.sh ${PRODUCT} && \
34
- # TODO: Try to install gradle via package manager (if possible) instead of fetching it from the internet
35
- # We don't specify "-x test" to skip the tests, as we might bump some Kafka internal dependencies in the future and
36
- # it's a good idea to run the tests in this case.
37
- ./gradlew clean releaseTarGz && \
38
- ./gradlew cyclonedxBom && \
39
- tar -xf core/build/distributions/kafka_${SCALA}-${PRODUCT}.tgz -C /stackable && \
40
- cp build/reports/bom.json /stackable/kafka_${SCALA}-${PRODUCT}.cdx.json && \
41
- rm -rf /stackable/kafka_${SCALA}-${PRODUCT}/site-docs/ && \
42
- rm -rf /stackable/kafka-${PRODUCT}-src
32
+ RUN <<EOF
33
+ curl "https://repo.stackable.tech/repository/packages/kafka/kafka-${PRODUCT}-src.tgz" | tar -xzC .
34
+ cd kafka-${PRODUCT}-src
35
+ ./patches/apply_patches.sh ${PRODUCT}
36
+ # TODO: Try to install gradle via package manager (if possible) instead of fetching it from the internet
37
+ # We don't specify "-x test" to skip the tests, as we might bump some Kafka internal dependencies in the future and
38
+ # it's a good idea to run the tests in this case.
39
+ ./gradlew clean releaseTarGz
40
+ ./gradlew cyclonedxBom
41
+ tar -xf core/build/distributions/kafka_${SCALA}-${PRODUCT}.tgz -C /stackable
42
+ cp build/reports/bom.json /stackable/kafka_${SCALA}-${PRODUCT}.cdx.json
43
+ rm -rf /stackable/kafka_${SCALA}-${PRODUCT}/site-docs/
44
+ rm -rf /stackable/kafka-${PRODUCT}-src
43
45
44
46
# TODO (@NickLarsenNZ): Compile from source: https://github.com/StyraInc/opa-kafka-plugin
45
- RUN curl https://repo.stackable.tech/repository/packages/kafka-opa-authorizer/opa-authorizer-${OPA_AUTHORIZER}-all.jar \
46
- -o /stackable/kafka_${SCALA}-${PRODUCT}/libs/opa-authorizer-${OPA_AUTHORIZER}-all.jar
47
+ curl https://repo.stackable.tech/repository/packages/kafka-opa-authorizer/opa-authorizer-${OPA_AUTHORIZER}-all.jar \
48
+ -o /stackable/kafka_${SCALA}-${PRODUCT}/libs/opa-authorizer-${OPA_AUTHORIZER}-all.jar
47
49
48
- COPY --chown=${STACKABLE_USER_UID}:0 kafka/stackable/jmx/ /stackable/jmx/
49
- RUN curl https://repo.stackable.tech/repository/packages/jmx-exporter/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar \
50
- -o /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar && \
51
- chmod +x /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar && \
52
- ln -s /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar /stackable/jmx/jmx_prometheus_javaagent.jar
50
+ # JMX exporter
51
+ curl https://repo.stackable.tech/repository/packages/jmx-exporter/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar \
52
+ -o /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar
53
+ chmod +x /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar
54
+ ln -s /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar /stackable/jmx/jmx_prometheus_javaagent.jar
53
55
56
+ # change groups
57
+ chmod -R g=u /stackable
58
+ EOF
54
59
55
60
FROM stackable/image/java-base AS final
56
61
@@ -60,21 +65,23 @@ ARG SCALA
60
65
ARG KCAT
61
66
ARG STACKABLE_USER_UID
62
67
63
- LABEL name="Apache Kafka" \
64
-
65
- vendor="Stackable GmbH" \
66
- version="${PRODUCT}" \
67
- release="${RELEASE}" \
68
- summary="The Stackable image for Apache Kafka." \
69
- description="This image is deployed by the Stackable Operator for Apache Kafka."
68
+ LABEL \
69
+ name="Apache Kafka" \
70
+
71
+ vendor="Stackable GmbH" \
72
+ version="${PRODUCT}" \
73
+ release="${RELEASE}" \
74
+ summary="The Stackable image for Apache Kafka." \
75
+ description="This image is deployed by the Stackable Operator for Apache Kafka."
70
76
71
- COPY --chown=${STACKABLE_USER_UID}:0 kafka/licenses /licenses
72
77
COPY --chown=${STACKABLE_USER_UID}:0 --from=kafka-builder /stackable/kafka_${SCALA}-${PRODUCT} /stackable/kafka_${SCALA}-${PRODUCT}
73
78
COPY --chown=${STACKABLE_USER_UID}:0 --from=kafka-builder /stackable/kafka_${SCALA}-${PRODUCT}.cdx.json /stackable/kafka_${SCALA}-${PRODUCT}/kafka_${SCALA}-${PRODUCT}.cdx.json
74
79
COPY --chown=${STACKABLE_USER_UID}:0 --from=kafka-builder /stackable/jmx/ /stackable/jmx/
75
80
COPY --chown=${STACKABLE_USER_UID}:0 --from=kcat /stackable/kcat-${KCAT}/kcat /stackable/bin/kcat-${KCAT}
76
81
COPY --chown=${STACKABLE_USER_UID}:0 --from=kcat /licenses /licenses
77
82
83
+ COPY --chown=${STACKABLE_USER_UID}:0 kafka/licenses /licenses
84
+
78
85
WORKDIR /stackable
79
86
80
87
RUN <<EOF
@@ -85,24 +92,39 @@ microdnf install \
85
92
86
93
microdnf clean all
87
94
rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE}\n " | sort > /stackable/package_manifest.txt
95
+ chown ${STACKABLE_USER_UID}:0 /stackable/package_manifest.txt
96
+ chmod g=u /stackable/package_manifest.txt
88
97
rm -rf /var/cache/yum
89
98
90
99
ln -s /stackable/bin/kcat-${KCAT} /stackable/bin/kcat
100
+ chown -h ${STACKABLE_USER_UID}:0 /stackable/bin/kcat
91
101
# kcat was located in /stackable/kcat - legacy
92
102
ln -s /stackable/bin/kcat /stackable/kcat
103
+ chown -h ${STACKABLE_USER_UID}:0 /stackable/kcat
93
104
ln -s /stackable/kafka_${SCALA}-${PRODUCT} /stackable/kafka
105
+ chown -h ${STACKABLE_USER_UID}:0 /stackable/kafka
94
106
95
- # All files and folders owned by root group to support running as arbitrary users.
96
- # This is best practice as all container users will belong to the root group (0).
97
- chown -R ${STACKABLE_USER_UID}:0 /stackable
98
- chmod -R g=u /stackable
107
+ # fix missing permissions
108
+ chmod g=u /stackable/bin
109
+ chmod g=u /stackable/jmx
110
+ chmod g=u /stackable/kafka_${SCALA}-${PRODUCT}
111
+ EOF
112
+
113
+ # ----------------------------------------
114
+ # Checks
115
+ # This section is to run final checks to ensure the created final images
116
+ # adhere to several minimal requirements like:
117
+ # - check file permissions and ownerships
118
+ # ----------------------------------------
119
+
120
+ # Check that permissions and ownership in /stackable are set correctly
121
+ # This will fail and stop the build if any mismatches are found.
122
+ RUN <<EOF
123
+ /bin/check-permissions-ownership.sh /stackable ${STACKABLE_USER_UID} 0
99
124
EOF
100
125
101
126
# ----------------------------------------
102
- # Attention: We are changing the group of all files in /stackable directly above
103
- # If you do any file based actions (copying / creating etc.) below this comment you
104
- # absolutely need to make sure that the correct permissions are applied!
105
- # chown ${STACKABLE_USER_UID}:0
127
+ # Attention: Do not perform any file based actions (copying/creating etc.) below this comment because the permissions would not be checked.
106
128
# ----------------------------------------
107
129
108
130
USER ${STACKABLE_USER_UID}
0 commit comments