This project demonstrates deploying a machine learning model as a FastAPI web service on AWS EC2 using Docker and GitHub Actions for CI/CD. The API predicts restaurant tips based on customer and bill information.
- FastAPI-based REST API for tip prediction
- Model loaded from AWS S3
- Dockerized application for easy deployment
- Automated CI/CD pipeline with GitHub Actions
- Secure deployment to AWS EC2
GET /— Health checkGET /info— Project informationGET /view— Sample people dataPOST /add— Add two numbersPOST /predict— Predict restaurant tip
{
"total_bill": 25.5,
"sex": "Male",
"smoker": "No",
"day": "Sat",
"time": "Dinner",
"size": 3
}-
Clone the repository
git clone https://github.com/abhi227070/CICD-Model-Deployement-AWS.git cd CICD-Model-Deployement-AWS -
Install dependencies
pip install -r requirements.txt
-
Configure AWS credentials
- Create a
.envfile:AWS_ACCESS_KEY=your-access-key AWS_SECRET_KEY=your-secret-key - Ensure your model file (
tips_rf_model.pkl) is in the specified S3 bucket.
- Create a
-
Run locally
uvicorn app:app --reload
-
Build Docker image
docker build -t tip-app . -
Run Docker container
docker run -d -p 8000:8000 --env-file .env --name tip-app tip-app
- Automated deployment to AWS EC2 via GitHub Actions (
.github/workflows/deploy.yml) - On push to
main, the workflow builds and deploys the Docker container to EC2
.
├── app.py
├── requirements.txt
├── Dockerfile
├── .env
├── .gitignore
├── .dockerignore
├── .github/
│ └── workflows/
│ └── deploy.yml
├── README.md
└── ...
MIT License. See LICENSE for details.
Abhijeet Maharana