FROM registry-1.docker.io/library/openjdk:17-bullseye as builder
WORKDIR /opt
RUN apt update && \
	apt install -y xmlstarlet
RUN mkdir tmp && \
	wget "https://www.apache.org/dyn/closer.cgi?filename=activemq/activemq-artemis/2.19.0/apache-artemis-2.19.0-bin.zip&action=download" -O tmp/artemis.zip && \
	unzip -d tmp -q "tmp/artemis.zip" && \
	rm -f tmp/*.zip && mv tmp/* ./apache-artemis-2.19.0 && \
	ls -lah ./apache-artemis-2.19.0 && \
	rmdir tmp
RUN mkdir -p /var/lib/artemis/data && \
	touch /var/lib/artemis/data/.perf-journal-completed
    
FROM registry-1.docker.io/library/openjdk:17-bullseye 
RUN apt-get update && apt-get upgrade -y
COPY --from=builder "/opt/apache-artemis-2.19.0" "/opt/apache-artemis-2.19.0"
EXPOSE 1883
EXPOSE 5445
EXPOSE 5672
EXPOSE 8161
EXPOSE 9404
EXPOSE 61613
EXPOSE 61616
WORKDIR /
COPY config /config/
COPY entrypoint.sh .
COPY jmx_prometheus_javaagent-0.16.1.jar .
COPY jmx-config.yaml .
RUN addgroup --gid 1000 predic8 && adduser --home /var/lib/artemis --uid 1000 --ingroup predic8 --shell /bin/bash --disabled-password predic8
USER predic8
ENTRYPOINT ["/entrypoint.sh"]
CMD /var/lib/artemis/bin/artemis run