-
Notifications
You must be signed in to change notification settings - Fork 1.5k
WIP: Run activemq container as non root #1378
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
base: main
Are you sure you want to change the base?
Changes from all commits
0250c68
87d4489
80cf559
723eb16
cdc6bd0
9a3345d
e1a5b79
ca6954d
ee2c9b6
3fb641f
59db1d6
b7f12b6
5b9efdd
a8cff13
ed75e96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,31 +15,87 @@ | |
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
################################################################################ | ||
FROM debian:bookworm-slim AS amq_tpl | ||
# activemq_dist can point to a directory or a tarball on the local system | ||
ARG activemq_dist=NOT_SET | ||
ARG ACTIVEMQ_WEB_DEFAULT_USER=admin | ||
ARG ACTIVEMQ_WEB_DEFAULT_PASSWORD=admin | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Prepare ActiveMQ distribution | ||
ADD $activemq_dist / | ||
|
||
RUN mv /apache-activemq-* /apache-activemq | ||
WORKDIR /apache-activemq | ||
RUN apt-get update && apt-get install xmlstarlet -y | ||
RUN xmlstarlet ed -L \ | ||
-N d='http://www.springframework.org/schema/beans' \ | ||
-N a='http://activemq.apache.org/schema/core' \ | ||
-d '//comment()' \ | ||
-s '/d:beans/a:broker' -t elem -n plugins \ | ||
-s '/d:beans/a:broker/plugins' -t elem -n simpleAuthenticationPlugin \ | ||
-s '/d:beans/a:broker/plugins/simpleAuthenticationPlugin' -t elem -n users \ | ||
-a '/d:beans/a:broker/plugins/simpleAuthenticationPlugin' -t attr -name anonymousAccessAllowed -v true \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enabling anonymous access should not be the default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. I first tried to make it point to another env var but it did not work and I concluded the plugin attribute I personally have no problem with setting it to false b default instead, unless there's a way to make the plugin initialization lookup a java system property for |
||
-s '/d:beans/a:broker/plugins/simpleAuthenticationPlugin/users' -t elem -n authenticationUser \ | ||
-a '/d:beans/a:broker/plugins/simpleAuthenticationPlugin/users/authenticationUser' -t attr -n username -v '${activemq.username}' \ | ||
-a '/d:beans/a:broker/plugins/simpleAuthenticationPlugin/users/authenticationUser' -t attr -name password -v '${activemq.password}' \ | ||
-a '/d:beans/a:broker/plugins/simpleAuthenticationPlugin/users/authenticationUser' -t attr -name groups -v '${activemq.groups}' \ | ||
conf/activemq.xml | ||
RUN xmlstarlet ed -L \ | ||
-N d='http://www.springframework.org/schema/beans' \ | ||
-N a='http://activemq.apache.org/schema/core' \ | ||
-u '/d:beans/a:broker/a:managementContext/a:managementContext/@createConnector' -v '${activemq.jmx.enabled}' \ | ||
conf/activemq.xml | ||
# Configure default web console authentication for ActiveMQ 5.x and 6.x | ||
RUN if [ -n "$ACTIVEMQ_WEB_DEFAULT_USER" ]; then \ | ||
sed -i "s/admin=/${ACTIVEMQ_WEB_DEFAULT_USER}=/g" conf/users.properties; \ | ||
sed -i "s/=admin/=${ACTIVEMQ_WEB_DEFAULT_USER}/g" conf/groups.properties; \ | ||
fi; \ | ||
if [ -n "$ACTIVEMQ_WEB_DEFAULT_PASSWORD" ]; then \ | ||
sed -i "s/=admin/=${ACTIVEMQ_WEB_DEFAULT_PASSWORD}/g" conf/users.properties; \ | ||
fi; \ | ||
if [ -f conf/jetty-realm.properties ]; then \ | ||
sed -i "s/admin: admin/${ACTIVEMQ_WEB_DEFAULT_USER}: ${ACTIVEMQ_WEB_DEFAULT_PASSWORD}/" conf/jetty-realm.properties; \ | ||
fi | ||
RUN rm conf/credentials.properties && touch conf/credentials.properties && \ | ||
mkdir tmp && \ | ||
chmod -R g+w conf data tmp | ||
|
||
FROM eclipse-temurin:17-jre | ||
ARG ACTIVEMQ_USERNAME=activemq | ||
ARG ACTIVEMQ_GROUPNAME=activemq | ||
ARG ACTIVEMQ_WEB_DEFAULT_USER=admin | ||
ARG ACTIVEMQ_WEB_DEFAULT_PASSWORD=admin | ||
|
||
# ActiveMQ environment variables | ||
ENV ACTIVEMQ_INSTALL_PATH /opt | ||
ENV ACTIVEMQ_HOME $ACTIVEMQ_INSTALL_PATH/apache-activemq | ||
ENV ACTIVEMQ_CONF $ACTIVEMQ_HOME/conf | ||
ENV ACTIVEMQ_OPTS_MEMORY -Xms64M -Xmx1G | ||
ENV ACTIVEMQ_EXEC exec | ||
ENV PATH $PATH:$ACTIVEMQ_HOME/bin | ||
ENV ACTIVEMQ_INSTALL_PATH=/opt | ||
ENV ACTIVEMQ_HOME=$ACTIVEMQ_INSTALL_PATH/apache-activemq | ||
ENV ACTIVEMQ_CONF=$ACTIVEMQ_HOME/conf | ||
ENV ACTIVEMQ_OPTS_MEMORY="-Xms64M -Xmx1G" | ||
ENV ACTIVEMQ_EXEC=exec | ||
ENV PATH=$PATH:$ACTIVEMQ_HOME/bin | ||
ENV ACTIVEMQ_CONNECTION_USER=system | ||
ENV ACTIVEMQ_CONNECTION_GROUPS=users | ||
ENV ACTIVEMQ_CONNECTION_PASSWORD=manager | ||
ENV ACTIVEMQ_JMX_ENABLED=false | ||
ENV ACTIVEMQ_WEB_DEFAULT_USER=$ACTIVEMQ_WEB_DEFAULT_USER | ||
ENV ACTIVEMQ_WEB_DEFAULT_PASSWORD=$ACTIVEMQ_WEB_DEFAULT_PASSWORD | ||
|
||
# Make the Web console accesible from outside the container | ||
ENV ACTIVEMQ_OPTS $ACTIVEMQ_OPTS_MEMORY -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=$ACTIVEMQ_CONF/login.config -Djetty.host=0.0.0.0 | ||
ENV ACTIVEMQ_OPTS='$ACTIVEMQ_OPTS_MEMORY -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=$ACTIVEMQ_CONF/login.config -Djetty.host=0.0.0.0 -Dactivemq.username=$ACTIVEMQ_CONNECTION_USER -Dactivemq.groups=$ACTIVEMQ_CONNECTION_GROUPS -Dactivemq.password=$ACTIVEMQ_CONNECTION_PASSWORD -Dactivemq.jmx.enabled=$ACTIVEMQ_JMX_ENABLED' | ||
#WORKDIR $ACTIVEMQ_HOME | ||
|
||
# activemq_dist can point to a directory or a tarball on the local system | ||
ARG activemq_dist=NOT_SET | ||
RUN groupadd --system ${ACTIVEMQ_GROUPNAME} && \ | ||
useradd -l --system -g ${ACTIVEMQ_GROUPNAME} -d ${ACTIVEMQ_HOME} -s /bin/false ${ACTIVEMQ_USERNAME} | ||
|
||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh | ||
COPY --from=amq_tpl --chown=:${ACTIVEMQ_GROUPNAME} /apache-activemq $ACTIVEMQ_INSTALL_PATH/apache-activemq | ||
|
||
# Install build dependencies and activemq | ||
ADD $activemq_dist $ACTIVEMQ_INSTALL_PATH | ||
RUN set -x && \ | ||
cp -r $ACTIVEMQ_INSTALL_PATH/apache-activemq-* $ACTIVEMQ_HOME && \ | ||
rm -r $ACTIVEMQ_INSTALL_PATH/apache-activemq-* | ||
RUN chmod 600 ${ACTIVEMQ_HOME}/conf/jmx.password && \ | ||
chown ${ACTIVEMQ_USERNAME}:${ACTIVEMQ_GROUPNAME} ${ACTIVEMQ_HOME}/conf/jmx.password | ||
|
||
USER ${ACTIVEMQ_USERNAME} | ||
EXPOSE 8161 61616 5672 61613 1883 61614 1099 | ||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] | ||
CMD ["activemq", "console"] |
Uh oh!
There was an error while loading. Please reload this page.