A Django REST API backend for the AWS ECS application.
- Django REST Framework
- PostgreSQL/MySQL database support
- Docker containerization
- Health check endpoints
- CORS support for frontend integration
- Environment-based configuration
- AWS ECS deployment ready
- Python 3.11+
- Docker (optional)
- Clone the repository:
git clone git@github.com:sabiut/aws-ecs-backend-django.git
cd aws-ecs-backend-django
- Create virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration
- Run migrations:
python manage.py migrate
- Create superuser (optional):
python manage.py createsuperuser
- Run development server:
python manage.py runserver
The API will be available at http://localhost:8000
- Build and run with Docker:
docker build -t django-backend .
docker run -p 8080:8080 django-backend
GET /health/
- Simple health checkGET /api/
- API rootGET /api/health/
- Detailed health checkGET /admin/
- Django admin interface
Copy .env.example
to .env
and configure:
# Django settings
DEBUG=False
SECRET_KEY=your-secret-key-here
ALLOWED_HOSTS=localhost,127.0.0.1,your-domain.com
# Database settings
DB_HOST=your-database-host
DB_NAME=your-database-name
DB_USER=your-database-user
DB_PASSWORD=your-database-password
DB_PORT=3306
The application supports both SQLite (development) and MySQL/PostgreSQL (production):
- SQLite: Used when
DB_HOST
is not set - MySQL: Used when
DB_HOST
is configured
This application is configured for deployment to AWS ECS using the CI/CD pipeline. The GitHub Actions workflow will:
- Run tests and linting
- Build Docker image
- Push to Amazon ECR
- Deploy to ECS Fargate
- Perform health checks
Run tests:
python manage.py test
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
MIT License