Beginner’s Guide to Using Databases with Python: Postgres, SQLAlchemy, and Alembic
Using Docker for Flask Application Development
Introduction
I’ve been using Docker for my staging and production environments, but I’ve recently figured out how to make Docker work for my development environment as well.
When I work on my personal web applications, I have three environments:
* Production – the actual application that serves the users
* Staging – a replica of the production environment on my laptop
* Development – the environment where I write source code, unit/integration test, debug, integrate, etc.While having a development environment that is significantly different (ie. not using Docker) from the staging/production environments is not an issue, I’ve really enjoyed the switch to using Docker for development.
The key aspects that were important to me when deciding to switch to Docker for my development environment were:
* Utilize the Flask development server instead of a production web server (Gunicorn)
* Allow easy access to my database (Postgres)
* Maintain my unit/integration testing capabilityThis blog post shows how to configure Docker and Docker Compose for creating a development environment that you can easily use on a day-to-day basis for developing a Flask application.
For reference, my Flask project that is the basis for this blog post can be found on GitLab.