Docker-Flask is about Flask project organization and running it in a docker-compose containers. Application has a basic user model with authentication(passwords hashing), database migrations, administration interface, celery asynchronous tasks, manage script, debug toolbar, bootstrap starter templates.
-
Docker and Docker-Compose for managing project
-
Flask application running on UWSGI with next extensions:
-
Celery asynchronous tasks application
-
Supervisor initialize system for managing python applications
-
PostgreSQL object-relational database
-
Nginx frontend web server for production mode
-
Redis key-value storage server
-
RabbitMQ AMPQ server(for production only)
- install docker https://github.com/docker/docker
- install docker-compose https://docs.docker.com/compose/install
docker-compose pull
docker-compose build flaskapp
To start applications with development environment:
docker-compose up -d
To start applications with production environment (first copy configuration file and edit it)
cp app/settings/prod.py.repl app/settings/prod.py
docker-compose --file docker-compose.prod.yml up -d
To initialize, create migration and upgrade your database:
docker exec -it dockerflask_flaskapp_1 bash -c "python manage.py create_db"
To run ipython debug flaskapp shell:
docker exec -it dockerflask_flaskapp_1 bash -c "python manage.py shell"
To create admin user:
docker exec -it dockerflask_flaskapp_1 bash -c "python manage.py create_user -a"
To initialize migrations:
docker exec -it dockerflask_flaskapp_1 bash -c "python manage.py db init"
To create a migration:
docker exec -it dockerflask_flaskapp_1 bash -c "python manage.py db migrate"
To upgrade your database with migration:
docker exec -it dockerflask_flaskapp_1 bash -c "python manage.py db upgrade"
docker-compose stop && docker-compose rm -f
To check standard logs:
docker-compose logs
Access the application containers shell:
docker exec -it dockerflask_flaskapp_1 bash
docker exec -it dockerflask_flaskapp_1 bash -c "python manage.py runtests"