Update docker-deploy.yaml #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_PRIVATE_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 ${{ steps.login-ecr.outputs.registry }}/advancedrag:latest |