Build a Web Stack
Let’s learn to configure our system for production in clean architecture.
Build a web application
Now that we’ve successfully containerized the tests, we can devise a production-ready setup of the whole application, running both a web server and a database in Docker containers.
To run a production-ready infrastructure, we need to put a WSGI server in front of the web framework and a web server in front of it. We’ll also need to run a database container that we’ll initialize only once.
The steps toward achieving a production-ready configuration aren’t complicated, and the final setup won’t be too different from what we already did for the tests. We need to follow these steps:
- Create a JSON configuration with environment variables suitable for production.
- Create a suitable configuration for Docker Compose, and configure the containers.
- Add commands to
manage.py
that allow us to control the processes.
Step 1: Create the JSON configuration file
We’ve created the config/production.json
file, which is similar to the one we created for the tests.
Get hands-on with 1400+ tech skills courses.