Skip to content

sabiut/aws-ecs-backend-django

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Backend API

A Django REST API backend for the AWS ECS application.

Features

  • Django REST Framework
  • PostgreSQL/MySQL database support
  • Docker containerization
  • Health check endpoints
  • CORS support for frontend integration
  • Environment-based configuration
  • AWS ECS deployment ready

Local Development

Prerequisites

  • Python 3.11+
  • Docker (optional)

Setup

  1. Clone the repository:
git clone git@github.com:sabiut/aws-ecs-backend-django.git
cd aws-ecs-backend-django
  1. Create virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up environment variables:
cp .env.example .env
# Edit .env with your configuration
  1. Run migrations:
python manage.py migrate
  1. Create superuser (optional):
python manage.py createsuperuser
  1. Run development server:
python manage.py runserver

The API will be available at http://localhost:8000

Docker Development

  1. Build and run with Docker:
docker build -t django-backend .
docker run -p 8080:8080 django-backend

API Endpoints

  • GET /health/ - Simple health check
  • GET /api/ - API root
  • GET /api/health/ - Detailed health check
  • GET /admin/ - Django admin interface

Environment Variables

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

Database Configuration

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

Deployment

This application is configured for deployment to AWS ECS using the CI/CD pipeline. The GitHub Actions workflow will:

  1. Run tests and linting
  2. Build Docker image
  3. Push to Amazon ECR
  4. Deploy to ECS Fargate
  5. Perform health checks

Testing

Run tests:

python manage.py test

Contributing

  1. Create a feature branch
  2. Make your changes
  3. Add tests
  4. Submit a pull request

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages