Skip to content

Update docker-deploy.yaml #11

Update docker-deploy.yaml

Update docker-deploy.yaml #11

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: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build Docker image and push to ECR
run: |
docker build -t advanced-rag-image:latest .
docker tag advanced-rag-image:latest ${{ steps.login-ecr.outputs.registry }}/advancedrag:latest
docker push ${{ steps.login-ecr.outputs.registry }}/advancedrag:latest
- name: SSH into EC2 instance
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
port: ${{ secrets.EC2_PORT }}
script: |
docker pull ${{ steps.login-ecr.outputs.registry }}/advancedrag:latest
docker stop advanced-rag-demo || true
docker rm advanced-rag-demo || true
docker run -d --name advanced-rag-demo -p 80:8501 --add-host=host.docker.internal:host-gateway -e OLLAMA_HOST="http://host.docker.internal:11434" -v ~/.aws:/root/.aws ${{ steps.login-ecr.outputs.registry }}/advancedrag:latest