Skip to content
This repository was archived by the owner on Aug 30, 2021. It is now read-only.

Commit fdeb8c2

Browse files
committed
Move the VOLUME declaration to the end of the Dockerfile
One a VOLUME has been declared, changes to that location are subsequently dropped during the building of the Dockerfile. With the changes, in rabbitmq/rabbitmq-common#369 applied, this meant that the enabling of plugins no longer worked. We now make the VOLUME declaration the last line of the Dockerfile, assuming that we would not want to throw out any changes. Additionally, we use gosu to execute plugin enablement, so that the 'enabled_plugins' file is owned by the rabbitmq user when the broker goes to update it.
1 parent d4f20ff commit fdeb8c2

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Dockerfile

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,6 @@ RUN ln -sf /opt/rabbitmq/plugins /plugins
256256

257257
# set home so that any `--user` knows where to put the erlang cookie
258258
ENV HOME $RABBITMQ_DATA_DIR
259-
# Hint that the data (a.k.a. home dir) dir should be separate volume
260-
VOLUME $RABBITMQ_DATA_DIR
261259

262260
# warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
263261
# Setting all environment variables that control language preferences, behaviour differs - https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html#The-LANGUAGE-variable
@@ -271,8 +269,8 @@ EXPOSE 4369 5671 5672 25672
271269
CMD ["rabbitmq-server"]
272270

273271
# rabbitmq_management
274-
RUN rabbitmq-plugins enable --offline rabbitmq_management && \
275-
rabbitmq-plugins is_enabled rabbitmq_management --offline
272+
RUN gosu rabbitmq rabbitmq-plugins enable --offline rabbitmq_management && \
273+
gosu rabbitmq rabbitmq-plugins is_enabled rabbitmq_management --offline
276274
# extract "rabbitmqadmin" from inside the "rabbitmq_management-X.Y.Z.ez" plugin zipfile
277275
# see https://github.com/docker-library/rabbitmq/issues/207
278276
RUN set -eux; \
@@ -296,6 +294,14 @@ RUN set -eux; \
296294
rabbitmqadmin --version
297295
EXPOSE 15671 15672
298296

299-
RUN rabbitmq-plugins enable --offline rabbitmq_prometheus && \
300-
rabbitmq-plugins is_enabled rabbitmq_prometheus --offline
297+
RUN gosu rabbitmq rabbitmq-plugins enable --offline rabbitmq_prometheus && \
298+
gosu rabbitmq rabbitmq-plugins is_enabled rabbitmq_prometheus --offline
301299
EXPOSE 15692
300+
301+
# Hint that the data (a.k.a. home dir) dir should be separate volume
302+
# We do this last, otherwise our plugin configuration will be thrown out,
303+
# as per https://docs.docker.com/engine/reference/builder/#volume
304+
# > Changing the volume from within the Dockerfile:
305+
# > If any build steps change the data within the volume after it has been
306+
# > declared, those changes will be discarded.
307+
VOLUME $RABBITMQ_DATA_DIR

0 commit comments

Comments
 (0)