Build multi-arch

This commit is contained in:
Jörn Guy Süß 2025-08-04 11:26:33 +10:00
parent 35221a7495
commit 8df84579a8

View File

@ -1,13 +1,9 @@
# This workflow builds and pushes a Docker image to GitHub Container Registry (ghcr.io) on every push to main. # This workflow builds and pushes a multi-architecture Docker image to GitHub Container Registry (ghcr.io).
# #
# The Docker meta step is required because GitHub repository names can contain uppercase letters, but Docker image tags must be lowercase. # The Docker meta step is required because GitHub repository names can contain uppercase letters, but Docker image tags must be lowercase.
# The docker/metadata-action@v5 normalizes the repository name to lowercase, ensuring the build and push steps use a valid image tag. # The docker/metadata-action@v5 normalizes the repository name to lowercase, ensuring the build and push steps use a valid image tag.
# #
# Without this normalization, you may encounter errors like: # This workflow builds for both AMD64 and ARM64 architectures using Docker Buildx and QEMU emulation.
# ERROR: failed to build: invalid tag "ghcr.io/jgsuess/FHIRFLARE-IG-Toolkit:latest": repository name must be lowercase
# Error: Process completed with exit code 1.
#
# This workflow uses the IMAGE_NAME environment variable set by the Docker meta step to guarantee a valid, lowercase image name.
name: Build and Push Docker image name: Build and Push Docker image
@ -25,6 +21,12 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry - name: Log in to GitHub Container Registry
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
@ -46,10 +48,11 @@ jobs:
echo "IMAGE_NAME=${{ steps.meta.outputs.tags }}" >> $GITHUB_ENV echo "IMAGE_NAME=${{ steps.meta.outputs.tags }}" >> $GITHUB_ENV
fi fi
- name: Build Docker image - name: Build and push multi-architecture Docker image
run: | uses: docker/build-push-action@v5
docker build -f docker/Dockerfile -t ${{ env.IMAGE_NAME }} . with:
context: .
- name: Push Docker image file: ./docker/Dockerfile
run: | platforms: linux/amd64,linux/arm64
docker push ${{ env.IMAGE_NAME }} push: true
tags: ${{ env.IMAGE_NAME }}