Skip to content

add dockerfile and github actions file #1

add dockerfile and github actions file

add dockerfile and github actions file #1

name: Docker Deploy to EC2
on:
push:
branches:
- deployment-patch
jobs:
deploy:
name: Deploy to EC2
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
registry: advancedrag
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Build Docker image
run: |
docker build -t advancedrag/advanced-rag-image:latest .
docker push advancedrag/advanced-rag-image:latest
- name: SSH into EC2 instance
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
port: ${{ secrets.EC2_PORT }}
script: |
# Pull the latest Docker image from Amazon ECR
docker pull advancedrag/advanced-rag-image:latest
# Stop and remove the existing container (if exists)
docker stop advanced-rag-demo || true
docker rm advanced-rag-demo || true
# Run the new Docker container
docker run -d \
--name advanced-rag-demo \
-p 80:8501 \ # Example port mapping, adjust as needed
advancedrag/advanced-rag-image:latest