From 4a190b206fb19995ad40d27df785d9b1c6311041 Mon Sep 17 00:00:00 2001 From: Javier Caceres <81489497+srnovus@users.noreply.github.com> Date: Wed, 13 Nov 2024 12:09:36 -0600 Subject: [PATCH] Update docker-build-check.yml Signed-off-by: Javier Caceres <81489497+srnovus@users.noreply.github.com> --- .github/workflows/docker-build-check.yml | 52 +++++++++++++++++------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/.github/workflows/docker-build-check.yml b/.github/workflows/docker-build-check.yml index 7934dc2..1e6cf52 100644 --- a/.github/workflows/docker-build-check.yml +++ b/.github/workflows/docker-build-check.yml @@ -1,27 +1,49 @@ -name: Dockerfile Build Check +name: Build and Deploy Docker Image on: - pull_request: push: branches: - - main + - main # Esto puede cambiar a la rama que prefieras + pull_request: + branches: + - main # Esto puede cambiar a la rama que prefieras jobs: - docker-build: + build: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v3 + + # Configurar Node.js en la versión que se usa en el Dockerfile + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' + + # Instalar pnpm + - name: Install pnpm + run: npm install -g pnpm + + # Instalar dependencias usando pnpm (no congelamos el lockfile en CI) + - name: Install dependencies + run: pnpm install --no-frozen-lockfile + + # Verificar que no haya conflictos en el lockfile + - name: Verify lockfile (optional) + run: pnpm install --no-frozen-lockfile - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + # Construir la imagen Docker (usando la fase de construcción) + - name: Build Docker image + run: docker build --file Dockerfile --target build --tag my-image-build . - - name: Login to DockerHub (Optional) - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + # Crear la imagen de producción (usando la fase de producción) + - name: Build production Docker image + run: docker build --file Dockerfile --target production --tag my-image-prod . - - name: Build Docker image - run: docker build --file Dockerfile --target build --tag fedired-build-check . + # (Opcional) Subir la imagen Docker a un registry, como DockerHub o GitHub Container Registry + - name: Push Docker image to registry + run: | + echo ${{ secrets.DOCKER_USERNAME }} | docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin + docker push my-image-prod