@@ -5,6 +5,7 @@ FROM stackable/image/java-devel AS nifi-builder
5
5
6
6
ARG PRODUCT
7
7
ARG MAVEN_VERSION="3.9.8"
8
+ ARG STACKABLE_USER_UID
8
9
9
10
RUN microdnf update && \
10
11
microdnf clean all && \
@@ -22,10 +23,10 @@ RUN if [[ "${PRODUCT}" == 2.* ]] ; then \
22
23
ln -sf /tmp/apache-maven-${MAVEN_VERSION}/bin/mvn /usr/bin/mvn ; \
23
24
fi
24
25
25
- USER stackable
26
+ USER ${STACKABLE_USER_UID}
26
27
WORKDIR /stackable
27
28
28
- COPY --chown=stackable:stackable nifi/stackable/patches /stackable/patches
29
+ COPY --chown=${STACKABLE_USER_UID}:0 nifi/stackable/patches /stackable/patches
29
30
30
31
# NOTE: NiFi 1.21.0 source build does not work with the current arm64 git runners due to java heap issues:
31
32
#
@@ -82,28 +83,11 @@ RUN if [[ "${PRODUCT}" == "1.21.0" ]] ; then \
82
83
rm -rf /stackable/nifi-${PRODUCT}/docs ; \
83
84
fi
84
85
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
-
103
86
FROM stackable/image/java-base AS final
104
87
105
88
ARG PRODUCT
106
89
ARG RELEASE
90
+ ARG STACKABLE_USER_UID
107
91
108
92
LABEL name="Apache NiFi" \
109
93
maintainer="info@stackable.tech" \
@@ -113,28 +97,39 @@ LABEL name="Apache NiFi" \
113
97
summary="The Stackable image for Apache NiFi." \
114
98
description="This image is deployed by the Stackable Operator for Apache NiFi."
115
99
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
127
118
128
- USER stackable
119
+ # The nipyapi is required for the ReportingTaskJob
120
+ pip install --no-cache-dir nipyapi==0.19.1 && \
129
121
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
132
125
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
136
131
137
- RUN ln -s /stackable/nifi-${PRODUCT} /stackable/nifi
132
+ USER ${STACKABLE_USER_UID}
138
133
139
134
ENV HOME=/stackable
140
135
ENV NIFI_HOME=/stackable/nifi
0 commit comments