Skip to content

BigTava/flask-docker-setup

Repository files navigation

Flask Docker Setup

Tutorial: Dockerizing Flask with Postgres, Gunicorn, and Nginx

Objectives

  • Configure Flask to run on Docker with Postgres;
  • Add Nginx and Gunicorn for production environment;
  • Serve static and user-uploaded media files via Nginx;

How to use this setup?

Development

  1. Build the images and run the containers:
$ docker-compose up -d --build
$ docker-compose -f docker-compose.prod.yml up -d --build
$ docker-compose -f docker-compose.prod.yml exec web python manage.py create_db
  1. Bring down containers
docker-compose down -v
  1. Ensure App is running http://localhost:1337

  2. Upload Asset http://localhost:1337/upload.

  3. View Asset http://localhost:1337/media/IMAGE_FILE_NAME.

Production

  1. Set up a fully managed database service -- like RDS or Cloud SQL -- rather than managing your own Postgres instance within a container.
  2. Use a non-root user for the db and nginx services for security reasons

About

My implementation of Dockerizing Flask with Postgres, Gunicor, and Nginx provided by Michael Herman

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors