0

I am trying to implement SSL certificate in my ActiveMQ Artemis docker image in on-prem server. I have modified the broker.xml and dockerfile to implement the change in the image, but whenever I am trying to run the image, it is throwing me error:

CREATE_ARGUMENTS=--user username --password password --silent --require-login --http-host 0.0.0.0 --relax-jolokia
broker already created, ignoring creation
Running sed command
sed: can't read /var/lib/artemis-instance/etc/artemis.profile: No such file or directory

Dockerfile:

RUN mkdir /var/lib/artemis-instance
RUN mkdir -p /etc/certs/
RUN chmod 755 /var/lib/artemis-instance
RUN rm -rf /var/lib/artemis-instance/etc/broker.xml; ln -s artemis.profile /var/lib/artemis-instance/etc/artemis.profile
COPY broker.xml /var/lib/artemis-instance/etc/broker.xml
COPY ./docker-run.sh /

broker.xml (have changed only in acceptors):

            <!-- STOMP Acceptor. -->
            <acceptor name="stomp">tcp://0.0.0.0:61613?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=STOMP;useEpoll=true</acceptor>

            <!-- HornetQ Compatibility Acceptor.  Enables HornetQ Core and STOMP for legacy HornetQ clients. -->
            <acceptor name="hornetq">tcp://0.0.0.0:5445?anycastPrefix=jms.queue.;multicastPrefix=jms.topic.;protocols=HORNETQ,STOMP;useEpoll=true</acceptor>

            <!-- MQTT Acceptor -->
            <acceptor name="mqtt">tcp://0.0.0.0:1883?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=MQTT;useEpoll=true;sslEnabled=true;keyStorePath=/var/lib/artemis-instance/etc/certs/;keyStorePassword=password;needClientAuth=true </acceptor>
        </acceptors>
Justin Bertram
  • 29,372
  • 4
  • 21
  • 43

1 Answers1

0

A solution I found that is admittedly a bit janky is to copy the broker.xml to a different directory. Copy /opt/docker-run.sh outside of the container, edit the docker-run.sh with the following

if ! [ -f ./etc/broker.xml ]; then
    /opt/activemq-artemis/bin/artemis create ${CREATE_ARGUMENTS} .
else
    echo "broker already created, ignoring creation"
fi
cp ./broker.xml ./etc/broker.xml
exec ./bin/artemis "$@"

and add the new docker-run.shto your Dockerfile to be copied over.

The reasoning is that artemis won't do anything if the broker.xml already exists where you try to copy. So you let artemis generate the broker.xml, then overwrite it with your new one, then start artemis.