Skip to content

Commit

Permalink
Replaced Dockerhub with AWS ECR
Browse files Browse the repository at this point in the history
  • Loading branch information
2003HARSH committed Nov 10, 2024
1 parent 8001d76 commit fd61319
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,36 +51,39 @@ jobs:
DAGSHUB_PAT: ${{ secrets.DAGSHUB_PAT }}
run: python -m unittest tests/test_flask_app.py

- name: Login to Dcokerhub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME}}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN}}
- name: Login to AWS ECR
run: |
aws configure set aws_access_key_id ${ {secrets.AWS_ACCESS_KEY_ID }}
aws configure set aws_secret_access_key ${ {secrets.AWS_SECRET_ACCESS_KEY }}
aws ecr get-login-password --region eu-north-1 | docker login --username AWS --password-stdin 843369994444.dkr.ecr.eu-north-1.amazonaws.com
- name: Build Docker Image
if: success()
run: |
docker build -t ${{ secrets.DOCKER_HUB_USERNAME}}/text-classification-using-mlops:latest .
docker build -t text-classification .
- name: Push Dcoker image to Dockerhub
if: success()
- name: Tag Docker Image
run: |
docker tag text-classification:latest 843369994444.dkr.ecr.eu-north-1.amazonaws.com/text-classification:latest
- name: Push Docker Image to AWS ECR
run: |
docker push ${{ secrets.DOCKER_HUB_USERNAME}}/text-classification-using-mlops:latest
docker push 843369994444.dkr.ecr.eu-north-1.amazonaws.com/text-classification:latest
Deploy-to-EC2:
runs-on: ubuntu-latest
needs: test-and-package
steps:
# Deploy-to-EC2:
# runs-on: ubuntu-latest
# needs: test-and-package

- name: Deploy to EC2
uses: appleboy/ssh-action@v0.1.5
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/text-classification-using-mlops:latest
docker stop my-app || true
docker rm my-app || true
docker run -d -p 80:5000 --name my-app -e DAGSHUB_PAT=${{ secrets.DAGSHUB_PAT }} ${{ secrets.DOCKER_HUB_USERNAME }}/text-classification-using-mlops:latest
# steps:

# - name: Deploy to EC2
# uses: appleboy/ssh-action@v0.1.5
# with:
# host: ${{ secrets.EC2_HOST }}
# username: ${{ secrets.EC2_USER }}
# key: ${{ secrets.EC2_SSH_KEY }}
# script: |
# docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/text-classification-using-mlops:latest
# docker stop my-app || true
# docker rm my-app || true
# docker run -d -p 80:5000 --name my-app -e DAGSHUB_PAT=${{ secrets.DAGSHUB_PAT }} ${{ secrets.DOCKER_HUB_USERNAME }}/text-classification-using-mlops:latest

0 comments on commit fd61319

Please sign in to comment.