Skip to content

Replaced Dockerhub with AWS ECR #2

Replaced Dockerhub with AWS ECR

Replaced Dockerhub with AWS ECR #2

Workflow file for this run

name: CI Pipeline
on: push
jobs:
test-and-package:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v3
- name: setup python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: install dependencies
run: |
pip install -r requirements.txt
- name: run pipeline
env:
DAGSHUB_PAT: ${{ secrets.DAGSHUB_PAT }}
run: |
dvc repro
- name: Run model tests
env:
DAGSHUB_PAT: ${{ secrets.DAGSHUB_PAT }}
run: |
python -m unittest tests/test_model.py
- name: Promote model to production
if: success()
env:
DAGSHUB_PAT: ${{ secrets.DAGSHUB_PAT }}
run: python scripts/promote_model.py
- name: Run Flask app tests
if: success()
env:
DAGSHUB_PAT: ${{ secrets.DAGSHUB_PAT }}
run: python -m unittest tests/test_flask_app.py
- 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
run: |
docker build -t text-classification .
- 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 843369994444.dkr.ecr.eu-north-1.amazonaws.com/text-classification:latest
# Deploy-to-EC2:
# runs-on: ubuntu-latest
# needs: test-and-package
# 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