This hands-on guide walks you through setting up a production-like environment for a Django web application using Docker containers for the web server (Gunicorn), reverse proxy (Nginx), and database (PostgreSQL).


Prerequisites

Before you begin, ensure you have the following installed and configured:


Part 1: Prepare Python Environment with pyenv

We start by setting up a clean and isolated Python environment on your host machine using pyenv. This is good practice for local development and helps ensure you can install the specific Python version and libraries needed before transferring them into the Docker image.


Part 2: Create a Django Project Locally

Now, we'll create a basic Django project within the prepared Python environment.