Skip to content

Commit

Permalink
CI + Pushed To ECR
Browse files Browse the repository at this point in the history
  • Loading branch information
arpitpatel1 committed Jan 2, 2024
1 parent f2dc4b6 commit d6c8927
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 5 deletions.
82 changes: 80 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ name: CI Pipeline
on:
push:

# permissions:
# id-token: write
# contents: read


jobs:
build:
code-execution:
name : Continues Integration
runs-on: ubuntu-latest

env:
Expand Down Expand Up @@ -41,4 +47,76 @@ jobs:
echo "# Model Score Report" >> report.md
echo "The R2 score is: $model_score" >> report.md
cml comment create report.md
cml comment create report.md
build-and-push-ecr-image:
name: Push to ECR
needs: code-execution
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Install Utilities
run: |
sudo apt-get update
sudo apt-get install -y jq unzip
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_URI : ${{ secrets.AWS_ECR_LOGIN_URI }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_NAME }}
IMAGE_TAG: latest
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t housing .
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
# Continuous-Deployment:
# runs-on: self-hosted
# needs: build-and-push-ecr-image
# steps:
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: ${{ secrets.AWS_REGION }}

# - name: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v2

# - name: Pull latest images
# env:
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_NAME }}
# IMAGE_TAG: latest
# run: |
# docker pull $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG

# - name: Delete Previous Container
# run: |
# docker rm -f trip-duration || true

# - name: Run Docker Image to serve users
# run: |
# docker run -d -p 8080:8000 --ipc="host" --name=trip-duration -e 'AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}' -e 'AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}' -e 'AWS_REGION=${{ secrets.AWS_REGION }}' ${{secrets.AWS_ECR_LOGIN_URI}}/${{ secrets.ECR_REPOSITORY_NAME }}:latest

10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Use an official Python runtime as a parent image
FROM python:3.8-slim

# Set the working directory to /app
COPY . /app
WORKDIR /app

# Set the working directory to /app
COPY app.py /app/app.py
COPY models/ /app/models/
COPY templates/ /app/templates/
COPY docker_requirements.txt /app/docker_requirements.txt

# Install any needed packages specified in requirements.txt
RUN pip install -r requirements.txt
RUN pip install -r docker_requirements.txt

# Copy files from S3 inside docker
# RUN mkdir /app/models
Expand Down
6 changes: 6 additions & 0 deletions docker_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fastapi
# joblib
uvicorn
scikit-learn
pandas
python-multipart

2 comments on commit d6c8927

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Model Score Report

The R2 score is: 0.8534155063614792

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Model Score Report

The R2 score is: 0.8478681157168393

Please sign in to comment.