From 9d9337a57756f3d4c9f2ba90b9d122d68df7daab Mon Sep 17 00:00:00 2001 From: JudLup Luna Date: Wed, 5 Jun 2024 22:50:57 -0500 Subject: [PATCH] =?UTF-8?q?chore:=20inclusi=C3=B3n=20de=20consctrucci?= =?UTF-8?q?=C3=B3n=20de=20imagen=20docker=20en=20pipeline=20y=20habilitar?= =?UTF-8?q?=20la=20imagen=20en=20el=20docker-compose?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 22 ++++++++++++++++++++-- docker-compose.yml | 4 +++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3b2508d..d379013 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -21,6 +21,20 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ${{ secrets.AWS_REGION }} + - name: Log in to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + with: + region: ${{ secrets.AWS_REGION }} + + - name: Build Docker image + run: docker build -t glasscamp-backend:latest . + + - name: Tag Docker image + run: docker tag glasscamp-backend:latest ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/glasscamp-backend:latest + + - name: Push Docker image to Amazon ECR + run: docker push ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/glasscamp-backend:latest deploy: runs-on: ubuntu-latest @@ -50,8 +64,12 @@ jobs: echo "NODE_ENV=${{secrets.NODE_ENV}}" >> .env echo "POSTGRES_USER=${{secrets.POSTGRES_USER}}" >> .env echo "POSTGRES_PASSWORD=${{secrets.POSTGRES_PASSWORD}}" >> .env - echo "POSTGRES_DB=${{secrets.POSTGRES_DB}}" >> .env - + echo "POSTGRES_DB=${{secrets.POSTGRES_DB}}" >> .env + echo "AWS_ACCOUNT_ID=${{secrets.AWS_ACCOUNT_ID}}" >> .env + echo "AWS_REGION=${{secrets.AWS_REGION}}" >> .env + # Hacer pull de los cambios en la imagen docker + # docker pull ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/glasscamp-backend:latest + # Actualizar la imagen del servicio backend y reiniciarlo sin afectar db docker-compose down docker-compose up -d --no-deps --build diff --git a/docker-compose.yml b/docker-compose.yml index 936a02f..54b7d1f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,7 +18,9 @@ services: - 5432:5432 backend: - build: . + # build: . + image: ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/glasscamp-backend:latest + # image: glasscamp-backend:latest container_name: backend env_file: - .env