backend-service is a backend system built using Django Rest Framework. It is containerized with Docker, utilizes JWT for secure authentication, and relies on PostgreSQL as the database. The project is designed to run in production behind an Nginx server with deployment configured via Docker Compose. CI/CD is set up with GitHub Actions to automate testing, image versioning, and deployment to an AWS t2.micro instance.
- Framework: Django Rest Framework
- Authentication: JWT
- Database: PostgreSQL
- Server: Nginx
- Containerization: Docker
- Deployment: Docker Compose
- Cloud server: AWS instance
- CI/CD Tool: GitHub Actions
- Image Storage: Docker Hub (with versioning)
- Tests:
- Unit Tests: Written using
unittest - Linter: Code checked with
flake8 - Code Quality: Analyzed with GitHub CodeQL
- Unit Tests: Written using
- Trigger: On push to the
mainbranch. - CI Steps:
- Run Linter (
flake8) - Execute Unit Tests (
unittest)
- Run Linter (
- Build and Push Image: If all three test passes, GitHub Actions builds a Docker image, tags it with a version, and pushes it to Docker Hub.
- Deploy to AWS:
- GitHub Actions SSHs into an AWS t2.micro instance.
- Pulls the latest Docker image from Docker Hub.
- Runs the container on the AWS instance using a Docker Compose file.
-
Clone the repository:
git clone https://github.com/haiderkn/backend-service.git cd backend-service -
Start the containers with Docker Compose:
docker compose -f docker-compose-localdev.yml up --build
-
Access the API at
http://localhost:<port>.
-
Unit Tests:
python manage.py test -
Linting:
flake8 .
- Deployment Server: AWS t2.micro instance
- Method: CI/CD workflow on merge to
mainruns linter and unit tests, builds and tags Docker image, pushes it to Docker Hub, SSHs into AWS, pulls the image, and deploys it with Docker Compose.
For any queries or contributions, please open an issue or submit a pull request.
- automate server setup using Ansible