fix: finalize runtime dependencies #9
This file contains hidden or 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: Deploy Application Docker Image to EC2 instance | |
| on: | |
| push: | |
| branches: [main] | |
| jobs: | |
| Continuous-Integration: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v3 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v2 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ secrets.AWS_DEFAULT_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 | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| ECR_REPOSITORY: ${{ secrets.ECR_REPO }} | |
| IMAGE_TAG: latest | |
| run: | | |
| docker build --no-cache -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
| docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
| Continuous-Deployment: | |
| needs: Continuous-Integration | |
| runs-on: self-hosted | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v3 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v2 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Deploy latest Docker image | |
| run: | | |
| echo "Stopping old containers..." | |
| docker stop $(docker ps -aq) || true | |
| docker rm $(docker ps -aq) || true | |
| echo "Pulling latest image..." | |
| docker pull ${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_REPO }}:latest | |
| echo "Running new container..." | |
| docker run -d --restart always \ | |
| -p 8080:8080 \ | |
| -e AWS_ACCESS_KEY_ID="${{ secrets.AWS_ACCESS_KEY_ID }}" \ | |
| -e AWS_SECRET_ACCESS_KEY="${{ secrets.AWS_SECRET_ACCESS_KEY }}" \ | |
| -e AWS_DEFAULT_REGION="${{ secrets.AWS_DEFAULT_REGION }}" \ | |
| -e PINECONE_API_KEY="${{ secrets.PINECONE_API_KEY }}" \ | |
| -e GROQ_API_KEY="${{ secrets.GROQ_API_KEY }}" \ | |
| ${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_REPO }}:latest |