A production-ready Django application boilerplate with Celery for asynchronous task processing, containerized with Docker for easy development and deployment.
- Django: Web framework for rapid development
- Celery: Distributed task queue for background processing
- Redis: Message broker and result backend
- PostgreSQL: Production-ready database
- Docker: Containerized environment for consistency
- Flower: Web-based tool for monitoring Celery tasks
- Gunicorn: WSGI HTTP Server for production
- Health Checks: Built-in health monitoring
- Makefile: Simplified command execution
┌─────────────────┐ ┌──────────────┐ ┌─────────────┐
│ Django App │────│ Redis │────│ Celery │
│ (Port 8000) │ │ (Port 6379) │ │ Worker │
└─────────────────┘ └──────────────┘ └─────────────┘
│ │ │
│ ┌──────────────┐ │
└──────────────│ PostgreSQL │───────────┘
│ │
└──────────────┘
│
┌──────────────────┐
│ Celery Beat │
│ (Scheduler) │
└──────────────────┘
│
┌──────────────────┐
│ Flower Monitor │
│ (Port 5555) │
└──────────────────┘
- Docker & Docker Compose
- Make (optional, for using Makefile commands)
git clone https://github.com/yourusername/django-celery-boilerplate.git
cd django-celery-boilerplateCreate a .env file in the project root:
cp .env.sample .envUsing Makefile (recommended):
# Build Docker images
make build
# Start all services
make up
# View logs
make logs
Or using Docker Compose directly:
# Build images
docker-compose -f docker/docker-compose.yml build
# Start services
docker-compose -f docker/docker-compose.yml up -d
# View logs
docker-compose -f docker/docker-compose.yml logs -f
- Django App:
http://localhost:8000 - Flower (Celery Monitor):
http://localhost:5555 - Health Check:
http://localhost:8000/health/
django-celery-boilerplate/
├── app/ # Django application code
│ ├── manage.py
│ ├── app/
│ │ ├── settings.py
│ │ ├── celery.py
│ │ └── wsgi.py
│ └── ...
├── docker/ # Docker configuration
│ ├── Dockerfile
│ └── docker-compose.yml
├── .env.example # Environment variables template
├── .gitignore
├── Makefile # Development commands
├── requirements.txt # Python dependencies
├── requirements.dev.txt # Development dependencies
└── README.md
-
Django Application (
app) -
Celery Worker (
celery) -
Celery Beat (
celery-beat) -
Flower (
flower) -
Redis (
redis) -
PostgreSQL (
db)
# Using Make
make test
# Using Docker Compose
docker-compose -f docker/docker-compose.yml exec app python manage.py test# All services
make logs
# Specific service
docker-compose -f docker/docker-compose.yml logs -f app
docker-compose -f docker/docker-compose.yml logs -f celery- Django:
http://localhost:8000/health/ - Redis: Built-in Redis ping
- PostgreSQL: Connection test every 5 seconds
Access http://localhost:5555 using username: admin, password: admin to monitor:
- Active tasks
- Task history
- Worker status
- Task statistics
NOTE: You change the flower auth credentials in the docker/docker-compose.dev.yml file
- Environment Variables: Ensure all production environment variables are set
- Static Files: Run
make collectstatic - Database: Run migrations with
make migrate - SSL/TLS: Configure reverse proxy (
Nginx) for HTTPS - Monitoring: Set up proper logging and monitoring solutions
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (git commit -m 'Add amazing feature')
- Push to the branch (git push origin feature/amazing-feature)
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
