Skip to content

Commit 8dd4135

Browse files
committed
fix: selectively copy items from hadoop-builder image to final image to not overwrite things from the base image
1 parent bd6b3a6 commit 8dd4135

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

hadoop/Dockerfile

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,10 @@ FROM stackable/image/java-base AS final
191191

192192
ARG PRODUCT
193193
ARG RELEASE
194+
ARG TARGETARCH
195+
ARG TARGETOS
194196
ARG HDFS_UTILS
197+
ARG ASYNC_PROFILER
195198
ARG STACKABLE_USER_UID
196199

197200
LABEL \
@@ -203,7 +206,14 @@ LABEL \
203206
summary="The Stackable image for Apache Hadoop." \
204207
description="This image is deployed by the Stackable Operator for Apache Hadoop / HDFS."
205208

206-
COPY --chown=${STACKABLE_USER_UID}:0 --from=hadoop-builder /stackable /stackable
209+
210+
COPY --chown=${STACKABLE_USER_UID}:0 --from=hadoop-builder /stackable/hadoop-${PRODUCT}-stackable${RELEASE} /stackable/hadoop-${PRODUCT}-stackable${RELEASE}
211+
COPY --chown=${STACKABLE_USER_UID}:0 --from=hadoop-builder /stackable/hadoop-${PRODUCT}-stackable${RELEASE}-src.tar.gz /stackable/
212+
# TODO ARCH & symlink
213+
COPY --chown=${STACKABLE_USER_UID}:0 --from=hadoop-builder /stackable/async-profiler-${ASYNC_PROFILER}-* /stackable/async-profiler-${ASYNC_PROFILER}
214+
COPY --chown=${STACKABLE_USER_UID}:0 --from=hadoop-builder /stackable/jmx /stackable/jmx
215+
COPY --chown=${STACKABLE_USER_UID}:0 --from=hadoop-builder /stackable/protobuf-*-src.tar.gz /stackable/
216+
207217
COPY --chown=${STACKABLE_USER_UID}:0 --from=hdfs-utils-builder /stackable/hdfs-utils-${HDFS_UTILS}.jar /stackable/hadoop-${PRODUCT}-stackable${RELEASE}/share/hadoop/common/lib/hdfs-utils-${HDFS_UTILS}.jar
208218
COPY --chown=${STACKABLE_USER_UID}:0 --from=hdfs-utils-builder /stackable/hdfs-utils-${HDFS_UTILS}-src.tar.gz /stackable
209219

@@ -230,7 +240,20 @@ rm -rf /var/cache/yum
230240
# Without this fuse_dfs does not work
231241
# It is so non-root users (as we are) can mount a FUSE device and let other users access it
232242
echo "user_allow_other" > /etc/fuse.conf
233-
EOF
243+
244+
ln -s "/stackable/hadoop-${PRODUCT}-stackable${RELEASE}" /stackable/hadoop
245+
chown --no-dereference "${STACKABLE_USER_UID}:0" /stackable/hadoop
246+
chmod g=u "/stackable/hadoop-${PRODUCT}-stackable${RELEASE}"
247+
chmod g=u /stackable/*-src.tar.gz
248+
249+
ARCH="${TARGETARCH/amd64/x64}"
250+
mv /stackable/async-profiler-${ASYNC_PROFILER}* "/stackable/async-profiler-${ASYNC_PROFILER-}-${TARGETOS}-${ARCH}"
251+
chmod g=u "/stackable/async-profiler-${ASYNC_PROFILER-}-${TARGETOS}-${ARCH}"
252+
ln -s "/stackable/async-profiler-${ASYNC_PROFILER}-${TARGETOS}-${ARCH}" /stackable/async-profiler
253+
chown --no-dereference "${STACKABLE_USER_UID}:0" /stackable/async-profiler
254+
255+
chmod g=u /stackable/jmx
256+
234257

235258
# ----------------------------------------
236259
# Checks
@@ -241,7 +264,6 @@ EOF
241264

242265
# Check that permissions and ownership in /stackable are set correctly
243266
# This will fail and stop the build if any mismatches are found.
244-
RUN <<EOF
245267
/bin/check-permissions-ownership.sh /stackable ${STACKABLE_USER_UID} 0
246268
EOF
247269

shared/checks/check-permissions-ownership.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ EXPECTED_UID=$2
2727
EXPECTED_GID=$3
2828

2929
error_flag=0
30+
ownership_errors=0
31+
permission_errors=0
3032

3133
# Check ownership
3234
while IFS= read -r -d '' entry; do
@@ -38,6 +40,7 @@ while IFS= read -r -d '' entry; do
3840
file=${remainder#* }
3941
echo "Ownership mismatch: $file (Expected: $EXPECTED_UID:$EXPECTED_GID, Found: $uid:$gid)"
4042
error_flag=1
43+
((ownership_errors++))
4144
fi
4245
done < <(find "$DIRECTORY" -printf "%U %G %p\0")
4346

@@ -48,13 +51,15 @@ while IFS= read -r -d '' entry; do
4851

4952
if [[ "$owner_perms" != "$group_perms" ]]; then
5053
file="${entry:11}"
51-
echo "Permission mismatch: $file (Owner: $owner_perms, Group: $group_perms)"
54+
echo "Permission mismatch: $file (Owner: $owner_perms, Group: $group_perms, Expected: owner=group)"
5255
error_flag=1
56+
((permission_errors++))
5357
fi
5458
done < <(find "$DIRECTORY" -printf "%M %p\0")
5559

5660
if [[ $error_flag -ne 0 ]]; then
5761
echo "Permission and Ownership checks failed for $DIRECTORY!"
62+
echo "Found $ownership_errors ownership mismatches and $permission_errors permission mismatches"
5863
exit 1
5964
fi
6065

0 commit comments

Comments
 (0)