Architected and containerized by Leonid Lachmann
This repository demonstrates the containerization of a monolithic Django web application using best practices in Docker. The project is packaged into a lightweight, multi-stage Docker image, ensuring a reproducible and isolated environment.
- Multi-stage Docker Build: Separated the build environment (compiling dependencies into wheels) from the runtime environment to significantly reduce the final image size and enhance security.
- Environment Optimization: Configured
ENV PYTHONUNBUFFERED=1to ensure Python output is piped directly to stdout/stderr for proper container log aggregation. - Build-time Database Migrations: Configured SQLite database migrations to execute during the image build phase via
RUNinstructions, ensuring the container is completely ready to serve traffic upon startup. - Dynamic Base Images: Utilized
ARGinstructions to allow flexible Python versioning during the build process.
Successfully built and tested locally. The multi-stage build completes efficiently, and the container serves the Django application on the exposed port.
- Docker installed on your machine.
You can pull the pre-built image directly from my personal Docker Hub repository:
docker pull your_dockerhub_username/todoapp:1.0.0
docker run -p 8080:8080 your_dockerhub_username/todoapp:1.0.0To build the image locally from the source code:
# 1. Clone the repository
git clone [https://github.com/leoleiden/production-ready-django-docker.git](https://github.com/leoleiden/production-ready-django-docker.git)
cd production-ready-django-docker
# 2. Build the Docker image
docker build -t todoapp:1.0.0 .
# 3. Run the container
docker run -p 8080:8080 todoapp:1.0.0Once the container is running, open your web browser and navigate to:
- Landing Page:
http://localhost:8080/ - API Endpoint:
http://localhost:8080/api/
A special thanks to Illia Losiev for his valuable support, guidance, and code reviews during the initial development of this infrastructure setup.

