From 0c7a9234bf3d58c54060821d41330de6e9056504 Mon Sep 17 00:00:00 2001 From: cytopia Date: Wed, 15 Aug 2018 19:54:20 +0200 Subject: [PATCH] Fix #57: Add RabbitMQ --- .gitignore | 1 + compose/docker-compose.override.yml-all | 36 ++++ compose/docker-compose.override.yml-rabbitmq | 22 +++ docs/custom-container/enable-rabbitmq.rst | 174 +++++++++++++++++++ docs/index.rst | 6 +- 5 files changed, 237 insertions(+), 2 deletions(-) create mode 100644 compose/docker-compose.override.yml-all create mode 100644 compose/docker-compose.override.yml-rabbitmq create mode 100644 docs/custom-container/enable-rabbitmq.rst diff --git a/.gitignore b/.gitignore index 6fb7be15..cb1497b0 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ /data/mysql/* /data/pqsql/* /data/www/* +/data/rabbit/* /backups/* # Ignore Certificate Authority diff --git a/compose/docker-compose.override.yml-all b/compose/docker-compose.override.yml-all new file mode 100644 index 00000000..1ac82c37 --- /dev/null +++ b/compose/docker-compose.override.yml-all @@ -0,0 +1,36 @@ +version: '2.1' + +services: + + mailhog: + image: mailhog/mailhog:${MAILHOG_SERVER:-latest} + hostname: mailhog + ports: + - "${LOCAL_LISTEN_ADDR}${HOST_PORT_MAILHOG:-8025}:8025" + networks: + app_net: + ipv4_address: 172.16.238.200 + depends_on: + - bind + - php + - httpd + + rabbit: + image: rabbitmq:${RABBIT_SERVER:-management} + hostname: rabbit + environment: + - RABBITMQ_DEFAULT_VHOST=${RABBIT_DEFAULT_VHOST:-my_vhost} + - RABBITMQ_DEFAULT_USER=${RABBIT_DEFAULT_USER:-guest} + - RABBITMQ_DEFAULT_PASS=${RABBIT_DEFAULT_PASS:-guest} + ports: + - "${LOCAL_LISTEN_ADDR}${HOST_PORT_RABBIT:-5672}:5672" + - "${LOCAL_LISTEN_ADDR}${HOST_PORT_RABBIT_MGMT:-15672}:15672" + networks: + app_net: + ipv4_address: 172.16.238.210 + volumes: + - ${HOST_PATH_RABBIT_DATADIR:-./data/rabbit}/${RABBIT_SERVER:-management}:/var/lib/rabbitmq + depends_on: + - bind + - php + - httpd diff --git a/compose/docker-compose.override.yml-rabbitmq b/compose/docker-compose.override.yml-rabbitmq new file mode 100644 index 00000000..2ba5ae61 --- /dev/null +++ b/compose/docker-compose.override.yml-rabbitmq @@ -0,0 +1,22 @@ +version: '2.1' + +services: + rabbit: + image: rabbitmq:${RABBIT_SERVER:-management} + hostname: rabbit + environment: + - RABBITMQ_DEFAULT_VHOST=${RABBIT_DEFAULT_VHOST:-my_vhost} + - RABBITMQ_DEFAULT_USER=${RABBIT_DEFAULT_USER:-guest} + - RABBITMQ_DEFAULT_PASS=${RABBIT_DEFAULT_PASS:-guest} + ports: + - "${LOCAL_LISTEN_ADDR}${HOST_PORT_RABBIT:-5672}:5672" + - "${LOCAL_LISTEN_ADDR}${HOST_PORT_RABBIT_MGMT:-15672}:15672" + networks: + app_net: + ipv4_address: 172.16.238.210 + volumes: + - ${HOST_PATH_RABBIT_DATADIR:-./data/rabbit}/${RABBIT_SERVER:-management}:/var/lib/rabbitmq + depends_on: + - bind + - php + - httpd diff --git a/docs/custom-container/enable-rabbitmq.rst b/docs/custom-container/enable-rabbitmq.rst new file mode 100644 index 00000000..5c3a7459 --- /dev/null +++ b/docs/custom-container/enable-rabbitmq.rst @@ -0,0 +1,174 @@ +.. include:: /_includes/all.rst + +.. _custom_container_enable_rabbitmq: + +***************************** +Enable and configure RabbitMQ +***************************** + +This section will guide you through getting RabbitMQ integrated into the Devilbox. + +.. seealso:: + * |ext_lnk_rabbitmq_github| + * |ext_lnk_rabbitmq_dockerhub| + * :ref:`custom_container_enable_all_additional_container` + + +**Table of Contents** + +.. contents:: :local: + + +Overview +======== + +Available overwrites +-------------------- + +.. include:: /_includes/snippets/docker-compose-override-tree-view.rst + + +RabbitMQ settings +----------------- + +In case of RabbitMQ, the file is ``compose/docker-compose.override.yml-rabbitmq``. This file +must be copied into the root of the Devilbox git directory. + ++-----------------------+------------------------------------------------------------------------------------------------------+ +| What | How and where | ++=======================+======================================================================================================+ +| Example compose file | ``compose/docker-compose.override.yml-all`` or |br| ``compose/docker-compose.override.yml-rabbitmq`` | ++-----------------------+------------------------------------------------------------------------------------------------------+ +| Container IP address | ``172.16.238.210`` | ++-----------------------+------------------------------------------------------------------------------------------------------+ +| Container host name | ``rabbit`` | ++-----------------------+------------------------------------------------------------------------------------------------------+ +| Container name | ``rabbit`` | ++-----------------------+------------------------------------------------------------------------------------------------------+ +| Mount points | ``./data/rabbit`` (can be changed via ``.env``) | ++-----------------------+------------------------------------------------------------------------------------------------------+ +| Exposed port | ``5672`` and ``15672`` (can be changed via ``.env``) | ++-----------------------+------------------------------------------------------------------------------------------------------+ +| Available at | ``http://localhost:15672`` (Admin WebUI) | ++-----------------------+------------------------------------------------------------------------------------------------------+ +| Further configuration | none | ++-----------------------+------------------------------------------------------------------------------------------------------+ + +RabbitMQ env variables +---------------------- + +Additionally the following ``.env`` variables can be created for easy configuration: + ++------------------------------+-------------------+----------------------------------------------------------------------------+ +| Variable | Default value | Description | ++==============================+===================+============================================================================+ +| ``HOST_PORT_RABBIT`` | ``5672`` | Controls the host port on which RabbitMQ API will be available at. | ++------------------------------+-------------------+----------------------------------------------------------------------------+ +| ``HOST_PORT_RABBIT_MGMT`` | ``15672`` | Controls the host port on which RabbitMQ Admin WebUI will be available at. | ++------------------------------+-------------------+----------------------------------------------------------------------------+ +| ``RABBIT_SERVER`` | ``management`` | Controls the RabbitMQ version to use. | ++------------------------------+-------------------+----------------------------------------------------------------------------+ +| ``HOST_PATH_RABBIT_DATADIR`` | ``./data/rabbit`` | Default mount point for persistent data. | ++------------------------------+-------------------+----------------------------------------------------------------------------+ +| ``rabbit_default_vhost`` | ``my_vhost`` | Default RabbitMQ vhost name. (not a webserver vhost name) | ++------------------------------+-------------------+----------------------------------------------------------------------------+ +| ``RABBIT_DEFAULT_USER`` | ``guest`` | Default username for Admin WebUI. | ++------------------------------+-------------------+----------------------------------------------------------------------------+ +| ``RABBIT_DEFAULT_PASS`` | ``guest`` | Default password for Admin WebUI. | ++------------------------------+-------------------+----------------------------------------------------------------------------+ + + + + +Instructions +============ + +1. Copy docker-compose.override.yml +----------------------------------- + +Copy the RabbitMQ Docker Compose overwrite file into the root of the Devilbox git directory. +(It must be at the same level as the default ``docker-compose.yml`` file). + +.. code-block:: bash + + host> cp compose/docker-compose.override.yml-rabbitmq docker-compose.override.yml + +.. seealso:: + * :ref:`docker_compose_override_yml` + * :ref:`add_your_own_docker_image` + * :ref:`overwrite_existing_docker_image` + + +2. Adjust ``.env`` settings (optional) +-------------------------------------- + +RabbitMQ is using sane defaults, which can be changed by adding variables to the ``.env`` file +and assigning custom values. + +Add the following variables to ``.env`` and adjust them to your needs: + +.. code-block:: bash + :caption: .env + + # RabbitMQ version to choose + #RABBIT_SERVER=3.6 + #RABBIT_SERVER=3.6-management + #RABBIT_SERVER=3.7 + #RABBIT_SERVER=3.7-management + #RABBIT_SERVER=latest + RABBIT_SERVER=management + + RABBIT_DEFAULT_VHOST=my_vhost + RABBIT_DEFAULT_USER=guest + RABBIT_DEFAULT_PASS=guest + + HOST_PORT_RABBIT=5672 + HOST_PORT_RABBIT_MGMT=15672 + HOST_PATH_RABBIT_DATADIR=./data/rabbit + +.. seealso:: :ref:`env_file` + + +4. Start the Devilbox +--------------------- + +The final step is to start the Devilbox with RabbitMQ. + +Let's assume you want to start ``php``, ``httpd``, ``bind``, ``rabbit``. + +.. code-block:: bash + + host> docker-compose up -d php httpd bind rabbitmq + +.. seealso:: :ref:`start_the_devilbox` + + +TL;DR +===== + +For the lazy readers, here are all commands required to get you started. +Simply copy and paste the following block into your terminal from the root of your Devilbox git +directory: + +.. code-block:: bash + + # Copy compose-override.yml into place + cp compose/docker-compose.override.yml-rabbitmq docker-compose.override.yml + + # Create .env variable + echo "# RabbitMQ version to choose" >> .env + echo "#RABBIT_SERVER=3.6" >> .env + echo "#RABBIT_SERVER=3.6-management" >> .env + echo "#RABBIT_SERVER=3.7" >> .env + echo "#RABBIT_SERVER=3.7-management" >> .env + echo "#RABBIT_SERVER=latest" >> .env + echo "RABBIT_SERVER=management" >> .env + echo "RABBIT_DEFAULT_VHOST=my_vhost" >> .env + echo "RABBIT_DEFAULT_USER=guest" >> .env + echo "RABBIT_DEFAULT_PASS=guest" >> .env + echo "HOST_PORT_RABBIT=5672" >> .env + echo "HOST_PORT_RABBIT_MGMT=15672" >> .env + echo "HOST_PATH_RABBIT_DATADIR=./data/rabbit" >> .env + + # Start container + docker-compose up -d php httpd bind rabbit diff --git a/docs/index.rst b/docs/index.rst index e7080956..6d0abfde 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -90,10 +90,12 @@ host is ready to be served with your custom domain. vhost-gen/example-add-subdomains .. toctree:: - :caption: Add custom container + :caption: Enable custom container :maxdepth: 2 - custom-container/integrate-mailhog + custom-container/enable-all-container + custom-container/enable-mailhog + custom-container/enable-rabbitmq .. toctree::