Merge pull request #508 from cytopia/features

Feature: Add Varnish to Devilbox stack
This commit is contained in:
cytopia 2019-02-17 10:29:24 +01:00 committed by GitHub
commit 325acdf89a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 229 additions and 8 deletions

View File

@ -14,7 +14,7 @@ putenv('RES_OPTIONS=retrans:1 retry:1 timeout:1 attempts:1');
$DEVILBOX_VERSION = 'v0.15';
$DEVILBOX_DATE = '2019-01-30';
$DEVILBOX_DATE = '2019-02-17';
$DEVILBOX_API_PAGE = 'devilbox-api/status.json';
//

View File

@ -40,6 +40,7 @@ major versions.
- MailHog
- RabbitMQ
- Solr
- Varnish
- New binaries
- `blackfire`
- `dep` (Deployer)

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

@ -70,5 +70,24 @@ services:
- php
- httpd
varnish:
image: devilbox/varnish:${VARNISH_SERVER:-6}
hostname: varnish
ports:
- "${LOCAL_LISTEN_ADDR}${HOST_PORT_VARNISH:-6081}:6081"
networks:
app_net:
ipv4_address: 172.16.238.230
environment:
- VARNISH_CONFIG=/etc/varnish/default.vcl
- CACHE_SIZE=${VARNISH_CACHE_SIZE:-128m}
- VARNISHD_PARAMS=${VARNISH_PARAMS:--p default_ttl=3600 -p default_grace=3600}
- BACKEND_HOST=httpd
- BACKEND_PORT=80
depends_on:
- bind
- php
- httpd
volumes:
data-solr:

View File

@ -0,0 +1,21 @@
version: '2.1'
services:
varnish:
image: devilbox/varnish:${VARNISH_SERVER:-6}
hostname: varnish
ports:
- "${LOCAL_LISTEN_ADDR}${HOST_PORT_VARNISH:-6081}:6081"
networks:
app_net:
ipv4_address: 172.16.238.230
environment:
- VARNISH_CONFIG=/etc/varnish/default.vcl
- CACHE_SIZE=${VARNISH_CACHE_SIZE:-128m}
- VARNISHD_PARAMS=${VARNISH_PARAMS:--p default_ttl=3600 -p default_grace=3600}
- BACKEND_HOST=httpd
- BACKEND_PORT=80
depends_on:
- bind
- php
- httpd

View File

@ -95,7 +95,7 @@ services:
# PHP
# ------------------------------------------------------------
php:
image: devilbox/php-fpm:${PHP_SERVER}-work-0.75
image: devilbox/php-fpm:${PHP_SERVER}-work-0.76
hostname: php
##

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::