Skip to content

Commit 45cbe54

Browse files
Make uid/gid configurable & change group of files - part 2 (#890)
* Make uid/gid configurable & change group of files This is a follow-up for #849 and includes: - The missing bits for Hive - Kafka * More tools now migrated but not tested yet: - Kafka Testing Tools - KCat - NiFi - Omid * - OPA - Spark (WIP) * Adds Spark and a changelog entry * Update CHANGELOG.md Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> * Update comment --------- Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com>
1 parent d3231ba commit 45cbe54

File tree

13 files changed

+207
-188
lines changed

13 files changed

+207
-188
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ All notable changes to this project will be documented in this file.
3131
- Enable [Docker build checks](https://docs.docker.com/build/checks/) ([#872]).
3232
- java: migrate to temurin jdk/jre ([#894]).
3333
- tools: bump kubectl to `1.31.1` and jq to `1.7.1` ([#896]).
34+
- Make username, user id, group id configurable, use numeric ids everywhere, change group of all files to 0 ([#849], [#890]).
3435

3536
### Removed
3637

@@ -66,6 +67,7 @@ All notable changes to this project will be documented in this file.
6667
[#822]: https://github.com/stackabletech/docker-images/pull/822
6768
[#846]: https://github.com/stackabletech/docker-images/pull/846
6869
[#848]: https://github.com/stackabletech/docker-images/pull/848
70+
[#849]: https://github.com/stackabletech/docker-images/pull/849
6971
[#851]: https://github.com/stackabletech/docker-images/pull/851
7072
[#852]: https://github.com/stackabletech/docker-images/pull/852
7173
[#853]: https://github.com/stackabletech/docker-images/pull/853
@@ -80,6 +82,7 @@ All notable changes to this project will be documented in this file.
8082
[#880]: https://github.com/stackabletech/docker-images/pull/880
8183
[#881]: https://github.com/stackabletech/docker-images/pull/881
8284
[#882]: https://github.com/stackabletech/docker-images/pull/882
85+
[#890]: https://github.com/stackabletech/docker-images/pull/890
8386
[#894]: https://github.com/stackabletech/docker-images/pull/894
8487
[#896]: https://github.com/stackabletech/docker-images/pull/896
8588

druid/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ ln -s /stackable/apache-druid-${PRODUCT} /stackable/druid
120120
# Force to overwrite the existing 'run-druid'
121121
ln -sf /stackable/bin/run-druid /stackable/druid/bin/run-druid
122122

123-
# All files and folders owned by root to support running as arbitrary users
124-
# This is best practice as all container users will belong to the root group (0)
123+
# All files and folders owned by root group to support running as arbitrary users.
124+
# This is best practice as all container users will belong to the root group (0).
125125
chown -R ${STACKABLE_USER_UID}:0 /stackable
126126
chmod -R g=u /stackable
127127
EOF

hadoop/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ find . -name 'hadoop-*tests.jar' -type f -delete
169169
# It is so non-root users (as we are) can mount a FUSE device and let other users access it
170170
echo "user_allow_other" > /etc/fuse.conf
171171

172-
# All files and folders owned by root to support running as arbitrary users
173-
# This is best practice as all container users will belong to the root group (0)
172+
# All files and folders owned by root group to support running as arbitrary users.
173+
# This is best practice as all container users will belong to the root group (0).
174174
chown -R ${STACKABLE_USER_UID}:0 /stackable
175175
chmod -R g=u /stackable
176176
EOF

hbase/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ ln --symbolic --logical --verbose "/stackable/hbase-${PRODUCT}" /stackable/hbase
354354
ln --symbolic --logical --verbose "/stackable/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}" /stackable/hbase-operator-tools
355355
ln --symbolic --logical --verbose "/stackable/phoenix/phoenix-server-hbase-${HBASE_PROFILE}.jar" "/stackable/hbase/lib/phoenix-server-hbase-${HBASE_PROFILE}.jar"
356356

357-
# All files and folders owned by root to support running as arbitrary users
358-
# This is best practice as all container users will belong to the root group (0)
357+
# All files and folders owned by root group to support running as arbitrary users.
358+
# This is best practice as all container users will belong to the root group (0).
359359
chown -R ${STACKABLE_USER_UID}:0 /stackable
360360
chmod -R g=u /stackable
361361
EOF

hello-world/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ rm -rf /var/cache/yum
2222

2323
curl "https://repo.stackable.tech/repository/packages/hello-world/hello-world-${PRODUCT}.jar" -o /stackable/hello-world.jar
2424

25-
# All files and folders owned by root to support running as arbitrary users
26-
# This is best practice as all container users will belong to the root group (0)
25+
# All files and folders owned by root group to support running as arbitrary users.
26+
# This is best practice as all container users will belong to the root group (0).
2727
chown -R ${STACKABLE_USER_UID}:0 /stackable
2828
chmod -R g=u /stackable
2929
EOF

hive/Dockerfile

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,40 +103,47 @@ LABEL io.openshift.tags="ubi9,stackable,hive,sdp"
103103
LABEL io.k8s.description="${DESCRIPTION}"
104104
LABEL io.k8s.display-name="${NAME}"
105105

106-
RUN <<EOF
107-
microdnf update
108-
microdnf clean all
109-
rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE}\n" | sort > /stackable/package_manifest.txt
110-
rm -rf /var/cache/yum
111-
EOF
112-
113-
USER ${STACKABLE_USER_UID}
114106
WORKDIR /stackable
115107

116108
COPY --chown=${STACKABLE_USER_UID}:0 --from=hive-builder /stackable/apache-hive-metastore-${PRODUCT}-bin /stackable/apache-hive-metastore-${PRODUCT}-bin
117-
RUN ln -s /stackable/apache-hive-metastore-${PRODUCT}-bin /stackable/hive-metastore
118109

119110
# It is useful to see which version of Hadoop is used at a glance
120111
# Therefore the use of the full name here
121112
# TODO: Do we really need all of Hadoop in here?
122113
COPY --chown=${STACKABLE_USER_UID}:0 --from=hadoop-builder /stackable/hadoop /stackable/hadoop-${HADOOP}
123-
RUN ln -s /stackable/hadoop-${HADOOP} /stackable/hadoop
114+
115+
RUN <<EOF
116+
microdnf update
117+
microdnf clean all
118+
rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE}\n" | sort > /stackable/package_manifest.txt
119+
rm -rf /var/cache/yum
120+
121+
ln -s /stackable/apache-hive-metastore-${PRODUCT}-bin /stackable/hive-metastore
122+
ln -s /stackable/hadoop-${HADOOP} /stackable/hadoop
124123

125124
# The next two sections for S3 and Azure use hardcoded version numbers on purpose instead of wildcards
126125
# This way the build will fail should one of the files not be available anymore in a later Hadoop version!
127126

128127
# Add S3 Support for Hive (support for s3a://)
129-
RUN cp /stackable/hadoop/share/hadoop/tools/lib/hadoop-aws-${HADOOP}.jar /stackable/hive-metastore/lib/
130-
RUN cp /stackable/hadoop/share/hadoop/tools/lib/aws-java-sdk-bundle-${AWS_JAVA_SDK_BUNDLE}.jar /stackable/hive-metastore/lib/
128+
cp /stackable/hadoop/share/hadoop/tools/lib/hadoop-aws-${HADOOP}.jar /stackable/hive-metastore/lib/
129+
cp /stackable/hadoop/share/hadoop/tools/lib/aws-java-sdk-bundle-${AWS_JAVA_SDK_BUNDLE}.jar /stackable/hive-metastore/lib/
131130

132131
# Add Azure ABFS support (support for abfs://)
133-
RUN cp /stackable/hadoop/share/hadoop/tools/lib/hadoop-azure-${HADOOP}.jar /stackable/hive-metastore/lib/
134-
RUN cp /stackable/hadoop/share/hadoop/tools/lib/azure-storage-${AZURE_STORAGE}.jar /stackable/hive-metastore/lib/
135-
RUN cp /stackable/hadoop/share/hadoop/tools/lib/azure-keyvault-core-${AZURE_KEYVAULT_CORE}.jar /stackable/hive-metastore/lib/
132+
cp /stackable/hadoop/share/hadoop/tools/lib/hadoop-azure-${HADOOP}.jar /stackable/hive-metastore/lib/
133+
cp /stackable/hadoop/share/hadoop/tools/lib/azure-storage-${AZURE_STORAGE}.jar /stackable/hive-metastore/lib/
134+
cp /stackable/hadoop/share/hadoop/tools/lib/azure-keyvault-core-${AZURE_KEYVAULT_CORE}.jar /stackable/hive-metastore/lib/
135+
136+
# All files and folders owned by root group to support running as arbitrary users.
137+
# This is best practice as all container users will belong to the root group (0).
138+
chown -R ${STACKABLE_USER_UID}:0 /stackable
139+
chmod -R g=u /stackable
140+
EOF
136141

137142
COPY --chown=${STACKABLE_USER_UID}:0 --from=hive-builder /stackable/jmx /stackable/jmx
138143
COPY hive/licenses /licenses
139144

145+
USER ${STACKABLE_USER_UID}
146+
140147
ENV HADOOP_HOME=/stackable/hadoop
141148
ENV HIVE_HOME=/stackable/hive-metastore
142149
ENV PATH="${PATH}":/stackable/hadoop/bin:/stackable/hive-metastore/bin

kafka-testing-tools/Dockerfile

Lines changed: 4 additions & 4 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,10 @@ 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

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

3939
ENTRYPOINT ["/stackable/kcat"]

kafka/Dockerfile

Lines changed: 34 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ ARG PRODUCT
99
ARG SCALA
1010
ARG OPA_AUTHORIZER
1111
ARG JMX_EXPORTER
12+
ARG STACKABLE_USER_UID
1213

13-
USER stackable
14+
USER ${STACKABLE_USER_UID}
1415
WORKDIR /stackable
1516

1617
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}
2728
RUN curl https://repo.stackable.tech/repository/packages/kafka-opa-authorizer/opa-authorizer-${OPA_AUTHORIZER}-all.jar \
2829
-o /stackable/kafka_${SCALA}-${PRODUCT}/libs/opa-authorizer-${OPA_AUTHORIZER}-all.jar
2930

30-
COPY --chown=stackable:stackable kafka/stackable/jmx/ /stackable/jmx/
31+
COPY --chown=${STACKABLE_USER_UID}:0 kafka/stackable/jmx/ /stackable/jmx/
3132
RUN curl https://repo.stackable.tech/repository/packages/jmx-exporter/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar \
3233
-o /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar && \
3334
chmod +x /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar && \
3435
ln -s /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar /stackable/jmx/jmx_prometheus_javaagent.jar
3536

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-
# ===
5237

5338
FROM stackable/image/java-base AS final
5439

5540
ARG RELEASE
5641
ARG PRODUCT
5742
ARG SCALA
5843
ARG KCAT
44+
ARG STACKABLE_USER_UID
5945

6046
LABEL name="Apache Kafka" \
6147
maintainer="info@stackable.tech" \
@@ -67,32 +53,38 @@ LABEL name="Apache Kafka" \
6753

6854
# This is needed for kubectl
6955
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
8461

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
9163

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 group 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}
9688

9789
ENV PATH="${PATH}:/stackable/bin:/stackable/kafka/bin"
9890

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 group 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

0 commit comments

Comments
 (0)