Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Dockerfile #451

Merged
merged 13 commits into from
Feb 1, 2024
34 changes: 16 additions & 18 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
# 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
SgtSilvio marked this conversation as resolved.
Show resolved Hide resolved

ARG HIVEMQ_VERSION

COPY hivemq-ce-${HIVEMQ_VERSION}.zip /
RUN unzip /hivemq-ce-${HIVEMQ_VERSION}.zip -d /opt \
&& chgrp -R 0 /opt \
&& chmod -R 770 /opt
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 \
&& chmod +x /opt/hivemq/bin/run.sh
SgtSilvio marked this conversation as resolved.
Show resolved Hide resolved

SgtSilvio marked this conversation as resolved.
Show resolved Hide resolved

FROM eclipse-temurin:11.0.22_7-jre-jammy@sha256:985ec5f9ff61ef9e24b2298ef902d773a1e1cb36693d62d0ac4d37e289ff595b

ARG HIVEMQ_VERSION

SgtSilvio marked this conversation as resolved.
Show resolved Hide resolved
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"
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

# 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 \
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-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
&& chmod 770 /opt/hivemq

SgtSilvio marked this conversation as resolved.
Show resolved Hide resolved
# Make broker data persistent throughout stop/start cycles
VOLUME /opt/hivemq/data
Expand Down
Loading