@@ -65,7 +65,7 @@ ln -s "/stackable/hbase-${PRODUCT}" /stackable/hbase
6565# ## JMX Prometheus Exporter/Agent
6666# ##
6767if [[ -n "${JMX_EXPORTER}" ]] ; then
68- curl "https://repo.stackable.tech/repository/packages/jmx-exporter/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar" -o "/stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar"
68+ curl --fail "https://repo.stackable.tech/repository/packages/jmx-exporter/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar" -o "/stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar"
6969 chmod +x "/stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar"
7070 ln -s "/stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar" /stackable/jmx/jmx_prometheus_javaagent.jar
7171fi
7575# ##
7676cd /stackable
7777export ARCH="${TARGETARCH/amd64/x64}"
78- curl "https://repo.stackable.tech/repository/packages/async-profiler/async-profiler-${ASYNC_PROFILER}-${TARGETOS}-${ARCH}.tar.gz" | tar -xzC .
78+ curl --fail "https://repo.stackable.tech/repository/packages/async-profiler/async-profiler-${ASYNC_PROFILER}-${TARGETOS}-${ARCH}.tar.gz" | tar -xzC .
7979ln -s "/stackable/async-profiler-${ASYNC_PROFILER}-${TARGETOS}-${ARCH}" /stackable/async-profiler
8080
8181# We're removing these to make the intermediate layer smaller
@@ -87,8 +87,12 @@ if [ "${DELETE_CACHES}" = "true" ] ; then
8787 rm -rf /stackable/.npm/*
8888 rm -rf /stackable/.cache/*
8989fi
90+
91+ # set correct groups
92+ chmod --recursive g=u /stackable
9093EOF
9194
95+
9296FROM stackable/image/java-devel AS opa-authorizer-builder
9397
9498ARG OPA_AUTHORIZER
@@ -99,7 +103,6 @@ USER ${STACKABLE_USER_UID}
99103WORKDIR /stackable
100104
101105RUN --mount=type=cache,id=maven-opa,uid=${STACKABLE_USER_UID},target=/stackable/.m2/repository <<EOF
102-
103106# ##
104107# ## OPA Authorizer (only for 2.6 upwards)
105108# ##
@@ -117,12 +120,15 @@ else
117120 touch hbase-opa-authorizer/target/hbase-opa-authorizer.jar
118121fi
119122
120-
121123if [ "${DELETE_CACHES}" = "true" ] ; then
122124 rm -rf /stackable/.m2/repository/*
123125fi
126+
127+ # set correct groups
128+ chmod --recursive g=u /stackable
124129EOF
125130
131+
126132FROM stackable/image/java-devel AS hbase-operator-tools-builder
127133
128134ARG HBASE_OPERATOR_TOOLS
@@ -141,7 +147,7 @@ ARG DELETE_CACHES="true"
141147COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/bin/hbck2.env /stackable/bin/
142148COPY --chown=${STACKABLE_USER_UID}:0 hbase/hbase-operator-tools/stackable/patches /stackable/patches
143149COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/patches/apply_patches.sh /stackable/patches
144- COPY --chown=${STACKABLE_USER_UID}:0 --chmod=755 hbase/stackable/bin/hbase-entrypoint.sh /stackable/bin/
150+ COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/bin/hbase-entrypoint.sh /stackable/bin/
145151
146152USER ${STACKABLE_USER_UID}
147153WORKDIR /stackable
@@ -150,7 +156,7 @@ WORKDIR /stackable
150156# We need to explicitly give the uid to use
151157RUN --mount=type=cache,id=maven-hbase-operator-tools-${HBASE_OPERATOR_TOOLS},uid=${STACKABLE_USER_UID},target=/stackable/.m2/repository <<EOF
152158
153- curl "https://repo.stackable.tech/repository/packages/hbase-operator-tools/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}-src.tar.gz" | tar -xzC .
159+ curl --fail "https://repo.stackable.tech/repository/packages/hbase-operator-tools/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}-src.tar.gz" | tar -xzC .
154160mv hbase-operator-tools-${HBASE_OPERATOR_TOOLS} hbase-operator-tools-${HBASE_OPERATOR_TOOLS}-src
155161chmod +x patches/apply_patches.sh
156162patches/apply_patches.sh ${HBASE_OPERATOR_TOOLS} hbase-operator-tools-${HBASE_OPERATOR_TOOLS}-src
@@ -187,6 +193,9 @@ if [ "${DELETE_CACHES}" = "true" ] ; then
187193 rm -rf /stackable/.npm/*
188194 rm -rf /stackable/.cache/*
189195fi
196+
197+ # set correct groups
198+ chmod --recursive g=u /stackable
190199EOF
191200
192201
@@ -202,9 +211,9 @@ USER ${STACKABLE_USER_UID}
202211WORKDIR /stackable
203212
204213COPY --from=hadoop-builder --chown=${STACKABLE_USER_UID}:0 \
205- /stackable/hadoop/share/hadoop/tools/lib/aws-java-sdk-bundle-*.jar \
206- /stackable/hadoop/share/hadoop/tools/lib/hadoop-aws-${HADOOP}.jar \
207- /stackable/hadoop/share/hadoop/tools/lib/
214+ /stackable/hadoop/share/hadoop/tools/lib/aws-java-sdk-bundle-*.jar \
215+ /stackable/hadoop/share/hadoop/tools/lib/hadoop-aws-${HADOOP}.jar \
216+ /stackable/hadoop/share/hadoop/tools/lib/
208217
209218COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/bin/export-snapshot-to-s3.env /stackable/bin/
210219
@@ -218,8 +227,12 @@ export LIBS=$(find /stackable/hadoop/share/hadoop -name '*.jar' -printf '%p:' |
218227envsubst '${PRODUCT}:${LIBS}' < /stackable/bin/export-snapshot-to-s3.env > /stackable/bin/export-snapshot-to-s3
219228chmod +x /stackable/bin/export-snapshot-to-s3
220229rm /stackable/bin/export-snapshot-to-s3.env
230+
231+ # set correct groups
232+ chmod --recursive g=u /stackable
221233EOF
222234
235+
223236FROM stackable/image/java-devel AS phoenix-builder
224237
225238ARG PRODUCT
@@ -240,7 +253,7 @@ WORKDIR /stackable
240253
241254RUN --mount=type=cache,id=maven-phoenix-${PHOENIX},uid=${STACKABLE_USER_UID},target=/stackable/.m2/repository <<EOF
242255cd /stackable
243- curl "https://repo.stackable.tech/repository/packages/phoenix/phoenix-${PHOENIX}-src.tar.gz" | tar -xzC .
256+ curl --fail "https://repo.stackable.tech/repository/packages/phoenix/phoenix-${PHOENIX}-src.tar.gz" | tar -xzC .
244257mv phoenix-${PHOENIX} phoenix-${PHOENIX}-src
245258
246259chmod +x patches/apply_patches.sh
@@ -269,7 +282,6 @@ mv phoenix-${PHOENIX}-src/phoenix-assembly/target/bom.json /stackable/phoenix-${
269282rm -rf /stackable/phoenix-${PHOENIX}-src
270283ln -s "/stackable/phoenix-${HBASE_PROFILE}-${PHOENIX}-bin" /stackable/phoenix
271284
272-
273285# We're removing these to make the intermediate layer smaller
274286# This can be necessary even though it's only a builder image because the GitHub Action Runners only have very limited space available
275287# and we are sometimes running into errors because we're out of space.
@@ -279,6 +291,9 @@ if [ "${DELETE_CACHES}" = "true" ] ; then
279291 rm -rf /stackable/.npm/*
280292 rm -rf /stackable/.cache/*
281293fi
294+
295+ # set correct groups
296+ chmod --recursive g=u /stackable
282297EOF
283298
284299
@@ -333,8 +348,8 @@ COPY --chown=${STACKABLE_USER_UID}:0 --from=hadoop-s3-builder /stackable/hadoop/
333348# hadoop-azure-${HADOOP}.jar contains the AzureBlobFileSystem which is required
334349# by hadoop-common-${HADOOP}.jar if the scheme of a file system is "abfs://".
335350COPY --chown=${STACKABLE_USER_UID}:0 --from=hadoop-builder \
336- /stackable/hadoop/share/hadoop/tools/lib/hadoop-azure-${HADOOP}.jar \
337- /stackable/hbase-${PRODUCT}/lib/
351+ /stackable/hadoop/share/hadoop/tools/lib/hadoop-azure-${HADOOP}.jar \
352+ /stackable/hbase-${PRODUCT}/lib/
338353
339354COPY --chown=${STACKABLE_USER_UID}:0 --from=opa-authorizer-builder /stackable/hbase-opa-authorizer/target/hbase-opa-authorizer*.jar /stackable/hbase-${PRODUCT}/lib
340355
@@ -352,24 +367,46 @@ microdnf install \
352367
353368microdnf clean all
354369rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE}\n " | sort > /stackable/package_manifest.txt
370+ chown ${STACKABLE_USER_UID}:0 /stackable/package_manifest.txt
371+ chmod g=u /stackable/package_manifest.txt
355372rm -rf /var/cache/yum
356373
357374ln --symbolic --logical --verbose "/stackable/hbase-${PRODUCT}" /stackable/hbase
375+ chown --no-dereference ${STACKABLE_USER_UID}:0 /stackable/hbase
376+ chmod g=u /stackable/hbase
377+
358378ln --symbolic --logical --verbose "/stackable/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}" /stackable/hbase-operator-tools
359- ln --symbolic --logical --verbose "/stackable/phoenix/phoenix-server-hbase-${HBASE_PROFILE}.jar" "/stackable/hbase/lib/phoenix-server-hbase-${HBASE_PROFILE}.jar"
379+ chown --no-dereference ${STACKABLE_USER_UID}:0 /stackable/hbase-operator-tools
380+ chmod g=u /stackable/hbase-operator-tools
360381
361- # All files and folders owned by root group to support running as arbitrary users.
362- # This is best practice as all container users will belong to the root group (0).
363- chown -R ${STACKABLE_USER_UID}:0 /stackable
364- chmod -R g=u /stackable
382+ ln --symbolic --logical --verbose "/stackable/phoenix/phoenix-server-hbase-${HBASE_PROFILE}.jar" "/stackable/hbase/lib/phoenix-server-hbase-${HBASE_PROFILE}.jar"
383+ chown --no-dereference ${STACKABLE_USER_UID}:0 "/stackable/hbase/lib/phoenix-server-hbase-${HBASE_PROFILE}.jar"
384+ chmod g=u "/stackable/hbase/lib/phoenix-server-hbase-${HBASE_PROFILE}.jar"
385+
386+ # fix missing permissions
387+ chmod g=u /stackable/async-profiler
388+ chmod g=u /stackable/bin
389+ chmod g=u /stackable/jmx
390+ chmod g=u /stackable/phoenix
391+ # the whole directory tree /stackable/hadoop/share/hadoop/tools/lib/ must be adapted
392+ find /stackable/hadoop -type d -exec chmod g=u {} +
365393EOF
366394
367395# ----------------------------------------
368- # Attention: We are changing the group of all files in /stackable directly above
369- # If you do any file based actions (copying / creating etc.) below this comment you
370- # absolutely need to make sure that the correct permissions are applied!
371- # chown ${STACKABLE_USER_UID}:0
396+ # Checks
397+ # This section is to run final checks to ensure the created final images
398+ # adhere to several minimal requirements like:
399+ # - check file permissions and ownerships
400+ # ----------------------------------------
401+
402+ # Check that permissions and ownership in /stackable are set correctly
403+ # This will fail and stop the build if any mismatches are found.
404+ RUN <<EOF
405+ /bin/check-permissions-ownership.sh /stackable ${STACKABLE_USER_UID} 0
406+ EOF
407+
372408# ----------------------------------------
409+ # Attention: Do not perform any file based actions (copying/creating etc.) below this comment because the permissions would not be checked.
373410
374411USER ${STACKABLE_USER_UID}
375412ENV HBASE_CONF_DIR=/stackable/hbase/conf
0 commit comments