Skip to content

Dockerfile Builder #4985

Dockerfile Builder

Dockerfile Builder #4985

name: Dockerfile Builder
on:
# We need to run this workflow after NPM publisher otherwise Docker is going to try to create
# images with NPM packages (versions) that do not exist in the registry yet.
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run
workflow_run:
workflows: ['NPM Publisher']
branches:
- master
types:
- completed
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
jobs:
# https://docs.docker.com/ci-cd/github-actions/
build-and-publish:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
strategy:
fail-fast: false
matrix:
project:
- 'abacus'
- 'abacus-backoffice'
- 'abacus-kochka'
- 'abacus-tools'
- 'mrtnzlml-meta'
include:
- project: abacus
projectPath: './src/abacus'
projectDockerfile: './src/abacus/Dockerfile'
projectImageName: 'adeira/abacus'
- project: abacus-backoffice
projectPath: './src/abacus-backoffice'
projectDockerfile: './src/abacus-backoffice/Dockerfile'
projectImageName: 'adeira/abacus-backoffice'
- project: abacus-kochka
projectPath: './src/abacus-kochka'
projectDockerfile: './src/abacus-kochka/Dockerfile'
projectImageName: 'adeira/abacus-kochka'
- project: abacus-tools
projectPath: './src/abacus-tools'
projectDockerfile: './src/abacus-tools/Dockerfile'
projectImageName: 'adeira/abacus-tools'
- project: mrtnzlml-meta
projectPath: './src/mrtnzlml-meta'
projectDockerfile: './src/mrtnzlml-meta/Dockerfile'
projectImageName: 'adeira/mrtnzlml-meta'
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4.1.7
with:
# Number of commits to fetch. 0 indicates all history for all branches and tags.
fetch-depth: 0
# https://github.com/docker/login-action
- name: Login to Docker Hub
uses: docker/login-action@v3.3.0
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3.6.1
# https://github.com/docker/metadata-action
- name: Collect Docker metadata
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: ${{ matrix.projectImageName }}
flavor: |
latest=true
tags: |
type=sha
# https://github.com/docker/build-push-action
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6.7.0
with:
context: ${{ matrix.projectPath }}
file: ${{ matrix.projectDockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
secrets: |
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}