A stripped-down example of a dockerized Flask web application,
based on the official Docker image for Python 🐍, served by Gunicorn 🦄
Table of Contents
The Makefile can be used to easily manage the app using GNU Make (on Linux, macOS and Windows (Cygwin)).
make reinit
will re(build)/re(run) the image/container (named - literally - appname:latest
)
and serve an instance of the app via: http://localhost:5000/appname
It's a handy shortcut that you can use to reload the app after code has changed.
For more fine-grained control, please have a look at the included Makefile.
make lock
will update your Pipfile dependencies and create a Pipfile.lock thereafter
so that the build process is reproducible and deterministic, thus production-ready.
Note that only MINOR and PATCH versions are udpated automatically so as to not break something.*
*) assuming that the Python packages are following Semantic Versioning best practices.
The fAPP folder contains the Flask app code itself. It's just a skeleton, but you can easily add, e.g.,
- more routes,
- jQuery,
- Bootstrap,
- etc.
The (empty) public folder is meant to be used to serve a favicon.ico
and/or webclip.png
(a.k.a. apple-touch-icon
). The code is already there (in views.py and index.html), just uncomment it and place the appropriate file(s) inside the public
folder (and remove the .gitignore
file which you will then no longer need).
Use the custom.css and custom.js files to easily add some custom CSS and JavaScript code to your app.