Skip to content

Commit

Permalink
matrix to build images
Browse files Browse the repository at this point in the history
  • Loading branch information
tudddorrr committed Aug 20, 2024
1 parent ee3a7d1 commit 9233667
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
image: [backend, clickhouse]
steps:
- run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

Expand All @@ -22,18 +25,18 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
id: docker_build
- name: Build and push (${{ matrix.image }})
id: build-image
uses: docker/build-push-action@v5
with:
push: true
tags: |
ghcr.io/talodev/backend:latest
ghcr.io/talodev/backend:${{ env.TAG }}
target: prod
ghcr.io/talodev/${{ matrix.image }}:latest
ghcr.io/talodev/${{ matrix.image }}:${{ env.TAG }}
target: ${{ matrix.image == 'backend' && 'prod' || '' }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Image digest (${{ matrix.image }})
run: echo ${{ steps.build-image.outputs.digest }}

deploy:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ COPY src ./src
RUN npm run build

FROM base AS prod
ENV NODE_ENV production
ENV NODE_ENV=production
RUN npm ci
COPY --from=build /usr/backend/dist .
CMD [ "node", "index.js" ]

0 comments on commit 9233667

Please sign in to comment.