Skip to content

Commit

Permalink
Update docker-build-check.yml
Browse files Browse the repository at this point in the history
Signed-off-by: Javier Caceres <[email protected]>
  • Loading branch information
srnovus authored Nov 13, 2024
1 parent 13f7817 commit 4a190b2
Showing 1 changed file with 37 additions and 15 deletions.
52 changes: 37 additions & 15 deletions .github/workflows/docker-build-check.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4a190b2

Please sign in to comment.