@@ -30,11 +30,11 @@ microdnf clean all
30
30
rm -rf /var/cache/yum
31
31
EOF
32
32
33
- USER stackable
33
+ USER ${STACKABLE_USER_UID}
34
34
WORKDIR /stackable
35
35
36
- COPY --chown=stackable:stackable druid/stackable/patches/apply_patches.sh /stackable/apache-druid-${PRODUCT}-src/patches/apply_patches.sh
37
- COPY --chown=stackable:stackable druid/stackable/patches/${PRODUCT} /stackable/apache-druid-${PRODUCT}-src/patches/${PRODUCT}
36
+ COPY --chown=stackable:0 druid/stackable/patches/apply_patches.sh /stackable/apache-druid-${PRODUCT}-src/patches/apply_patches.sh
37
+ COPY --chown=stackable:0 druid/stackable/patches/${PRODUCT} /stackable/apache-druid-${PRODUCT}-src/patches/${PRODUCT}
38
38
39
39
# Cache mounts are owned by root by default
40
40
# We need to explicitly give the uid to use which is hardcoded to "1000" in stackable-base
@@ -44,9 +44,9 @@ COPY --chown=stackable:stackable druid/stackable/patches/${PRODUCT} /stackable/a
44
44
# with a "directory not empty" error on the first builder to finish, as other builders
45
45
# are still working in the cache directory.
46
46
47
- RUN --mount=type=cache,id=maven-${PRODUCT},uid=1000 ,target=/stackable/.m2/repository \
48
- --mount=type=cache,id=npm-${PRODUCT},uid=1000 ,target=/stackable/.npm \
49
- --mount=type=cache,id=cache-${PRODUCT},uid=1000 ,target=/stackable/.cache \
47
+ RUN --mount=type=cache,id=maven-${PRODUCT},uid=${STACKABLE_USER_UID} ,target=/stackable/.m2/repository \
48
+ --mount=type=cache,id=npm-${PRODUCT},uid=${STACKABLE_USER_UID} ,target=/stackable/.npm \
49
+ --mount=type=cache,id=cache-${PRODUCT},uid=${STACKABLE_USER_UID} ,target=/stackable/.cache \
50
50
<<EOF
51
51
curl --fail -L "https://repo.stackable.tech/repository/packages/druid/apache-druid-${PRODUCT}-src.tar.gz" | tar -xzC .
52
52
cd apache-druid-${PRODUCT}-src
@@ -78,6 +78,7 @@ FROM stackable/image/java-base AS final
78
78
79
79
ARG PRODUCT
80
80
ARG RELEASE
81
+ ARG STACKABLE_USER_UID
81
82
82
83
ARG NAME="Apache Druid"
83
84
ARG DESCRIPTION="This image is deployed by the Stackable Operator for Apache Druid"
@@ -101,27 +102,29 @@ LABEL io.openshift.tags="ubi9,stackable,druid,sdp"
101
102
LABEL io.k8s.description="${DESCRIPTION}"
102
103
LABEL io.k8s.display-name="${NAME}"
103
104
105
+
106
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=druid-builder /stackable/apache-druid-${PRODUCT} /stackable/apache-druid-${PRODUCT}
107
+ COPY --chown=${STACKABLE_USER_UID}:0 druid/stackable/bin /stackable/bin
108
+ COPY --chown=${STACKABLE_USER_UID}:0 druid/licenses /licenses
109
+
104
110
RUN <<EOF
105
111
microdnf update
106
112
microdnf clean all
107
113
rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE}\n " | sort > /stackable/package_manifest.txt
108
114
rm -rf /var/cache/yum
109
- EOF
110
-
111
- USER stackable
112
- WORKDIR /stackable
113
-
114
- COPY --chown=stackable:stackable --from=druid-builder /stackable/apache-druid-${PRODUCT} /stackable/apache-druid-${PRODUCT}
115
- COPY --chown=stackable:stackable druid/stackable/bin /stackable/bin
116
- COPY --chown=stackable:stackable druid/licenses /licenses
117
115
118
- RUN <<EOF
119
116
ln -s /stackable/apache-druid-${PRODUCT} /stackable/druid
120
117
121
118
# Force to overwrite the existing 'run-druid'
122
119
ln -sf /stackable/bin/run-druid /stackable/druid/bin/run-druid
120
+
121
+ # All files and folders owned by root to support running as arbitrary users
122
+ # This is best practice as all container users will belong to the root group (0)
123
+ chown -R ${STACKABLE_USER_UID}:0 /stackable
124
+ chmod -R g=u /stackable
123
125
EOF
124
126
127
+ USER ${STACKABLE_USER_UID}
125
128
ENV PATH="${PATH}" :/stackable/druid/bin
126
129
127
130
WORKDIR /stackable/druid
0 commit comments