Skip to content

leoleiden/production-ready-django-docker

Repository files navigation

🐳 Production-Ready Django Dockerization

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.

⚙️ DevOps Features & Best Practices

  • 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=1 to 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 RUN instructions, ensuring the container is completely ready to serve traffic upon startup.
  • Dynamic Base Images: Utilized ARG instructions to allow flexible Python versioning during the build process.

📊 Proof of Execution

Successfully built and tested locally. The multi-stage build completes efficiently, and the container serves the Django application on the exposed port.

Build Process & Container Execution

Terminal Build

Live Application

App Browser

🚀 Getting Started

Prerequisites

  • Docker installed on your machine.

Run via Docker Hub

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.0

Build Locally

To 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.0

Accessing the Application

Once 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.

About

Containerized Django application demonstrating Docker best practices, multi-stage builds, and GitHub Actions CI integration.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors