Skip to content

Commit 1dfa941

Browse files
committed
reduce image size
1 parent 83c3ad3 commit 1dfa941

File tree

1 file changed

+40
-33
lines changed

1 file changed

+40
-33
lines changed

zookeeper/Dockerfile

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,35 @@ USER ${STACKABLE_USER_UID}
1717
WORKDIR /stackable
1818

1919
# Download ZooKeeper sources from our own repo
20-
RUN curl "https://repo.stackable.tech/repository/packages/zookeeper/apache-zookeeper-${PRODUCT}.tar.gz" | tar -xzC . && \
21-
# Apply any required patches
22-
patches/apply_patches.sh ${PRODUCT} && \
23-
cd /stackable/apache-zookeeper-${PRODUCT}/ && \
24-
# Exclude the `zookeeper-client` submodule, this is not needed and has c parts
25-
# that created all kinds of issues for the build container
26-
mvn --batch-mode --no-transfer-progress -pl "!zookeeper-client/zookeeper-client-c" clean install checkstyle:check spotbugs:check -DskipTests -Pfull-build && \
27-
mv zookeeper-assembly/target/apache-zookeeper-${PRODUCT}-bin.tar.gz /stackable && \
28-
cd /stackable && \
29-
# Unpack the archive which contains the build artifacts from above. Remove some
30-
# unused files to shrink the final image size.
31-
tar xvzf /stackable/apache-zookeeper-${PRODUCT}-bin.tar.gz && \
32-
mv /stackable/apache-zookeeper-${PRODUCT}/zookeeper-assembly/target/bom.json /stackable/apache-zookeeper-${PRODUCT}-bin/apache-zookeeper-${PRODUCT}.cdx.json && \
33-
rm -rf /stackable/apache-zookeeper-${PRODUCT}-bin/docs && \
34-
rm /stackable/apache-zookeeper-${PRODUCT}-bin/README_packaging.md && \
35-
# Download the JMX exporter jar from our own repo
36-
curl "https://repo.stackable.tech/repository/packages/jmx-exporter/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar" \
37-
-o "/stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar" && \
38-
chmod +x "/stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar" && \
39-
ln -s "/stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar" /stackable/jmx/jmx_prometheus_javaagent.jar
20+
RUN <<EOF
21+
curl --fail "https://repo.stackable.tech/repository/packages/zookeeper/apache-zookeeper-${PRODUCT}.tar.gz" | tar -xzC .
22+
23+
# Apply any required patches
24+
patches/apply_patches.sh ${PRODUCT}
25+
cd /stackable/apache-zookeeper-${PRODUCT}/
26+
27+
# Exclude the `zookeeper-client` submodule, this is not needed and has c parts
28+
# that created all kinds of issues for the build container
29+
mvn --batch-mode --no-transfer-progress -pl "!zookeeper-client/zookeeper-client-c" clean install checkstyle:check spotbugs:check -DskipTests -Pfull-build
30+
mv zookeeper-assembly/target/apache-zookeeper-${PRODUCT}-bin.tar.gz /stackable
31+
32+
cd /stackable
33+
# Unpack the archive which contains the build artifacts from above. Remove some
34+
# unused files to shrink the final image size.
35+
tar xvzf /stackable/apache-zookeeper-${PRODUCT}-bin.tar.gz
36+
mv /stackable/apache-zookeeper-${PRODUCT}/zookeeper-assembly/target/bom.json /stackable/apache-zookeeper-${PRODUCT}-bin/apache-zookeeper-${PRODUCT}.cdx.json
37+
rm -rf /stackable/apache-zookeeper-${PRODUCT}-bin/docs
38+
rm /stackable/apache-zookeeper-${PRODUCT}-bin/README_packaging.md
39+
40+
# Download the JMX exporter jar from our own repo
41+
curl "https://repo.stackable.tech/repository/packages/jmx-exporter/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar" \
42+
-o "/stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar"
43+
chmod +x "/stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar"
44+
ln -s "/stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar" /stackable/jmx/jmx_prometheus_javaagent.jar
45+
46+
# set correct groups
47+
chmod -R g=u /stackable
48+
EOF
4049

4150
# END ZOOKEEPER BUILDER
4251
# ==============================================================================
@@ -50,20 +59,22 @@ ARG PRODUCT
5059
ARG RELEASE
5160
ARG STACKABLE_USER_UID
5261

53-
LABEL name="Apache ZooKeeper" \
62+
LABEL \
63+
name="Apache ZooKeeper" \
5464
maintainer="[email protected]" \
5565
vendor="Stackable GmbH" \
5666
version="${PRODUCT}" \
5767
release="${RELEASE}" \
5868
summary="The Stackable image for Apache ZooKeeper." \
5969
description="This image is deployed by the Stackable Operator for Apache ZooKeeper."
6070

61-
RUN microdnf update && \
62-
microdnf clean all && \
63-
rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE}\n" | sort > /stackable/package_manifest.txt && \
64-
rm -rf /var/cache/yum
65-
66-
WORKDIR /stackable
71+
RUN <<EOF
72+
microdnf update
73+
microdnf clean all
74+
rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE}\n" | sort > /stackable/package_manifest.txt
75+
chown ${STACKABLE_USER_UID}:0 /stackable/package_manifest.txt
76+
rm -rf /var/cache/yum
77+
EOF
6778

6879
# Copy over the ZooKeeper binary folder
6980
COPY --chown=${STACKABLE_USER_UID}:0 --from=builder /stackable/apache-zookeeper-${PRODUCT}-bin /stackable/apache-zookeeper-${PRODUCT}-bin/
@@ -74,15 +85,11 @@ COPY zookeeper/licenses /licenses
7485
# to preserve the folder name with the version.
7586
RUN <<EOF
7687
ln -s /stackable/apache-zookeeper-${PRODUCT}-bin/ /stackable/zookeeper
77-
78-
# All files and folders owned by root group to support running as arbitrary users.
79-
# This is best practice as all container users will belong to the root group (0).
80-
chown -R ${STACKABLE_USER_UID}:0 /stackable
81-
chmod -R g=u /stackable
88+
chown -h ${STACKABLE_USER_UID}:0 /stackable/zookeeper
8289
EOF
8390

8491
# ----------------------------------------
85-
# Attention: We are changing the group of all files in /stackable directly above
92+
# Attention:
8693
# If you do any file based actions (copying / creating etc.) below this comment you
8794
# absolutely need to make sure that the correct permissions are applied!
8895
# chown ${STACKABLE_USER_UID}:0

0 commit comments

Comments
 (0)