docker-build-backend.yml•1.78 kB
name: Build backend image
on:
push:
branches:
- "main"
tags:
- "v*"
env:
REGISTRY: ghcr.io
DOCKERFILE: ./docker/api/Dockerfile
IMAGE_NAME: ${{ github.repository }}
IMAGE_KIND: backend
jobs:
backend-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
flavor: |
latest=false
suffix=-${{ env.IMAGE_KIND }},onlatest=false
tags: |
type=edge,branch=main,suffix=-${{ env.IMAGE_KIND }}
type=semver,pattern={{version}},branch=main,suffix=-${{ env.IMAGE_KIND }}
type=semver,pattern={{version}},branch=main,enable=${{ startsWith(github.ref, 'refs/tags/') }},suffix=-${{ env.IMAGE_KIND }}
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
driver-opts: |
image=moby/buildkit:latest
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
file: ${{ env.DOCKERFILE }}
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}