Skip to content

Enable and configure Python Flask

Enable and configure Python Flask

This section will guide you through getting Python Flask integrated into the Devilbox.

* example-setup-reverse-proxy-python-flask * custom-container-enable-all-additional-container * docker-compose-override-yml-how-does-it-work

Overview

Available overwrites

The Devilbox ships various example configurations to overwrite the default stack. Those files are located under compose/ in the Devilbox git directory.

docker-compose.override.yml-all has all examples combined in one file for easy copy/paste. However, each example also exists in its standalone file as shown below:

Terminal window
host> tree -L 1 compose/
compose/
├── docker-compose.override.yml-all
├── docker-compose.override.yml-blackfire
├── docker-compose.override.yml-elk
├── docker-compose.override.yml-mailhog
├── docker-compose.override.yml-meilisearch
├── docker-compose.override.yml-ngrok
├── docker-compose.override.yml-php-community
├── 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, 10 files

custom-container-enable-all-additional-container

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.

WhatHow and where
Example compose filecompose/docker-compose.override.yml-all or br compose/docker-compose.override.yml-python-flask
Container IP address172.16.238.250
Container host nameflask1
Container nameflask1
Mount pointsdata/www`
Exposed portnone
Available atDevilbox intranet via Reverse Proxy configuration
Further configurationexample-setup-reverse-proxy-python-flask

Python Flask env variables

Additionally the following .env variables can be created for easy configuration:

VariableDefault valueDescription
FLASK_PROJECTnoneSpecifies your Python Flask project dir in data/www.
PYTHON_VERSION3.8Specifies 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).

Terminal window
host> cp compose/docker-compose.override.yml-python-flask docker-compose.override.yml

* docker-compose-override-yml * add-your-own-docker-image * 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:

Terminal window
# 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

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.

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:

Terminal window
# 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.

example-setup-reverse-proxy-python-flask