Skip to content

Commit 59cb54d

Browse files
Fix: hbase reduce image size (#1028)
* reduce size * remove comment * adapted changelog * consolidate fixes * fixes * consolidation * fix changelog * Update hbase/Dockerfile Co-authored-by: Siegfried Weber <[email protected]> --------- Co-authored-by: Siegfried Weber <[email protected]>
1 parent 14a6c24 commit 59cb54d

File tree

2 files changed

+63
-22
lines changed

2 files changed

+63
-22
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file.
88

99
- hadoop: check for correct permissions and ownerships in /stackable folder via
1010
`check-permissions-ownership.sh` provided in stackable-base image ([#1029]).
11+
- hbase: check for correct permissions and ownerships in /stackable folder via
12+
`check-permissions-ownership.sh` provided in stackable-base image ([#1028]).
1113
- spark-connect-client: A new image for Spark connect tests and demos ([#1034])
1214
- nifi: check for correct permissions and ownerships in /stackable folder via
1315
`check-permissions-ownership.sh` provided in stackable-base image ([#1027]).
@@ -22,12 +24,14 @@ All notable changes to this project will be documented in this file.
2224
### Fixed
2325

2426
- hadoop: reduce docker image size by removing the recursive chown/chmods in the final image ([#1029]).
27+
- hbase: reduce docker image size by removing the recursive chown/chmods in the final image ([#1028]).
2528
- nifi: reduce docker image size by removing the recursive chown/chmods in the final image ([#1027]).
2629
- opa: reduce docker image size by removing the recursive chown/chmods in the final image ([#1038]).
2730
- spark-k8s: reduce docker image size by removing the recursive chown/chmods in the final image ([#1042]).
2831
- Add `--locked` flag to `cargo install` commands for reproducible builds ([#1044]).
2932

3033
[#1027]: https://github.com/stackabletech/docker-images/pull/1027
34+
[#1028]: https://github.com/stackabletech/docker-images/pull/1028
3135
[#1029]: https://github.com/stackabletech/docker-images/pull/1029
3236
[#1034]: https://github.com/stackabletech/docker-images/pull/1034
3337
[#1038]: https://github.com/stackabletech/docker-images/pull/1038

hbase/Dockerfile

Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ ln -s "/stackable/hbase-${PRODUCT}" /stackable/hbase
6565
### JMX Prometheus Exporter/Agent
6666
###
6767
if [[ -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
7171
fi
@@ -75,7 +75,7 @@ fi
7575
###
7676
cd /stackable
7777
export 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 .
7979
ln -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/*
8989
fi
90+
91+
# set correct groups
92+
chmod --recursive g=u /stackable
9093
EOF
9194

95+
9296
FROM stackable/image/java-devel AS opa-authorizer-builder
9397

9498
ARG OPA_AUTHORIZER
@@ -99,7 +103,6 @@ USER ${STACKABLE_USER_UID}
99103
WORKDIR /stackable
100104

101105
RUN --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
118121
fi
119122

120-
121123
if [ "${DELETE_CACHES}" = "true" ] ; then
122124
rm -rf /stackable/.m2/repository/*
123125
fi
126+
127+
# set correct groups
128+
chmod --recursive g=u /stackable
124129
EOF
125130

131+
126132
FROM stackable/image/java-devel AS hbase-operator-tools-builder
127133

128134
ARG HBASE_OPERATOR_TOOLS
@@ -141,7 +147,7 @@ ARG DELETE_CACHES="true"
141147
COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/bin/hbck2.env /stackable/bin/
142148
COPY --chown=${STACKABLE_USER_UID}:0 hbase/hbase-operator-tools/stackable/patches /stackable/patches
143149
COPY --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

146152
USER ${STACKABLE_USER_UID}
147153
WORKDIR /stackable
@@ -150,7 +156,7 @@ WORKDIR /stackable
150156
# We need to explicitly give the uid to use
151157
RUN --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 .
154160
mv hbase-operator-tools-${HBASE_OPERATOR_TOOLS} hbase-operator-tools-${HBASE_OPERATOR_TOOLS}-src
155161
chmod +x patches/apply_patches.sh
156162
patches/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/*
189195
fi
196+
197+
# set correct groups
198+
chmod --recursive g=u /stackable
190199
EOF
191200

192201

@@ -202,9 +211,9 @@ USER ${STACKABLE_USER_UID}
202211
WORKDIR /stackable
203212

204213
COPY --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

209218
COPY --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:' |
218227
envsubst '${PRODUCT}:${LIBS}' < /stackable/bin/export-snapshot-to-s3.env > /stackable/bin/export-snapshot-to-s3
219228
chmod +x /stackable/bin/export-snapshot-to-s3
220229
rm /stackable/bin/export-snapshot-to-s3.env
230+
231+
# set correct groups
232+
chmod --recursive g=u /stackable
221233
EOF
222234

235+
223236
FROM stackable/image/java-devel AS phoenix-builder
224237

225238
ARG PRODUCT
@@ -240,7 +253,7 @@ WORKDIR /stackable
240253

241254
RUN --mount=type=cache,id=maven-phoenix-${PHOENIX},uid=${STACKABLE_USER_UID},target=/stackable/.m2/repository <<EOF
242255
cd /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 .
244257
mv phoenix-${PHOENIX} phoenix-${PHOENIX}-src
245258

246259
chmod +x patches/apply_patches.sh
@@ -269,7 +282,6 @@ mv phoenix-${PHOENIX}-src/phoenix-assembly/target/bom.json /stackable/phoenix-${
269282
rm -rf /stackable/phoenix-${PHOENIX}-src
270283
ln -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/*
281293
fi
294+
295+
# set correct groups
296+
chmod --recursive g=u /stackable
282297
EOF
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://".
335350
COPY --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

339354
COPY --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

353368
microdnf clean all
354369
rpm -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
355372
rm -rf /var/cache/yum
356373

357374
ln --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+
358378
ln --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 {} +
365393
EOF
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

374411
USER ${STACKABLE_USER_UID}
375412
ENV HBASE_CONF_DIR=/stackable/hbase/conf

0 commit comments

Comments
 (0)