This project demonstrates a comprehensive DevOps pipeline including CI/CD using GitHub Actions, Docker containerization, cloud deployment on AWS, and real-time monitoring with Prometheus. The application is a simple Flask-based REST API that provides user information and is monitored using Prometheus.
.
├── ci-cd
│ └── github-actions.yml # GitHub Actions for CI/CD
├── cloud-deployment
│ └── aws
│ ├── command.txt # Terraform deployment commands
│ ├── main.tf # AWS resource definitions
│ ├── outputs.tf # Terraform output variables
│ └── variables.tf # Terraform input variables
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # Docker image definition
├── prometheus
│ └── prometheus.yml # Prometheus configuration
├── scripts
│ ├── build.sh # Docker image build script
│ ├── deploy.sh # Terraform deployment script
│ ├── docker_deploy.sh # Docker Compose deployment script
│ └── test.sh # Test execution script
├── src
│ ├── app.py # Flask application
│ ├── models.py # Data model definitions
│ ├── routes.py # API route handlers
│ └── utils.py # Utility functions
└── tests
└── test_app.py # Unit tests
- Docker
- Docker Compose
- Terraform
- AWS CLI configured with proper access
- Python 3.9
-
Clone the repository:
git clone https://github.com/yourusername/devops-assignment.git cd devops-assignment -
Install required Python packages:
pip install -r requirements.txt
python src/app.pyAccess the application at: http://localhost:5000
docker-compose up --build -dAccess the application at: http://localhost:5000
Access Prometheus at: http://localhost:9090
- Prometheus metrics are exposed at
http://localhost:8000/metrics - Access Prometheus dashboard:
http://localhost:9090
-
CI/CD is triggered on every push or pull request to the
mainbranch. -
Pipeline stages:
- Build: Builds and pushes the Docker image.
- Test: Runs unit tests.
- Deploy: Deploys to AWS using Terraform.
-
Initialize Terraform:
terraform init
-
Deploy the infrastructure:
./scripts/deploy.sh
-
Check the public IP of the deployed instance:
terraform output instance_public_ip
Run the test suite:
./scripts/test.sh- Home:
GET / - List Users:
GET /users - User Details:
GET /users/<user_id>
-
Check Docker logs:
docker logs <container_name>
-
Restart Docker Compose:
docker-compose restart
-
Check Prometheus metrics:
curl http://localhost:8000/metrics
Feel free to submit issues and feature requests. Pull requests are welcome.