Add documentation for Varnish

This commit is contained in:
cytopia 2019-02-16 21:12:34 +01:00
parent e4a5d09fd9
commit ae0ced0a67
No known key found for this signature in database
GPG Key ID: 6D56EDB8695128A2
7 changed files with 186 additions and 6 deletions

View File

@ -60,12 +60,12 @@ Before updating the Devilbox ensure to always check for breaking changes until t
The Devilbox ships the following pre-configured Docker container in any available version.
| Web server | SQL | NoSQL | Queue & Search | Misc |
|------------|------------|-----------|----------------|-----------|
| Apache | MariaDB | Memcached | RabbitMQ | Bind |
| Nginx | MySQL | MongoDB | Solr | Blackfire |
| | PerconaDB | Redis | | MailHog |
| | PostgreSQL | | | PHP |
| Web server | SQL | NoSQL | Queue & Search | Cache | Misc |
|------------|------------|-----------|----------------|---------|-----------|
| Apache | MariaDB | Memcached | RabbitMQ | Varnish | Bind |
| Nginx | MySQL | MongoDB | Solr | | Blackfire |
| | PerconaDB | Redis | | | MailHog |
| | PostgreSQL | | | | PHP |
> **Documentation:**
> [Available Container](https://devilbox.readthedocs.io/en/latest/readings/available-container.html)
@ -341,6 +341,7 @@ Additionally to the default stack, there are a variety of other services that ca
<th>MailHog</th>
<th>RabbitMQ</th>
<th>Solr</th>
<th>Varnish</th>
</tr>
</thead>
<tbody>
@ -349,24 +350,28 @@ Additionally to the default stack, there are a variety of other services that ca
<td><a target="_blank" title="MailHog v1.0.0" href="https://github.com/mailhog/MailHog">v1.0.0</a></td>
<td><a target="_blank" title="RabbitMQ 3.6" href="https://github.com/rabbitmq/rabbitmq-server">3.6</a></td>
<td><a target="_blank" title="Solr 5" href="https://github.com/apache/lucene-solr">5</a></td>
<td><a target="_blank" title="Varnish 4" href="https://github.com/devilbox/docker-varnish">4</a></td>
</tr>
<tr>
<td>...</td>
<td><a target="_blank" title="MailHog latest" href="https://github.com/mailhog/MailHog">latest</a></td>
<td><a target="_blank" title="RabbitMQ 3.7" href="https://github.com/rabbitmq/rabbitmq-server">3.7</a></td>
<td><a target="_blank" title="Solr 6" href="https://github.com/apache/lucene-solr">6</a></td>
<td><a target="_blank" title="Varnish 5" href="https://github.com/devilbox/docker-varnish">5</a></td>
</tr>
<tr>
<td><a target="_blank" title="Blackfire 1.18.0" href="https://github.com/blackfireio/docker">1.18.0</a></td>
<td></td>
<td><a target="_blank" title="RabbitMQ latest" href="https://github.com/rabbitmq/rabbitmq-server">latest</a></td>
<td><a target="_blank" title="Solr 7" href="https://github.com/apache/lucene-solr">7</a></td>
<td><a target="_blank" title="Varnish 6" href="https://github.com/devilbox/docker-varnish">6</a></td>
</tr>
<tr>
<td><a target="_blank" title="Blackfire latest" href="https://github.com/blackfireio/docker">latest</a></td>
<td></td>
<td></td>
<td><a target="_blank" title="Solr latest" href="https://github.com/apache/lucene-solr">latest</a></td>
<td><a target="_blank" title="Varnish latest" href="https://github.com/devilbox/docker-varnish">latest</a></td>
</tr>
</tbody>
</table>

View File

@ -75,3 +75,15 @@
<a target="_blank" href="https://hub.docker.com/_/solr/">
Dockerhub: Solr <img src="https://raw.githubusercontent.com/cytopia/icons/master/11x11/ext-link.png" />
</a>
.. |ext_lnk_varnish_github| raw:: html
<a target="_blank" href="https://github.com/varnishcache/varnish-cache/">
Github: Varnish <img src="https://raw.githubusercontent.com/cytopia/icons/master/11x11/ext-link.png" />
</a>
.. |ext_lnk_varnish_dockerhub| raw:: html
<a target="_blank" href="https://hub.docker.com/r/devilbox/varnish/">
Dockerhub: Varnish <img src="https://raw.githubusercontent.com/cytopia/icons/master/11x11/ext-link.png" />
</a>

View File

@ -9,3 +9,5 @@
+---------------------------+-----------+-----------+----------------+
| Solr | solr | solr | 172.16.238.220 |
+---------------------------+-----------+-----------+----------------+
| Varnish | varnish | varnish | 172.16.238.230 |
+---------------------------+-----------+-----------+----------------+

View File

@ -13,6 +13,7 @@ However, each example also exists in its standalone file as shown below:
├── docker-compose.override.yml-mailhog
├── docker-compose.override.yml-rabbitmq
├── docker-compose.override.yml-solr
├── docker-compose.override.yml-varnish
└── README.md
0 directories, 6 files

View File

@ -59,3 +59,4 @@ In order to fully customize each container, refer to their own documentation sec
* :ref:`custom_container_enable_mailhog`
* :ref:`custom_container_enable_rabbitmq`
* :ref:`custom_container_enable_solr`
* :ref:`custom_container_enable_varnish`

View File

@ -0,0 +1,158 @@
.. include:: /_includes/all.rst
.. _custom_container_enable_varnish:
****************************
Enable and configure Varnish
****************************
This section will guide you through getting Varnish integrated into the Devilbox.
.. seealso::
* |ext_lnk_varnish_github|
* |ext_lnk_varnish_dockerhub|
* :ref:`custom_container_enable_all_additional_container`
* :ref:`docker_compose_override_yml_how_does_it_work`
**Table of Contents**
.. contents:: :local:
Overview
========
Available overwrites
--------------------
.. include:: /_includes/snippets/docker-compose-override-tree-view.rst
Varnish settings
----------------
In case of Varnish, the file is ``compose/docker-compose.override.yml-varnish``. 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-varnish`` |
+-----------------------+------------------------------------------------------------------------------------------------------+
| Container IP address | ``172.16.238.230`` |
+-----------------------+------------------------------------------------------------------------------------------------------+
| Container host name | ``varnish`` |
+-----------------------+------------------------------------------------------------------------------------------------------+
| Container name | ``varnish`` |
+-----------------------+------------------------------------------------------------------------------------------------------+
| Mount points | none |
+-----------------------+------------------------------------------------------------------------------------------------------+
| Exposed port | ``6081`` (can be changed via ``.env``) |
+-----------------------+------------------------------------------------------------------------------------------------------+
| Available at | ``http://localhost:6081`` (or via ``http:<project>.<TLD>:6081``) |
+-----------------------+------------------------------------------------------------------------------------------------------+
| Further configuration | none |
+-----------------------+------------------------------------------------------------------------------------------------------+
Varnish env variables
---------------------
Additionally the following ``.env`` variables can be created for easy configuration:
+------------------------------+-----------------------------------------------+--------------------------------------------------------------------+
| Variable | Default value | Description |
+==============================+===============================================+====================================================================+
| ``HOST_PORT_VARNISH`` | ``6081`` | Controls the host port on which Varnish will be available at. |
+------------------------------+-----------------------------------------------+--------------------------------------------------------------------+
| ``VARNISH_SERVER`` | ``6`` | Controls the Varnish version to use. |
+------------------------------+-----------------------------------------------+--------------------------------------------------------------------+
| ``VARNISH_CONFIG`` | ``/etc/varnish/default.vcl`` | Path to Varnish configuration file (custom config can be mounted). |
+------------------------------+-----------------------------------------------+--------------------------------------------------------------------+
| ``VARNICS_CACHE_SIZE`` | ``128m`` | Varnish Cache size. |
+------------------------------+-----------------------------------------------+--------------------------------------------------------------------+
| ``VARNISH_PARAMS`` | ``-p default_ttl=3600 -p default_grace=3600`` | Additional Varnish startup parameter. |
+------------------------------+-----------------------------------------------+--------------------------------------------------------------------+
Instructions
============
1. Copy docker-compose.override.yml
-----------------------------------
Copy the Varnish 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-varnish 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)
--------------------------------------
Varnish 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
# Varnish version to choose
#VARNISH_SERVER=4
#VARNISH_SERVER=5
VARNISH_SERVER=6
# Varnish settings
VARNICS_CACHE_SIZE=128m
VARNISH_PARAMS=-p default_ttl=3600 -p default_grace=3600
HOST_PORT_VARNISH=6081
.. seealso:: :ref:`env_file`
4. Start the Devilbox
---------------------
The final step is to start the Devilbox with Varnish.
Let's assume you want to start ``php``, ``httpd``, ``bind``, ``varnish``.
.. code-block:: bash
host> docker-compose up -d php httpd bind varnish
.. 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-varnish docker-compose.override.yml
# Create .env variable
echo "# Varnish version to choose" >> .env
echo "#VARNISH_SERVER=4" >> .env
echo "#VARNISH_SERVER=5" >> .env
echo "VARNISH_SERVER=6" >> .env
echo "# Varnish settings" >> .env
echo "VARNICS_CACHE_SIZE=128m" >> .env
echo "VARNISH_PARAMS=-p default_ttl=3600 -p default_grace=3600" >> .env
echo "HOST_PORT_VARNISH=6081" >> .env
# Start container
docker-compose up -d php httpd bind varnish

View File

@ -117,6 +117,7 @@ host is ready to be served with your custom domain.
custom-container/enable-mailhog
custom-container/enable-rabbitmq
custom-container/enable-solr
custom-container/enable-varnish
.. toctree::