-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Javier Caceres <[email protected]>
- Loading branch information
Showing
1 changed file
with
37 additions
and
15 deletions.
There are no files selected for viewing
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
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 |