Deploying a Flask Application on Ubuntu 16.04

June 12, 2018

Context I have a simple flask app that displays data from a sqlite3 database. Nothing fancy.

Tutorials

  1. Serve Flask Apps with Gunicorn and Nginx
  2. Setup Firewall on Ubuntu 16.04
  3. Setup SSL with LetsEncrypt on Ubuntu 16.04

The Pieces

Based on searching online, the most battle-tested deployment tools right now seem to be:

  1. Gunicorn – application server
  2. Systemd – among other things, it can manage custom services (e.g. gunicorn server)
  3. Nginx – reverse proxy

There were a few interesting alternatives (e.g. cherrypy, tornado, bjoern etc.) that could have replaced 1 or 2 of the components above. But lack beginner-friendly documentation and low number of Stack Overflow questions for these alternatives prevented me from trying these out. Maybe next project.

Assuming you already have a virtualenv, with all requirements above, follow the tutorials above to deploy a flask app.

I'll tell you when I post stuff.

Subscribe to get my latest posts by email.