Merge pull request #690 from cytopia/release/v1.7.0

Release v1.7.0
This commit is contained in:
cytopia 2020-03-25 09:41:40 +01:00 committed by GitHub
commit 8c931cdf56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 700 additions and 25 deletions

View File

@ -13,8 +13,8 @@ error_reporting(-1);
putenv('RES_OPTIONS=retrans:1 retry:1 timeout:1 attempts:1');
$DEVILBOX_VERSION = 'v1.6.3';
$DEVILBOX_DATE = '2020-03-23';
$DEVILBOX_VERSION = 'v1.7.0';
$DEVILBOX_DATE = '2020-03-24';
$DEVILBOX_API_PAGE = 'devilbox-api/status.json';
//

View File

@ -7,6 +7,12 @@ major versions.
## Unreleased
## Release v1.7.0 (2020-03-24)
#### Added
- Python Flask
## Bugfix Release v1.6.3 (2020-03-23)
#### Fixed

View File

@ -91,12 +91,12 @@ Only the webserver and PHP container are mandatory, all others are optional and
Each of them is also available in multiple different versions in order to reflect your exact desired environment.
| Accel | Frontend | SQL | NoSQL | Queue | Search | ELK | Utils |
|---------|------------|------------|-----------|----------|--------|---------------|-----------|
| HAProxy | Apache | MariaDB | Memcached | RabbitMQ | Solr | ElasticSearch | Bind |
| Varnish | Nginx | MySQL | MongoDB | | | Logstash | Blackfire |
| | PHP | PerconaDB | Redis | | | Kibana | MailHog |
| | | PostgreSQL | | | | | Ngrok |
| Accel | Web | App | SQL | NoSQL | Queue / Search | ELK | Utils |
|---------|------------|----------------|------------|-----------|----------------|---------------|-----------|
| HAProxy | Apache | PHP | MariaDB | Memcached | RabbitMQ | ElasticSearch | Bind |
| Varnish | Nginx | Python (Flask) | MySQL | MongoDB | Solr | Logstash | Blackfire |
| | | | PerconaDB | Redis | | Kibana | MailHog |
| | | | PostgreSQL | | | | Ngrok |
> **Documentation:**
> [Available Container](https://devilbox.readthedocs.io/en/latest/readings/available-container.html)
@ -374,6 +374,7 @@ Additionally to the default stack, there are a variety of other services that ca
<table>
<thead>
<tr>
<th>Python (Flask)</th>
<th>Blackfire</th>
<th>ELK</th>
<th>MailHog</th>
@ -386,6 +387,7 @@ Additionally to the default stack, there are a variety of other services that ca
</thead>
<tbody>
<tr>
<td><a target="_blank" title="Python 2.7 " href="https://github.com/devilbox/docker-python-flask">2.7</a></td>
<td><a target="_blank" title="Blackfire 1.8" href="https://github.com/blackfireio/docker">1.8</a></td>
<td><a target="_blank" title="ELK stack" href="https://www.docker.elastic.co">5.x.y</a></td>
<td><a target="_blank" title="MailHog v1.0.0" href="https://github.com/mailhog/MailHog">v1.0.0</a></td>
@ -396,6 +398,7 @@ Additionally to the default stack, there are a variety of other services that ca
<td><a target="_blank" title="Varnish 4" href="https://github.com/devilbox/docker-varnish">4</a></td>
</tr>
<tr>
<td>...</td>
<td>...</td>
<td><a target="_blank" title="ELK stack" href="https://www.docker.elastic.co">6.x.y</a></td>
<td><a target="_blank" title="MailHog latest" href="https://github.com/mailhog/MailHog">latest</a></td>
@ -406,6 +409,7 @@ Additionally to the default stack, there are a variety of other services that ca
<td><a target="_blank" title="Varnish 5" href="https://github.com/devilbox/docker-varnish">5</a></td>
</tr>
<tr>
<td><a target="_blank" title="Python 3.7 " href="https://github.com/devilbox/docker-python-flask">3.7</a></td>
<td><a target="_blank" title="Blackfire 1.18.0" href="https://github.com/blackfireio/docker">1.18.0</a></td>
<td><a target="_blank" title="ELK stack" href="https://www.docker.elastic.co">7.x.y</a></td>
<td></td>
@ -416,6 +420,7 @@ Additionally to the default stack, there are a variety of other services that ca
<td><a target="_blank" title="Varnish 6" href="https://github.com/devilbox/docker-varnish">6</a></td>
</tr>
<tr>
<td><a target="_blank" title="Python 3.8 " href="https://github.com/devilbox/docker-python-flask">3.8</a></td>
<td><a target="_blank" title="Blackfire latest" href="https://github.com/blackfireio/docker">latest</a></td>
<td></td>
<td></td>
@ -650,8 +655,8 @@ The following tools will assist you on creating new projects easily as well as h
<td><code>pm2</code> is Node.js Production Process Manager with a built-in Load Balancer.</td>
</tr>
<tr>
<td>:wrench: <a href="https://github.com/brigade/scss-lint/">scss-lint</a></td>
<td><code>scss-lint</code> is a css/scss linter.</td>
<td>:wrench: <a href="https://github.com/stylelint/stylelint">stylelint</a></td>
<td><code>stylelint</code> is a css/scss linter.</td>
</tr>
<tr>
<td>:wrench: <a href="https://github.com/symfony/symfony-installer">symfony installer</a></td>
@ -821,7 +826,7 @@ PHP modules can be enabled or disabled on demand to reflect the state of your ta
You can also copy any custom modules into `mod/(php-fpm)-<VERSION>` and add a custom `*.ini` file to load them.
#### Supported Frameworks
#### Supported PHP Frameworks
As far as tested there are no limitations and you can use any Framework or CMS just as you would on your live environment. Below are a few examples of extensively tested Frameworks and CMS:
@ -867,12 +872,13 @@ As far as tested there are no limitations and you can use any Framework or CMS j
#### Supported reverse proxied applications
As far as tested there are no limitations and you can use any application that creates an open port.
These ports will be reverse proxied by the web server and even allow you to use valid HTTPS for them.
By the built-in autostart feature of the Devilbox you can ensure that your application automatically
These ports will be reverse proxied by the web server and even allow you to use **valid HTTPS** for them.
By the built-in **autostart feature** of the Devilbox you can ensure that your application automatically
starts up as soon as you run `docker-compose up`.
<a target="_blank" title="NodeJS" href="https://nodejs.org"><img width="64" style="width:64px;" src="docs/img/logo_tools/nodejs.png" alt="Devilbox"/></a>
<a target="_blank" title="Sphinx" href="https://www.sphinx-doc.org/en/stable/"><img width="64" style="width:64px;" src="docs/img/logo_tools/sphinx.png" alt="Devilbox"/></a>
<a target="_blank" title="NodeJS" href="https://nodejs.org"><img width="64" style="width:64px;" src="docs/img/logo_tools/nodejs.png" alt="NodeJS"/></a>
<a target="_blank" title="Python Flask" href="https://github.com/pallets/flask"><img width="64" style="width:64px;" src="docs/img/logo_tools/flask.png" alt="Python Flask"/></a>
<a target="_blank" title="Sphinx" href="https://www.sphinx-doc.org/en/stable/"><img width="64" style="width:64px;" src="docs/img/logo_tools/sphinx.png" alt="Sphinx"/></a>
> **Documentation:**<br/>
> [Setup reverse proxy NodeJs](https://devilbox.readthedocs.io/en/latest/examples/setup-reverse-proxy-nodejs.html) |

View File

@ -208,6 +208,34 @@ services:
depends_on:
- elastic
# -----------------------------------------------------------------------------------------------
# Python Flask
# -----------------------------------------------------------------------------------------------
# You can add more than one service here if you have multiple flask projects.
# Just duplicate the block and adjust service name, hostname and ip address.
flask1:
image: devilbox/python-flask:${PYTHON_VERSION:-3.8}-dev
hostname: flask1
ports:
- "${LOCAL_LISTEN_ADDR}${HOST_PORT_FLASK:-3000}:${FLASK_PORT:-3000}"
networks:
app_net:
ipv4_address: 172.16.238.250
volumes:
# Mount custom mass virtual hosting
- ${HOST_PATH_HTTPD_DATADIR}:/shared/httpd:rw${MOUNT_OPTIONS}
environment:
- FLASK_PROJECT=${FLASK_PROJECT}
- FLASK_PORT=${FLASK_PORT:-3000}
- FLASK_APP_DIR=${FLASK_APP_DIR:-htdocs}
- FLASK_APP_FILE=${FLASK_APP_FILE:-main.py}
- NEW_UID
- NEW_GID
depends_on:
- bind
- httpd
###
### Volumes

View File

@ -0,0 +1,33 @@
# vim: set ft=yaml:
---
version: '2.3'
services:
# -----------------------------------------------------------------------------------------------
# Python Flask
# -----------------------------------------------------------------------------------------------
# You can add more than one service here if you have multiple flask projects.
# Just duplicate the block and adjust service name, hostname and ip address.
flask1:
image: devilbox/python-flask:${PYTHON_VERSION:-3.8}-dev
hostname: flask1
ports:
- "${LOCAL_LISTEN_ADDR}${HOST_PORT_FLASK:-3000}:${FLASK_PORT:-3000}"
networks:
app_net:
ipv4_address: 172.16.238.250
volumes:
# Mount custom mass virtual hosting
- ${HOST_PATH_HTTPD_DATADIR}:/shared/httpd:rw${MOUNT_OPTIONS}
environment:
- FLASK_PROJECT=${FLASK_PROJECT}
- FLASK_PORT=${FLASK_PORT:-3000}
- FLASK_APP_DIR=${FLASK_APP_DIR:-htdocs}
- FLASK_APP_FILE=${FLASK_APP_FILE:-main.py}
- NEW_UID
- NEW_GID
depends_on:
- bind
- httpd

View File

@ -24,13 +24,11 @@ help:
# -------------------------------------------------------------------------------------------------
linkcheck2:
ifeq ($(wildcard file1),)
bash -c 'curl -Ss -o linkcheck https://raw.githubusercontent.com/cytopia/linkcheck/master/linkcheck 2>/dev/null'
else
bash -c 'curl -Ss -o linkcheck -z linkcheck https://raw.githubusercontent.com/cytopia/linkcheck/master/linkcheck 2>/dev/null'
endif
chmod +x linkcheck
./linkcheck -l -k -r 60 -t 30 -e rst _includes/
docker run \
--rm \
$$(tty -s && echo "-it" || echo) \
-v $(PWD):/data \
cytopia/linkcheck -l -k -r 60 -t 30 -e rst -c '200,204' _includes/
linkcheck:
docker run \

View File

@ -21,3 +21,5 @@
+-------------------------------------+-----------+-----------+----------------+
| ELK: Kibana | kibana | kibana | 172.16.238.242 |
+-------------------------------------+-----------+-----------+----------------+
| Python Flask | flask1 | flask1 | 172.16.238.250 |
+-------------------------------------+-----------+-----------+----------------+

View File

@ -13,11 +13,12 @@ However, each example also exists in its standalone file as shown below:
├── docker-compose.override.yml-elk
├── docker-compose.override.yml-mailhog
├── docker-compose.override.yml-ngrok
├── docker-compose.override.yml-python-flask
├── docker-compose.override.yml-rabbitmq
├── docker-compose.override.yml-solr
├── docker-compose.override.yml-varnish
└── README.md
0 directories, 8 files
0 directories, 10 files
.. seealso:: :ref:`custom_container_enable_all_additional_container`

View File

@ -60,6 +60,7 @@ In order to fully customize each container, refer to their own documentation sec
* :ref:`custom_container_enable_elk_stack`
* :ref:`custom_container_enable_mailhog`
* :ref:`custom_container_enable_ngrok`
* :ref:`custom_container_enable_python_flask`
* :ref:`custom_container_enable_rabbitmq`
* :ref:`custom_container_enable_solr`
* :ref:`custom_container_enable_varnish`

View File

@ -0,0 +1,149 @@
.. include:: /_includes/all.rst
.. include:: /_includes/snippets/__ANNOUNCEMENTS__.rst
.. _custom_container_enable_python_flask:
*********************************
Enable and configure Python Flask
*********************************
This section will guide you through getting Python Flask integrated into the Devilbox.
.. seealso::
* :ref:`example_setup_reverse_proxy_python_flask`
* :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
Python Flask settings
---------------------
In case of Python Flask, the file is ``compose/docker-compose.override.yml-python-flask``. 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-python-flask`` |
+-----------------------+----------------------------------------------------------------------------------------------------------+
| Container IP address | ``172.16.238.250`` |
+-----------------------+----------------------------------------------------------------------------------------------------------+
| Container host name | ``flask1`` |
+-----------------------+----------------------------------------------------------------------------------------------------------+
| Container name | ``flask1`` |
+-----------------------+----------------------------------------------------------------------------------------------------------+
| Mount points | ``data/www``` |
+-----------------------+----------------------------------------------------------------------------------------------------------+
| Exposed port | none |
+-----------------------+----------------------------------------------------------------------------------------------------------+
| Available at | Devilbox intranet via Reverse Proxy configuration |
+-----------------------+----------------------------------------------------------------------------------------------------------+
| Further configuration | :ref:`example_setup_reverse_proxy_python_flask` |
+-----------------------+----------------------------------------------------------------------------------------------------------+
Python Flask env variables
--------------------------
Additionally the following ``.env`` variables can be created for easy configuration:
+------------------------------+-------------------+----------------------------------------------------------------------------+
| Variable | Default value | Description |
+==============================+===================+============================================================================+
| ``FLASK_PROJECT`` | none | Specifies your Python Flask project dir in data/www. |
+------------------------------+-------------------+----------------------------------------------------------------------------+
| ``PYTHON_VERSION`` | ``3.8`` | Specifies the Python version to use for Flask. |
+------------------------------+-------------------+----------------------------------------------------------------------------+
Instructions
============
1. Copy docker-compose.override.yml
-----------------------------------
Copy the Python Flask 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-python-flask 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)
--------------------------------------
Python Flask 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
# Project directory in data/www
FLASK_PROJECT=my-flask
# Python version to choose
#PYTHON_VERSION=2.7
#PYTHON_VERSION=3.5
#PYTHON_VERSION=3.6
#PYTHON_VERSION=3.7
PYTHON_VERSION=3.8
.. seealso:: :ref:`env_file`
3. Configure Reverse Proxy
--------------------------
Before starting up the devilbox you will need to configure your python flask project and the
reverse proxy settings.
.. seealso:: :ref:`example_setup_reverse_proxy_python_flask`
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-flask1 docker-compose.override.yml
# Create .env variable
echo "# Project directory in data/www" > .env
echo "FLASK_PROJECT=my-flask" >> .env
echo "# Python version to choose" >> .env
echo "#PYTHON_VERSION=2.7" >> .env
echo "#PYTHON_VERSION=3.5" >> .env
echo "#PYTHON_VERSION=3.6" >> .env
echo "#PYTHON_VERSION=3.7" >> .env
echo "PYTHON_VERSION=3.8" >> .env
before starting up the devilbox you will need to configure your python flask project and the
reverse proxy settings.
.. seealso:: :ref:`example_setup_reverse_proxy_python_flask`

View File

@ -127,7 +127,7 @@ Add the following variables to ``.env`` and adjust them to your needs:
.. seealso:: :ref:`env_file`
4. Start the Devilbox
3. Start the Devilbox
---------------------
The final step is to start the Devilbox with RabbitMQ.

View File

@ -114,7 +114,7 @@ Add the following variables to ``.env`` and adjust them to your needs:
.. seealso:: :ref:`env_file`
4. Start the Devilbox
3. Start the Devilbox
---------------------
The final step is to start the Devilbox with Solr.

View File

@ -0,0 +1,449 @@
.. include:: /_includes/all.rst
.. include:: /_includes/snippets/__ANNOUNCEMENTS__.rst
.. _example_setup_reverse_proxy_python_flask:
********************************
Setup reverse proxy Python Flask
********************************
This example will walk you through adding a version specific Python Flask docker container,
creating a simple Flask hello world application and have its requirements specified in
``requirements.txt`` automatically installed. Once setup, your application will be ready via
``docker-compose up``, proxied to the web server and can be reached via valid HTTPS.
.. note::
This example is using an additional Docker image, so you are able to specify any Python version
you like and even be able to add multiple Docker images with different versions.
**Table of Contents**
.. contents:: :local:
Overview
========
The following configuration will be used:
+--------------+--------------------------+-------------+------------+-----------------------------------------------+
| Project name | VirtualHost directory | Database | TLD_SUFFIX | Project URL |
+==============+==========================+=============+============+===============================================+
| my-flask | /shared/httpd/my-flask | - | loc | http://my-flask.loc |br| https://my-flask.loc |
+--------------+--------------------------+-------------+------------+-----------------------------------------------+
.. note::
* Inside the Devilbox PHP container, projects are always in ``/shared/httpd/``.
* On your host operating system, projects are by default in ``./data/www/`` inside the
Devilbox git directory. This path can be changed via :ref:`env_httpd_datadir`.
The following Devilbox configuration is required:
+--------------+------------------------------------------------------------------------------------------------+
| Service | Implications |
+==============+================================================================================================+
| Webserver | Reverse proxy vhost-gen template need to be applied |
+--------------+------------------------------------------------------------------------------------------------+
| Python Flask | Docker Compose override file must be applied. |
+--------------+------------------------------------------------------------------------------------------------+
| ``.env`` | ``FLASK_PROJECT`` variable must be declared and set. |
+--------------+------------------------------------------------------------------------------------------------+
| ``.env`` | ``PYTHON_VERSION`` variable can be declared and set. |
+--------------+------------------------------------------------------------------------------------------------+
Additionally we will set the listening port of the Flask appliation to ``3000``.
.. seealso::
For a detailed overview about the Compose file see: :ref:`custom_container_enable_python_flask`
Walk through
============
It will be ready in ten simple steps:
1. Configure Python Flask project name and versoin
2. Enter the PHP container
3. Create a new VirtualHost directory
4. Create Flask hello world application
5. Symlink *virtual* docroot directory
6. Add reverse proxy vhost-gen config files
7. Copy Python Flask compose file
8. Setup DNS record
9. Restart the Devilbox
10. Visit http://my-flask.loc in your browser
1. Configure Python Flask project name and version
--------------------------------------------------
The Python Flask container will only serve a single project. In order for it to know where
to find your project, you will have to add an environment variable (``FLASK_PROJECT``),
telling it what the directory name of your project is.
Additionally you can define the Python version (``PYTHON_VERSION``) under which you want to run
your Flask project.
.. seealso:: Available Python versions can be seen here: https://github.com/devilbox/docker-python-flask
Add the following variable to the very end of your ``.env`` file:
.. code-block:: bash
:caption: .env
FLASK_PROJECT=my-flask
#PYTHON_VERSION=2.7
#PYTHON_VERSION=3.5
#PYTHON_VERSION=3.6
#PYTHON_VERSION=3.7
PYTHON_VERSION=3.8
2. Enter the PHP container
--------------------------
All work will be done inside the PHP container as it provides you with all required command line
tools.
Navigate to the Devilbox git directory and execute ``shell.sh`` (or ``shell.bat`` on Windows) to
enter the running PHP container.
.. code-block:: bash
host> ./shell.sh
.. seealso::
* :ref:`enter_the_php_container`
* :ref:`work_inside_the_php_container`
* :ref:`available_tools`
3. Create new VirtualHost directory
-----------------------------------
The vhost directory defines the name under which your project will be available. |br|
( ``<vhost dir>.TLD_SUFFIX`` will be the final URL ).
.. code-block:: bash
devilbox@php-7.0.20 in /shared/httpd $ mkdir my-flask
.. seealso:: :ref:`env_tld_suffix`
4. Create Flask hello world application
---------------------------------------
4.1 Add your code
^^^^^^^^^^^^^^^^^
.. code-block:: bash
# Navigate to your project directory
devilbox@php-7.0.20 in /shared/httpd $ cd my-flask
# Create a directory which will hold the source code
devilbox@php-7.0.20 in /shared/httpd/my-flask $ mkdir app
# Create the main.py file with your favourite editor
devilbox@php-7.0.20 in /shared/httpd/my-flask/app $ vi main.py
.. code-block:: python
:caption: main.py
"""Flask example application."""
from flask import Flask
app = Flask(__name__)
@app.route("/")
def index():
"""Serve the default index page."""
return "Hello World!"
if __name__ == "__main__":
"""Ensure Flask listens on all interfaces."""
app.run(host='0.0.0.0')
4.2 Add dependencies
^^^^^^^^^^^^^^^^^^^^
You can optionally add a ``requirements.txt`` file which will be read during startup. The Python
Flask container will then automatically install all Python libraries specified in that file.
.. code-block:: bash
# Navigate to your project directory
devilbox@php-7.0.20 in /shared/httpd $ cd my-flask
# Create and open the file with your favourite editor
devilbox@php-7.0.20 in /shared/httpd/my-flask $ vi requirements.txt
.. code-block:: ini
:caption: data/www/my-flask/requirements.txt
requests
5. Symlink *virtual* docroot directory
--------------------------------------
.. code-block:: bash
# Navigate to your project directory
devilbox@php-7.0.20 in /shared/httpd $ cd my-flask
# Create the docroot directory
devilbox@php-7.0.20 in /shared/httpd/my-flask $ ln -s app htdocs
.. seealso:: :ref:`env_httpd_docroot_dir`
6. Add reverse proxy vhost-gen config files
-------------------------------------------
6.1 Create vhost-gen template directory
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Before we can copy the vhost-gen templates, we must create the ``.devilbox`` template directory
inside the project directory.
.. code-block:: bash
# Navigate to your project directory
devilbox@php-7.0.20 in /shared/httpd $ cd my-flask
# Create the .devilbox template directory
devilbox@php-7.0.20 in /shared/httpd/my-flask $ mkdir .devilbox
.. seealso:: :ref:`env_httpd_template_dir`
6.2 Copy vhost-gen templates
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Now we can copy and adjust the vhost-gen reverse proxy files for Apache 2.2, Apache 2.4 and Nginx.
The reverse vhost-gen templates are available in ``cfg/vhost-gen``:
.. code-block:: bash
:emphasize-lines: 4,6,8
host> tree -L 1 cfg/vhost-gen/
cfg/vhost-gen/
├── apache22.yml-example-rproxy
├── apache22.yml-example-vhost
├── apache24.yml-example-rproxy
├── apache24.yml-example-vhost
├── nginx.yml-example-rproxy
├── nginx.yml-example-vhost
└── README.md
0 directories, 7 files
For this example we will copy all ``*-example-rproxy`` files into ``data/www/my-flask/.devilbox/``
(Inside container: ``/shared/httpd/my-flask/.devilbox``) to ensure this will work with all web servers.
.. code-block:: bash
host> cd /path/to/devilbox
host> cp cfg/vhost-gen/apache22.yml-example-rproxy data/www/my-flask/.devilbox/apache22.yml
host> cp cfg/vhost-gen/apache24.yml-example-rproxy data/www/my-flask/.devilbox/apache24.yml
host> cp cfg/vhost-gen/nginx.yml-example-rproxy data/www/my-flask/.devilbox/nginx.yml
6.3 Adjust ports and backend
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
By default, all vhost-gen templates will forward requests to port ``8000`` into the PHP container.
Our current example however uses port ``3000`` and backend IP ``172.16.238.250`` (as defined
in the Flask docker compose override file), so we must change that accordingly for all three
templates.
6.3.1 Adjust Apache 2.2 template
""""""""""""""""""""""""""""""""
Open the ``apache22.yml`` vhost-gen template in your project:
.. code-block:: bash
host> cd /path/to/devilbox
host> vi data/www/my-flask/.devilbox/apache22.yml
Find the two lines with ``ProxyPass`` and ``ProxyPassReverse`` and change the port from ``8000``
to ``3000`` as well as the backend server from ``php`` to ``172.16.238.250``.
.. code-block:: yaml
:caption: data/www/my-flask/.devilbox/apache22.yml
:emphasize-lines: 16,17
# ... more lines above ... #
###
### Basic vHost skeleton
###
vhost: |
<VirtualHost __DEFAULT_VHOST__:__PORT__>
ServerName __VHOST_NAME__
CustomLog "__ACCESS_LOG__" combined
ErrorLog "__ERROR_LOG__"
# Reverse Proxy definition (Ensure to adjust the port, currently '8000')
ProxyRequests On
ProxyPreserveHost On
ProxyPass / http://172.16.238.250:3000/
ProxyPassReverse / http://172.16.238.250:3000/
# ... more lines below ... #
6.3.2 Adjust Apache 2.4 template
""""""""""""""""""""""""""""""""
Open the ``apache24.yml`` vhost-gen template in your project:
.. code-block:: bash
host> cd /path/to/devilbox
host> vi data/www/my-flask/.devilbox/apache24.yml
Find the two lines with ``ProxyPass`` and ``ProxyPassReverse`` and change the port from ``8000``
to ``3000``
.. code-block:: yaml
:caption: data/www/my-flask/.devilbox/apache24.yml
:emphasize-lines: 16,17
# ... more lines above ... #
###
### Basic vHost skeleton
###
vhost: |
<VirtualHost __DEFAULT_VHOST__:__PORT__>
ServerName __VHOST_NAME__
CustomLog "__ACCESS_LOG__" combined
ErrorLog "__ERROR_LOG__"
# Reverse Proxy definition (Ensure to adjust the port, currently '8000')
ProxyRequests On
ProxyPreserveHost On
ProxyPass / http://172.16.238.250:3000/
ProxyPassReverse / http://172.16.238.250:3000/
# ... more lines below ... #
6.3.3 Adjust Nginx template
"""""""""""""""""""""""""""
Open the ``nginx.yml`` vhost-gen template in your project:
.. code-block:: bash
host> cd /path/to/devilbox
host> vi data/www/my-flask/.devilbox/nginx.yml
Find the lines with ``proxy_pass`` and change the port from ``8000`` to ``3000``
.. code-block:: yaml
:caption: data/www/my-flask/.devilbox/nginx.yml
:emphasize-lines: 18
# ... more lines above ... #
###
### Basic vHost skeleton
###
vhost: |
server {
listen __PORT____DEFAULT_VHOST__;
server_name __VHOST_NAME__;
access_log "__ACCESS_LOG__" combined;
error_log "__ERROR_LOG__" warn;
# Reverse Proxy definition (Ensure to adjust the port, currently '8000')
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://172.16.238.250:3000;
}
# ... more lines below ... #
7. Copy Python Flask compose file
---------------------------------
Python Flask comes with its own Docker container and can be added to the Devilbox stack via
the ``docker-compose.override.yml`` file. A fully functional template already exists in the
``compose/`` directory. All you will have to do is copy it over.
.. code-block:: bash
host> cd /path/to/devilbox
host> cp compose/docker-compose.override.yml-python-flask.yml docker-compose.override.yml
.. seealso:: :ref:`docker_compose_override_yml`
8. DNS record
-------------
If you **have** Auto DNS configured already, you can skip this section, because DNS entries will
be available automatically by the bundled DNS server.
If you **don't have** Auto DNS configured, you will need to add the following line to your
host operating systems ``/etc/hosts`` file (or ``C:\Windows\System32\drivers\etc`` on Windows):
.. code-block:: bash
:caption: /etc/hosts
127.0.0.1 my-flask.loc
.. seealso::
* :ref:`howto_add_project_hosts_entry_on_mac`
* :ref:`howto_add_project_hosts_entry_on_win`
* :ref:`setup_auto_dns`
9. Restart the Devilbox
-----------------------
Now for those changes to take affect, you will have to restart the Devilbox.
.. code-block:: bash
host> cd /path/to/devilbox
# Stop the Devilbox
host> docker-compose down
host> docker-compose rm -f
# Start the Devilbox
host> docker-compose up -d php httpd bind flask1
10. Open your browser
---------------------
All set now, you can visit http://my-flask.loc or https://my-flask.loc in your browser.
The Python Flask application has been started up automatically and the reverse proxy will direct all
requests to it.
Next steps
==========
.. include:: /_includes/snippets/examples/next-steps.rst

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -122,6 +122,7 @@ host is ready to be served with your custom domain.
custom-container/enable-elk-stack
custom-container/enable-mailhog
custom-container/enable-ngrok
custom-container/enable-python-flask
custom-container/enable-rabbitmq
custom-container/enable-solr
custom-container/enable-varnish
@ -200,6 +201,7 @@ host is ready to be served with your custom domain.
examples/setup-reverse-proxy-nodejs
examples/setup-reverse-proxy-sphinx-docs
examples/setup-reverse-proxy-python-flask
.. toctree::