From 40ca7d4b6e2efb71c49596ffb2f65f68642ce6cd Mon Sep 17 00:00:00 2001 From: Enrique Calderon <71863693+ksobrenat32@users.noreply.github.com> Date: Fri, 7 Feb 2025 09:58:35 -0600 Subject: [PATCH] Infra: Build container image for all branches (#5) * infra: Build images for all branches without the need of tags. Stop using latest tag on container image. * Fix npm install on docker There are errors when the branch is not ready to be merged. This is a temporary fix to make the docker image buildable on all branches. --- .github/workflows/docker.yml | 15 +++++++++------ Dockerfile | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2f78c9b..d63dabc 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,8 +2,8 @@ name: Docker Build and Push on: push: - tags: - - "*" + branches: + - '**' concurrency: group: "docker-image" @@ -27,12 +27,15 @@ jobs: with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.GH_TOKEN }} - + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Downcase REPO variable + run: | + echo "REPO=${GITHUB_REPOSITORY@L}" >> "${GITHUB_ENV}" + - name: Build and push uses: docker/build-push-action@v5 with: push: true - tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:${{ github.ref_name }} + tags: ghcr.io/${{ env.REPO }}:${{ github.ref_name }}, ghcr.io/${{ env.REPO }}:${{ github.sha }} platforms: linux/amd64,linux/arm64 - diff --git a/Dockerfile b/Dockerfile index 9365ee1..68bc8dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,8 @@ FROM node:20-alpine AS build WORKDIR /app COPY package*.json ./ -RUN npm ci +RUN npm install && \ + npm ci COPY . . RUN npm run build