Skip to content

Commit 9325504

Browse files
changes in ci cd
1 parent 89116ab commit 9325504

File tree

2 files changed

+50
-13
lines changed

2 files changed

+50
-13
lines changed

.github/workflows/deploy.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,50 @@ on:
55
branches:
66
- main
77

8+
env:
9+
IMAGE_TAG: ghcr.io/${{ github.repository_owner }}/end-to-end-mlops-food-delivery-time-prediction-project:latest
10+
811
jobs:
912
build-and-deploy:
1013
runs-on: ubuntu-latest
1114
steps:
1215
- name: Checkout code
13-
uses: actions/checkout@v2
16+
uses: actions/checkout@v3
1417

1518
- name: Set up Docker Buildx
16-
uses: docker/setup-buildx-action@v1
19+
uses: docker/setup-buildx-action@v2
1720

1821
- name: Log in to GitHub Container Registry
19-
uses: docker/login-action@v1
22+
uses: docker/login-action@v2
2023
with:
2124
registry: ghcr.io
2225
username: ${{ github.actor }}
2326
password: ${{ secrets.GITHUB_TOKEN }}
2427

25-
- name: Build Docker image
26-
uses: docker/build-push-action@v2
28+
- name: Build Docker image for testing
29+
uses: docker/build-push-action@v4
2730
with:
2831
context: .
29-
load: true # Load image for testing
30-
tags: ghcr.io/${{ github.repository }}:latest
32+
load: true # Load image locally for testing
33+
tags: ${{ env.IMAGE_TAG }}
3134

3235
- name: Run tests
3336
run: |
34-
docker run --rm ghcr.io/${{ github.repository }}:latest python -m unittest tests/test_routes.py -v
37+
docker run --rm ${{ env.IMAGE_TAG }} python -m unittest tests/test_routes.py -v
3538

3639
- name: Push Docker image
37-
uses: docker/build-push-action@v2
40+
uses: docker/build-push-action@v4
3841
with:
3942
context: .
4043
push: true
41-
tags: ghcr.io/${{ github.repository }}:latest
44+
tags: ${{ env.IMAGE_TAG }}
4245

4346
- name: Generate Dockerrun.aws.json
4447
run: |
4548
echo '{
4649
"AWSEBDockerrunVersion": "1",
4750
"Image": {
48-
"Name": "ghcr.io/${{ github.repository }}:latest",
51+
"Name": "${{ env.IMAGE_TAG }}",
4952
"Update": "true"
5053
},
5154
"Ports": [
@@ -56,11 +59,11 @@ jobs:
5659
}' > Dockerrun.aws.json
5760

5861
- name: Configure AWS credentials
59-
uses: aws-actions/configure-aws-credentials@v1
62+
uses: aws-actions/configure-aws-credentials@v2
6063
with:
6164
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
6265
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
63-
aws-region: us-east-1 # Adjust to your preferred region
66+
aws-region: us-east-1
6467

6568
- name: Upload Dockerrun.aws.json to S3
6669
run: aws s3 cp Dockerrun.aws.json s3://food-delivery-deploy/Dockerrun.aws.json

instruction.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## Deployment Instructions
2+
3+
This project uses GitHub Actions to deploy a Dockerized Flask application to AWS Elastic Beanstalk. Follow these steps to deploy it on your AWS account:
4+
5+
### Prerequisites
6+
- A GitHub account and repository (fork or clone this repo).
7+
- An AWS account with access to Elastic Beanstalk and S3.
8+
- Docker installed locally (optional, for testing).
9+
10+
### Steps
11+
1. **Set Up AWS Resources**
12+
- **S3 Bucket:**
13+
- Create an S3 bucket named `food-delivery-deploy` in your AWS account.
14+
- **Elastic Beanstalk:**
15+
- Go to the Elastic Beanstalk console.
16+
- Create an application named `food-delivery-prediction`.
17+
- Create an environment named `food-delivery-prod` with the "Docker" platform (use a sample app initially).
18+
- **IAM User:**
19+
- Create an IAM user with `AWSElasticBeanstalkFullAccess` and `AmazonS3FullAccess` permissions.
20+
- Note the Access Key ID and Secret Access Key.
21+
22+
2. **Configure GitHub Secrets**
23+
- In your GitHub repository, go to **Settings > Secrets and variables > Actions > Secrets**.
24+
- Add the following secrets:
25+
- `AWS_ACCESS_KEY_ID`: Your IAM user's Access Key ID.
26+
- `AWS_SECRET_ACCESS_KEY`: Your IAM user's Secret Access Key.
27+
28+
3. **Push Changes**
29+
- Ensure the `Dockerfile` and `.github/workflows/deploy.yml` are in your repository.
30+
- Push changes to the `main` branch:
31+
```bash
32+
git add .
33+
git commit -m "Set up CI/CD with GitHub Actions"
34+
git push origin main

0 commit comments

Comments
 (0)