forked from hivemq/hivemq4-docker-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
63 lines (49 loc) · 2.55 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
FROM openjdk:11-jre-slim
ARG HIVEMQ_VERSION=4.0.0
ENV HIVEMQ_GID=10000
ENV HIVEMQ_UID=10000
# Additional JVM options, may be overwritten by user
ENV JAVA_OPTS "-XX:+UnlockExperimentalVMOptions -XX:+UseNUMA"
# gosu for root step-down to user-privileged process
ENV GOSU_VERSION 1.11
# Set locale
ENV LANG=en_US.UTF-8
# gosu setup
RUN set -x \
&& apt-get update && apt-get install -y --no-install-recommends curl gnupg-agent gnupg dirmngr unzip \
&& curl -fSL "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" -o /usr/local/bin/gosu \
&& curl -fSL "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" -o /usr/local/bin/gosu.asc \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
&& rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \
&& { command -v gpgconf && gpgconf --kill all || :; } \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true \
&& apt-get purge -y gpg dirmngr && rm -rf /var/lib/apt/lists/*
COPY config.xml /opt/config.xml
COPY docker-entrypoint.sh /opt/docker-entrypoint.sh
# HiveMQ setup
RUN curl -L https://www.hivemq.com/releases/hivemq-${HIVEMQ_VERSION}.zip -o /opt/hivemq-${HIVEMQ_VERSION}.zip \
&& unzip /opt/hivemq-${HIVEMQ_VERSION}.zip -d /opt/\
&& rm -f /opt/hivemq-${HIVEMQ_VERSION}.zip \
&& ln -s /opt/hivemq-${HIVEMQ_VERSION} /opt/hivemq \
&& mv /opt/config.xml /opt/hivemq-${HIVEMQ_VERSION}/conf/config.xml \
&& groupadd --gid ${HIVEMQ_GID} hivemq \
&& useradd -g hivemq -d /opt/hivemq -s /bin/bash --uid ${HIVEMQ_UID} hivemq \
&& chmod -R 775 /opt \
&& chmod +x /opt/hivemq/bin/run.sh /opt/docker-entrypoint.sh
# Substitute eval for exec and replace OOM flag if necessary (for older releases). This is necessary for proper signal propagation
RUN sed -i -e 's|eval \\"java\\" "$HOME_OPT" "$JAVA_OPTS" -jar "$JAR_PATH"|exec "java" $HOME_OPT $JAVA_OPTS -jar "$JAR_PATH"|' /opt/hivemq/bin/run.sh && \
sed -i -e "s|-XX:OnOutOfMemoryError='sleep 5; kill -9 %p'|-XX:+CrashOnOutOfMemoryError|" /opt/hivemq/bin/run.sh
# Make broker data persistent throughout stop/start cycles
VOLUME /opt/hivemq/data
# Persist log data
VOLUME /opt/hivemq/log
#mqtt-clients
EXPOSE 1883
#HiveMQ Control Center
EXPOSE 8080
WORKDIR /opt/hivemq
ENTRYPOINT ["/opt/docker-entrypoint.sh"]
CMD ["/opt/hivemq/bin/run.sh"]