Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Project Setup

A complete, production-ready Django project boilerplate using Docker Compose. Everything you need to go from zero to a fully running Django stack — database, async tasks, monitoring, reverse proxy, and caching — all in a single docker-compose up.

⭐ Use this as a starting point for your own Django projects.


Stack

Service Technology Purpose
Web App Django 5 + uWSGI WSGI application server
Reverse Proxy Nginx Routes traffic, caches static/media files
Database PostgreSQL Primary relational database
DB Admin pgAdmin 4 PostgreSQL browser-based GUI
Cache / Broker Redis Celery message broker + Django cache
Task Queue Celery Async background task processing
Scheduler Celery Beat Periodic/scheduled task runner
Task Monitor Flower Real-time Celery monitoring dashboard
Metrics Prometheus Client App metrics collection

Project Structure

Django-project-setup/
├── app/              # Django application code
├── proxy/            # Nginx configuration (reverse proxy + static caching)
├── scripts/          # Entrypoint and helper shell scripts
├── Dockerfile        # Django + uWSGI image
├── docker-compose.yml
├── requirements.txt
├── .env              # Environment variables
└── .dockerignore

Quick Start

Prerequisites

1. Clone the Repository

git clone https://github.com/LokRaj-Vuppu/Django-project-setup.git
cd Django-project-setup

2. Configure Environment Variables

Edit the .env file with your settings:

SECRET_KEY=your_django_secret_key
DEBUG=False

POSTGRES_DB=django_db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=password
POSTGRES_HOST=db
POSTGRES_PORT=5432

REDIS_URL=redis://redis:6379/0

CELERY_BROKER_URL=redis://redis:6379/0
CELERY_RESULT_BACKEND=django-db

PGADMIN_DEFAULT_EMAIL=admin@admin.com
PGADMIN_DEFAULT_PASSWORD=admin

3. Build and Start All Services

docker compose build
docker compose up

Or run in detached mode:

docker compose up -d

4. Apply Migrations

docker compose exec web python manage.py migrate

5. Create Superuser

docker compose exec web python manage.py createsuperuser

6. Collect Static Files

docker compose exec web python manage.py collectstatic --no-input

Service URLs

Service URL
Django App http://localhost
pgAdmin http://localhost:5050
Flower (Celery Monitor) http://localhost:5555

Architecture

Client Request
      │
      ▼
   Nginx (port 80)
      │  ├── /static/ → serves cached static files directly
      │  └── /media/  → serves cached media files directly
      │
      ▼
   uWSGI (Django WSGI)
      │
      ├──► PostgreSQL (psycopg2)
      ├──► Redis (cache + Celery broker)
      │
      ▼
Celery Worker ◄──── Redis Broker
      │
Celery Beat (Periodic Scheduler)
      │
   Flower (Monitoring UI)

Useful Commands

# View logs for a specific service
docker compose logs -f web
docker compose logs -f celery

# Run Celery worker manually
docker compose exec web celery -A app worker -l info

# Run Celery Beat manually
docker compose exec web celery -A app beat -l info

# Stop all services and remove volumes
docker compose down -v

# Rebuild after code changes
docker compose up --build

Key Differences from django-kubernetes

This repo uses uWSGI as the WSGI server (instead of Gunicorn) and is designed for Docker Compose deployment only. For a Kubernetes-based setup with the same stack, see django-kubernetes.


Author

LokRaj VuppuGitHub

About

Complete production-ready Django project boilerplate with Docker — PostgreSQL, pgAdmin, Redis, Celery, Celery Beat, Flower, uWSGI, and Nginx with static/media caching

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Contributors

Languages