@@ -14,21 +14,22 @@ ARG JMX_EXPORTER
14
14
ARG HADOOP
15
15
ARG TARGETARCH
16
16
ARG TARGETOS
17
+ ARG STACKABLE_USER_UID
17
18
18
19
# Setting this to anything other than "true" will keep the cache folders around (e.g. for Maven, NPM etc.)
19
20
# This can be used to speed up builds when disk space is of no concern.
20
21
ARG DELETE_CACHES="true"
21
22
22
23
COPY hbase/licenses /licenses
23
24
24
- USER stackable
25
+ USER ${STACKABLE_USER_UID}
25
26
WORKDIR /stackable
26
27
27
- COPY --chown=stackable:stackable hbase/stackable/patches /stackable/patches
28
- COPY --chown=stackable:stackable hbase/stackable/jmx/config${JMX_EXPORTER} /stackable/jmx
28
+ COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/patches /stackable/patches
29
+ COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/jmx/config${JMX_EXPORTER} /stackable/jmx
29
30
30
31
# Cache mounts are owned by root by default
31
- # We need to explicitly give the uid to use which is hardcoded to "1000" in stackable-base
32
+ # We need to explicitly give the uid to use
32
33
# And every cache needs its own id, we can't share them between stages because we might delete the caches
33
34
# at the end of a run while other stages are still using it.
34
35
# While this might work in theory it didn't in practice (FileNotFound exceptions etc.)
@@ -38,7 +39,7 @@ COPY --chown=stackable:stackable hbase/stackable/jmx/config${JMX_EXPORTER} /stac
38
39
# builder containers will share the same cache and the `rm -rf` commands will fail
39
40
# with a "directory not empty" error on the first builder to finish, as other builders
40
41
# are still working in the cache directory.
41
- RUN --mount=type=cache,id=maven-hbase-${PRODUCT},uid=1000 ,target=/stackable/.m2/repository <<EOF
42
+ RUN --mount=type=cache,id=maven-hbase-${PRODUCT},uid=${STACKABLE_USER_UID} ,target=/stackable/.m2/repository <<EOF
42
43
# ##
43
44
# ## HBase
44
45
# ##
@@ -91,11 +92,12 @@ FROM stackable/image/java-devel AS opa-authorizer-builder
91
92
92
93
ARG OPA_AUTHORIZER
93
94
ARG DELETE_CACHES
95
+ ARG STACKABLE_USER_UID
94
96
95
- USER stackable
97
+ USER ${STACKABLE_USER_UID}
96
98
WORKDIR /stackable
97
99
98
- RUN --mount=type=cache,id=maven-opa,uid=1000 ,target=/stackable/.m2/repository <<EOF
100
+ RUN --mount=type=cache,id=maven-opa,uid=${STACKABLE_USER_UID} ,target=/stackable/.m2/repository <<EOF
99
101
100
102
# ##
101
103
# ## OPA Authorizer (only for 2.6 upwards)
@@ -125,6 +127,7 @@ FROM stackable/image/java-devel AS hbase-operator-tools-builder
125
127
ARG HBASE_OPERATOR_TOOLS
126
128
ARG HBASE_THIRDPARTY
127
129
ARG PRODUCT
130
+ ARG STACKABLE_USER_UID
128
131
129
132
# Setting this to anything other than "true" will keep the cache folders around (e.g. for Maven, NPM etc.)
130
133
# This can be used to speed up builds when disk space is of no concern.
@@ -134,15 +137,15 @@ ARG DELETE_CACHES="true"
134
137
# The variable names are intentionally passed to envsubst in single-quotes,
135
138
# so that they are not expanded. Disabling ShellCheck rules in a Dockerfile
136
139
# does not work, so please ignore the according warning (SC2016).
137
- COPY --chown=stackable:stackable hbase/stackable/bin/hbck2.env /stackable/bin/
138
- COPY --chown=stackable:stackable hbase/stackable/patches /stackable/patches
140
+ COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/bin/hbck2.env /stackable/bin/
141
+ COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/patches /stackable/patches
139
142
140
- USER stackable
143
+ USER ${STACKABLE_USER_UID}
141
144
WORKDIR /stackable
142
145
143
146
# Cache mounts are owned by root by default
144
- # We need to explicitly give the uid to use which is hardcoded to "1000" in stackable-base
145
- RUN --mount=type=cache,id=maven-hbase-operator-tools,uid=1000 ,target=/stackable/.m2/repository <<EOF
147
+ # We need to explicitly give the uid to use
148
+ RUN --mount=type=cache,id=maven-hbase-operator-tools,uid=${STACKABLE_USER_UID} ,target=/stackable/.m2/repository <<EOF
146
149
147
150
curl --fail -L "https://repo.stackable.tech/repository/packages/hbase-operator-tools/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}-src.tar.gz" | tar -xzC .
148
151
mv hbase-operator-tools-${HBASE_OPERATOR_TOOLS} hbase-operator-tools-${HBASE_OPERATOR_TOOLS}-src
@@ -190,16 +193,17 @@ FROM stackable/image/java-devel AS hadoop-s3-builder
190
193
191
194
ARG PRODUCT
192
195
ARG HADOOP
196
+ ARG STACKABLE_USER_UID
193
197
194
- USER stackable
198
+ USER ${STACKABLE_USER_UID}
195
199
WORKDIR /stackable
196
200
197
- COPY --from=hadoop-builder --chown=stackable:stackable \
201
+ COPY --from=hadoop-builder --chown=${STACKABLE_USER_UID}:0 \
198
202
/stackable/hadoop/share/hadoop/tools/lib/aws-java-sdk-bundle-*.jar \
199
203
/stackable/hadoop/share/hadoop/tools/lib/hadoop-aws-${HADOOP}.jar \
200
204
/stackable/hadoop/share/hadoop/tools/lib/
201
205
202
- COPY --chown=stackable:stackable hbase/stackable/bin/export-snapshot-to-s3.env /stackable/bin/
206
+ COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/bin/export-snapshot-to-s3.env /stackable/bin/
203
207
204
208
RUN <<EOF
205
209
# Resolve paths in bin/export-snapshot-to-s3
@@ -220,16 +224,17 @@ ARG ASYNC_PROFILER
220
224
ARG PHOENIX
221
225
ARG HBASE_PROFILE
222
226
ARG HADOOP
227
+ ARG STACKABLE_USER_UID
223
228
224
229
# Setting this to anything other than "true" will keep the cache folders around (e.g. for Maven, NPM etc.)
225
230
# This can be used to speed up builds when disk space is of no concern.
226
231
ARG DELETE_CACHES="true"
227
232
228
- COPY --chown=stackable:stackable hbase/stackable/patches /stackable/patches
229
- USER stackable
233
+ COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/patches /stackable/patches
234
+ USER ${STACKABLE_USER_UID}
230
235
WORKDIR /stackable
231
236
232
- RUN --mount=type=cache,id=maven-phoenix,uid=1000 ,target=/stackable/.m2/repository <<EOF
237
+ RUN --mount=type=cache,id=maven-phoenix,uid=${STACKABLE_USER_UID} ,target=/stackable/.m2/repository <<EOF
233
238
cd /stackable
234
239
curl --fail -L "https://repo.stackable.tech/repository/packages/phoenix/phoenix-${PHOENIX}-src.tar.gz" | tar -xzC .
235
240
mv phoenix-${PHOENIX} phoenix-${PHOENIX}-src
@@ -305,27 +310,27 @@ LABEL io.openshift.tags="ubi9,stackable,hbase,sdp,nosql"
305
310
LABEL io.k8s.description="${DESCRIPTION}"
306
311
LABEL io.k8s.display-name="${NAME}"
307
312
308
- COPY --chown=stackable:stackable --from=hbase-builder /stackable/hbase-${PRODUCT} /stackable/hbase-${PRODUCT}/
309
- COPY --chown=stackable:stackable --from=hbase-builder /stackable/async-profiler /stackable/async-profiler/
310
- COPY --chown=stackable:stackable --from=hbase-builder /stackable/jmx /stackable/jmx/
313
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=hbase-builder /stackable/hbase-${PRODUCT} /stackable/hbase-${PRODUCT}/
314
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=hbase-builder /stackable/async-profiler /stackable/async-profiler/
315
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=hbase-builder /stackable/jmx /stackable/jmx/
311
316
312
- COPY --chown=stackable:stackable --from=hbase-operator-tools-builder /stackable/hbase-operator-tools-${HBASE_OPERATOR_TOOLS} /stackable/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}/
313
- COPY --chown=stackable:stackable --from=hbase-operator-tools-builder /stackable/bin/hbck2 /stackable/bin/hbck2
317
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=hbase-operator-tools-builder /stackable/hbase-operator-tools-${HBASE_OPERATOR_TOOLS} /stackable/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}/
318
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=hbase-operator-tools-builder /stackable/bin/hbck2 /stackable/bin/hbck2
314
319
315
- COPY --chown=stackable:stackable --from=phoenix-builder /stackable/phoenix /stackable/phoenix/
320
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=phoenix-builder /stackable/phoenix /stackable/phoenix/
316
321
317
- COPY --chown=stackable:stackable --from=hadoop-s3-builder /stackable/bin/export-snapshot-to-s3 /stackable/bin/export-snapshot-to-s3
318
- COPY --chown=stackable:stackable --from=hadoop-s3-builder /stackable/hadoop/share/hadoop/tools/lib/ /stackable/hadoop/share/hadoop/tools/lib/
322
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=hadoop-s3-builder /stackable/bin/export-snapshot-to-s3 /stackable/bin/export-snapshot-to-s3
323
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=hadoop-s3-builder /stackable/hadoop/share/hadoop/tools/lib/ /stackable/hadoop/share/hadoop/tools/lib/
319
324
320
325
# Copy the dependencies from Hadoop which are required for the Azure Data Lake
321
326
# Storage (ADLS) to /stackable/hbase-${PRODUCT}/lib which is on the classpath.
322
327
# hadoop-azure-${HADOOP}.jar contains the AzureBlobFileSystem which is required
323
328
# by hadoop-common-${HADOOP}.jar if the scheme of a file system is "abfs://".
324
- COPY --chown=stackable:stackable --from=hadoop-builder \
329
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=hadoop-builder \
325
330
/stackable/hadoop/share/hadoop/tools/lib/hadoop-azure-${HADOOP}.jar \
326
331
/stackable/hbase-${PRODUCT}/lib/
327
332
328
- COPY --chown=stackable:stackable --from=opa-authorizer-builder /stackable/hbase-opa-authorizer/target/hbase-opa-authorizer*.jar /stackable/hbase-${PRODUCT}/lib
333
+ COPY --chown=${STACKABLE_USER_UID}:0 --from=opa-authorizer-builder /stackable/hbase-opa-authorizer/target/hbase-opa-authorizer*.jar /stackable/hbase-${PRODUCT}/lib
329
334
330
335
RUN <<EOF
331
336
microdnf update
@@ -346,9 +351,14 @@ rm -rf /var/cache/yum
346
351
ln --symbolic --logical --verbose "/stackable/hbase-${PRODUCT}" /stackable/hbase
347
352
ln --symbolic --logical --verbose "/stackable/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}" /stackable/hbase-operator-tools
348
353
ln --symbolic --logical --verbose "/stackable/phoenix/phoenix-server-hbase-${HBASE_PROFILE}.jar" "/stackable/hbase/lib/phoenix-server-hbase-${HBASE_PROFILE}.jar"
354
+
355
+ # All files and folders owned by root to support running as arbitrary users
356
+ # This is best practice as all container users will belong to the root group (0)
357
+ chown -R ${STACKABLE_USER_UID}:0 /stackable
358
+ chmod -R g=u /stackable
349
359
EOF
350
360
351
- USER stackable
361
+ USER ${STACKABLE_USER_UID}
352
362
ENV HBASE_CONF_DIR=/stackable/hbase/conf
353
363
ENV HOME=/stackable
354
364
ENV PATH="${PATH}:/stackable/bin:/stackable/hbase/bin"
0 commit comments