From ea40bda61ba1d0623619c75aaef5efed1a303283 Mon Sep 17 00:00:00 2001 From: Silvio Giebl Date: Mon, 29 Jan 2024 16:34:56 +0100 Subject: [PATCH 01/13] Dockerfile > change HIVEMQ_GID and HIVEMQ_UID env to arg --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index e83c776e9..6575538a4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -12,8 +12,8 @@ FROM eclipse-temurin:11.0.22_7-jre-jammy@sha256:985ec5f9ff61ef9e24b2298ef902d773 ARG HIVEMQ_VERSION -ENV HIVEMQ_GID=10000 -ENV HIVEMQ_UID=10000 +ARG HIVEMQ_GID=10000 +ARG HIVEMQ_UID=10000 # Additional JVM options, may be overwritten by user ENV JAVA_OPTS "-XX:+UnlockExperimentalVMOptions -XX:+UseNUMA" From 2a4c93090f42ead0b8923e217fa4ce8d4c11e84f Mon Sep 17 00:00:00 2001 From: Silvio Giebl Date: Mon, 29 Jan 2024 18:28:19 +0100 Subject: [PATCH 02/13] Dockerfile > use /tmp for zip --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 6575538a4..bcf0ed2fa 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,8 +3,8 @@ FROM busybox:1.35.0@sha256:02289a9972c5024cd2f083221f6903786e7f4cb4a9a9696f665d2 ARG HIVEMQ_VERSION -COPY hivemq-ce-${HIVEMQ_VERSION}.zip / -RUN unzip /hivemq-ce-${HIVEMQ_VERSION}.zip -d /opt \ +COPY hivemq-ce-${HIVEMQ_VERSION}.zip /tmp/hivemq-ce.zip +RUN unzip /tmp/hivemq-ce.zip -d /opt \ && chgrp -R 0 /opt \ && chmod -R 770 /opt From bdf19f424c1015ed86e7691f753516a7d51bb37b Mon Sep 17 00:00:00 2001 From: Silvio Giebl Date: Mon, 29 Jan 2024 23:15:27 +0100 Subject: [PATCH 03/13] Dockerfile > copy config.xml in unpack stage --- docker/Dockerfile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index bcf0ed2fa..ea2740fdc 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,8 +4,9 @@ FROM busybox:1.35.0@sha256:02289a9972c5024cd2f083221f6903786e7f4cb4a9a9696f665d2 ARG HIVEMQ_VERSION COPY hivemq-ce-${HIVEMQ_VERSION}.zip /tmp/hivemq-ce.zip -RUN unzip /tmp/hivemq-ce.zip -d /opt \ - && chgrp -R 0 /opt \ +RUN unzip /tmp/hivemq-ce.zip -d /opt +COPY config.xml /opt/hivemq-ce-${HIVEMQ_VERSION}/conf/config.xml +RUN chgrp -R 0 /opt \ && chmod -R 770 /opt FROM eclipse-temurin:11.0.22_7-jre-jammy@sha256:985ec5f9ff61ef9e24b2298ef902d773a1e1cb36693d62d0ac4d37e289ff595b @@ -26,13 +27,10 @@ ENV LANG=en_US.UTF-8 # HiveMQ setup COPY --from=unpack /opt/hivemq-ce-${HIVEMQ_VERSION} /opt/hivemq-ce-${HIVEMQ_VERSION} -COPY config.xml /opt/hivemq-ce-${HIVEMQ_VERSION}/conf/config.xml COPY docker-entrypoint.sh /opt/docker-entrypoint.sh RUN ln -s /opt/hivemq-ce-${HIVEMQ_VERSION} /opt/hivemq \ && groupadd --gid ${HIVEMQ_GID} hivemq \ && useradd -g hivemq -d /opt/hivemq -s /bin/bash --uid ${HIVEMQ_UID} hivemq \ - && chgrp 0 /opt/hivemq-ce-${HIVEMQ_VERSION}/conf/config.xml \ - && chmod 770 /opt/hivemq-ce-${HIVEMQ_VERSION}/conf/config.xml \ && chgrp 0 /opt/hivemq \ && chmod 770 /opt/hivemq \ && chmod +x /opt/hivemq/bin/run.sh /opt/docker-entrypoint.sh From 44e049ed79e7af60b5a03a9874b9eecd8439a5bc Mon Sep 17 00:00:00 2001 From: Silvio Giebl Date: Mon, 29 Jan 2024 23:23:24 +0100 Subject: [PATCH 04/13] Dockerfile > copy docker-entrypoint.sh before hivemq layer --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index ea2740fdc..c96bd4285 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -26,8 +26,8 @@ ENV HIVEMQ_ALLOW_ALL_CLIENTS "true" ENV LANG=en_US.UTF-8 # HiveMQ setup -COPY --from=unpack /opt/hivemq-ce-${HIVEMQ_VERSION} /opt/hivemq-ce-${HIVEMQ_VERSION} COPY docker-entrypoint.sh /opt/docker-entrypoint.sh +COPY --from=unpack /opt/hivemq-ce-${HIVEMQ_VERSION} /opt/hivemq-ce-${HIVEMQ_VERSION} RUN ln -s /opt/hivemq-ce-${HIVEMQ_VERSION} /opt/hivemq \ && groupadd --gid ${HIVEMQ_GID} hivemq \ && useradd -g hivemq -d /opt/hivemq -s /bin/bash --uid ${HIVEMQ_UID} hivemq \ From 39b8ea345bb4772d7c0fd8a7a4fae463d36397de Mon Sep 17 00:00:00 2001 From: Silvio Giebl Date: Mon, 29 Jan 2024 23:31:15 +0100 Subject: [PATCH 05/13] Dockerfile > move chmod +x of run.sh to unpack stage --- docker/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index c96bd4285..4461bbc36 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -7,7 +7,8 @@ COPY hivemq-ce-${HIVEMQ_VERSION}.zip /tmp/hivemq-ce.zip RUN unzip /tmp/hivemq-ce.zip -d /opt COPY config.xml /opt/hivemq-ce-${HIVEMQ_VERSION}/conf/config.xml RUN chgrp -R 0 /opt \ - && chmod -R 770 /opt + && chmod -R 770 /opt \ + && chmod +x /opt/hivemq-ce-${HIVEMQ_VERSION}/bin/run.sh FROM eclipse-temurin:11.0.22_7-jre-jammy@sha256:985ec5f9ff61ef9e24b2298ef902d773a1e1cb36693d62d0ac4d37e289ff595b @@ -33,7 +34,7 @@ RUN ln -s /opt/hivemq-ce-${HIVEMQ_VERSION} /opt/hivemq \ && useradd -g hivemq -d /opt/hivemq -s /bin/bash --uid ${HIVEMQ_UID} hivemq \ && chgrp 0 /opt/hivemq \ && chmod 770 /opt/hivemq \ - && chmod +x /opt/hivemq/bin/run.sh /opt/docker-entrypoint.sh + && chmod +x /opt/docker-entrypoint.sh # Make broker data persistent throughout stop/start cycles VOLUME /opt/hivemq/data From 8c566c3136ba3963774cf316854dfd538075cd19 Mon Sep 17 00:00:00 2001 From: Silvio Giebl Date: Tue, 30 Jan 2024 11:28:13 +0100 Subject: [PATCH 06/13] Dockerfile > move directly into /opt/hivemq without symlink --- docker/Dockerfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 4461bbc36..e8f111e83 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,11 +4,12 @@ FROM busybox:1.35.0@sha256:02289a9972c5024cd2f083221f6903786e7f4cb4a9a9696f665d2 ARG HIVEMQ_VERSION COPY hivemq-ce-${HIVEMQ_VERSION}.zip /tmp/hivemq-ce.zip -RUN unzip /tmp/hivemq-ce.zip -d /opt -COPY config.xml /opt/hivemq-ce-${HIVEMQ_VERSION}/conf/config.xml +RUN unzip /tmp/hivemq-ce.zip -d /opt \ + && mv /opt/hivemq-ce-${HIVEMQ_VERSION} /opt/hivemq +COPY config.xml /opt/hivemq/conf/config.xml RUN chgrp -R 0 /opt \ && chmod -R 770 /opt \ - && chmod +x /opt/hivemq-ce-${HIVEMQ_VERSION}/bin/run.sh + && chmod +x /opt/hivemq/bin/run.sh FROM eclipse-temurin:11.0.22_7-jre-jammy@sha256:985ec5f9ff61ef9e24b2298ef902d773a1e1cb36693d62d0ac4d37e289ff595b @@ -28,13 +29,12 @@ ENV LANG=en_US.UTF-8 # HiveMQ setup COPY docker-entrypoint.sh /opt/docker-entrypoint.sh -COPY --from=unpack /opt/hivemq-ce-${HIVEMQ_VERSION} /opt/hivemq-ce-${HIVEMQ_VERSION} -RUN ln -s /opt/hivemq-ce-${HIVEMQ_VERSION} /opt/hivemq \ +COPY --from=unpack /opt/hivemq /opt/hivemq +RUN chmod +x /opt/docker-entrypoint.sh \ && groupadd --gid ${HIVEMQ_GID} hivemq \ && useradd -g hivemq -d /opt/hivemq -s /bin/bash --uid ${HIVEMQ_UID} hivemq \ && chgrp 0 /opt/hivemq \ - && chmod 770 /opt/hivemq \ - && chmod +x /opt/docker-entrypoint.sh + && chmod 770 /opt/hivemq # Make broker data persistent throughout stop/start cycles VOLUME /opt/hivemq/data From 712f998b961b300cead80301cd773e942e9065a6 Mon Sep 17 00:00:00 2001 From: Silvio Giebl Date: Tue, 30 Jan 2024 12:23:42 +0100 Subject: [PATCH 07/13] Dockerfile > remove unnecessary chgrp 0 --- docker/Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index e8f111e83..f24973fe8 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -7,8 +7,7 @@ COPY hivemq-ce-${HIVEMQ_VERSION}.zip /tmp/hivemq-ce.zip RUN unzip /tmp/hivemq-ce.zip -d /opt \ && mv /opt/hivemq-ce-${HIVEMQ_VERSION} /opt/hivemq COPY config.xml /opt/hivemq/conf/config.xml -RUN chgrp -R 0 /opt \ - && chmod -R 770 /opt \ +RUN chmod -R 770 /opt \ && chmod +x /opt/hivemq/bin/run.sh FROM eclipse-temurin:11.0.22_7-jre-jammy@sha256:985ec5f9ff61ef9e24b2298ef902d773a1e1cb36693d62d0ac4d37e289ff595b @@ -33,7 +32,6 @@ COPY --from=unpack /opt/hivemq /opt/hivemq RUN chmod +x /opt/docker-entrypoint.sh \ && groupadd --gid ${HIVEMQ_GID} hivemq \ && useradd -g hivemq -d /opt/hivemq -s /bin/bash --uid ${HIVEMQ_UID} hivemq \ - && chgrp 0 /opt/hivemq \ && chmod 770 /opt/hivemq # Make broker data persistent throughout stop/start cycles From 4e32ca14c8be1e2ea5bb8a945a31771f2c3ebf7e Mon Sep 17 00:00:00 2001 From: Silvio Giebl Date: Tue, 30 Jan 2024 12:49:21 +0100 Subject: [PATCH 08/13] Dockerfile > unify ENV syntax --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index f24973fe8..29b3f907d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -18,10 +18,10 @@ ARG HIVEMQ_GID=10000 ARG HIVEMQ_UID=10000 # Additional JVM options, may be overwritten by user -ENV JAVA_OPTS "-XX:+UnlockExperimentalVMOptions -XX:+UseNUMA" +ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseNUMA" # Default allow all extension, set this to false to disable it -ENV HIVEMQ_ALLOW_ALL_CLIENTS "true" +ENV HIVEMQ_ALLOW_ALL_CLIENTS=true # Set locale ENV LANG=en_US.UTF-8 From 35d440f80cde37413e0f04f918bae3d556442640 Mon Sep 17 00:00:00 2001 From: Silvio Giebl Date: Tue, 30 Jan 2024 15:08:37 +0100 Subject: [PATCH 09/13] Dockerfile > 2 empty lines between stages --- docker/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 29b3f907d..5996ff7ad 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -10,6 +10,7 @@ COPY config.xml /opt/hivemq/conf/config.xml RUN chmod -R 770 /opt \ && chmod +x /opt/hivemq/bin/run.sh + FROM eclipse-temurin:11.0.22_7-jre-jammy@sha256:985ec5f9ff61ef9e24b2298ef902d773a1e1cb36693d62d0ac4d37e289ff595b ARG HIVEMQ_VERSION From 1c1ed79cace317ef785108ef33fabe2da3f25f9b Mon Sep 17 00:00:00 2001 From: Silvio Giebl Date: Tue, 30 Jan 2024 15:28:12 +0100 Subject: [PATCH 10/13] Dockerfile > Sync CE and EE --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 5996ff7ad..6e806ed19 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,5 @@ -# We use multi-stage here to unzip in an initial layer so we don't have to COPY and then RUN unzip (two layers). ADD can lead to larger layers as well. -FROM busybox:1.35.0@sha256:02289a9972c5024cd2f083221f6903786e7f4cb4a9a9696f665d20dd6892e5d6 AS unpack +# Additional build image to unpack the zip file and change the permissions without retaining large layers just for those operations +FROM busybox:1.36.1@sha256:6d9ac9237a84afe1516540f40a0fafdc86859b2141954b4d643af7066d598b74 AS unpack ARG HIVEMQ_VERSION From 258456f62801257a2f7de6faf9b2920a2940270f Mon Sep 17 00:00:00 2001 From: Silvio Giebl Date: Wed, 31 Jan 2024 09:17:55 +0100 Subject: [PATCH 11/13] Dockerfile > remove unnecessary ARG --- docker/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 6e806ed19..96d28a626 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -13,8 +13,6 @@ RUN chmod -R 770 /opt \ FROM eclipse-temurin:11.0.22_7-jre-jammy@sha256:985ec5f9ff61ef9e24b2298ef902d773a1e1cb36693d62d0ac4d37e289ff595b -ARG HIVEMQ_VERSION - ARG HIVEMQ_GID=10000 ARG HIVEMQ_UID=10000 From 67f77498a1e33daad5622700800c4e8812fd9f46 Mon Sep 17 00:00:00 2001 From: Silvio Giebl Date: Wed, 31 Jan 2024 09:19:10 +0100 Subject: [PATCH 12/13] Dockerfile > chmod /opt/hivemq and not /opt --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 96d28a626..8f079a761 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -7,7 +7,7 @@ COPY hivemq-ce-${HIVEMQ_VERSION}.zip /tmp/hivemq-ce.zip RUN unzip /tmp/hivemq-ce.zip -d /opt \ && mv /opt/hivemq-ce-${HIVEMQ_VERSION} /opt/hivemq COPY config.xml /opt/hivemq/conf/config.xml -RUN chmod -R 770 /opt \ +RUN chmod -R 770 /opt/hivemq \ && chmod +x /opt/hivemq/bin/run.sh From 7295956df6260a4bd745f621a255a6f90c5af1fc Mon Sep 17 00:00:00 2001 From: Silvio Giebl Date: Wed, 31 Jan 2024 09:59:59 +0100 Subject: [PATCH 13/13] Dockerfile > add comments --- docker/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 8f079a761..2e924fc71 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -11,6 +11,7 @@ RUN chmod -R 770 /opt/hivemq \ && chmod +x /opt/hivemq/bin/run.sh +# Actual image FROM eclipse-temurin:11.0.22_7-jre-jammy@sha256:985ec5f9ff61ef9e24b2298ef902d773a1e1cb36693d62d0ac4d37e289ff595b ARG HIVEMQ_GID=10000