Update Dockerfile #10
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: Build and Deploy Docker Image | |
on: | |
push: | |
branches: | |
- main # Esto puede cambiar a la rama que prefieras | |
pull_request: | |
branches: | |
- main # Esto puede cambiar a la rama que prefieras | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- 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 | |
# Construir la imagen Docker (usando la fase de construcción) | |
- name: Build Docker image | |
run: docker build --file Dockerfile --target build --tag fedired . | |
# 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 fedired . | |
# (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 fedired |