This is a Django-based microservice application containerized using Docker. It includes PostgreSQL, Redis, Celery for background tasks and Gunicorn as the production WSGI server. The infrastructure is managed with Terraform and deployed on AWS EC2.
http://13.48.146.116:8000
http://13.48.146.116:8000/swagger
Deployed on an AWS EC2 instance using Gunicorn + Whitenoise
- Django 5.2 + DRF
- PostgreSQL (via Docker)
- Redis + Celery for async task processing
- Swagger (drf-yasg) for API documentation
- Docker Compose for local orchestration
- Gunicorn as production WSGI server
- Terraform for AWS infrastructure (EC2, Security Groups, CloudWatch, S3)
- GitHub Actions CI/CD deployment to EC2
- Docker
- Docker Compose
- Terraform (if managing infrastructure)
git clone https://github.com/ALASHI1/django-mircoservice.git
cd django-mircoserviceCreate a .env file in the root directory with the following content:
POSTGRES_DB=your_db
POSTGRES_USER=your_user
POSTGRES_PASSWORD=your_passworddocker-compose up -d --build- Django: http://localhost:8000
- Swagger UI: http://localhost:8000/swagger/
- Stores Terraform state in versioned S3 bucket
- Amazon Linux 2023 (ARM)
- Docker, Docker Compose installed via GitHub Actions
- Security group exposes ports: 22 (SSH), 80, 443, 8000
- CloudWatch + IAM Role for logs
Run Terraform:
terraform init
terraform apply- Deploys to EC2 on every push to
main - Uses
appleboy/ssh-actionto SSH and redeploy Docker containers
| Service | Port | Description |
|---|---|---|
| Django (Gunicorn) | 8000 | Web API |
| PostgreSQL | 5432 | Relational database |
| Redis | 6379 | Broker for Celery |
| Celery | — | Background task worker |
- Swagger UI available at
/swagger/ - Endpoints organized with
drf-yasg
- Go to the url
/swagger/ - Signup and login to get the token
- Click the Authorize button on the top right corner
- Enter the token in the format
Token <token>and click Authorize ('Dont forget the "Token" prefix') - Then you can use the APIs with the token
See ARCHITECTURE.md for in-depth system design and infrastructure details.