use arm runner to build arm docker image

This commit is contained in:
Cucumberrbob 2025-03-16 16:33:21 +00:00
parent 9ac87727c7
commit a3358aec76
No known key found for this signature in database
GPG key ID: 2B935C47401C3614

View file

@ -1,38 +1,47 @@
name: Docker Image CI name: Docker Multi-Architecture Image CI
on: on:
push: push:
tags: pull_request:
- v*
permissions: permissions:
packages: write packages: write
env: env:
APP_NAME: rdtclient APP_NAME: rdtclient
DOCKER_FILE: ./Dockerfile DOCKER_FILE: ./Dockerfile
DOCKER_PLATFORMS: "linux/arm64/v8,linux/amd64"
ENABLE_DOCKERHUB: 1 ENABLE_DOCKERHUB: 1
ENABLE_GHCR: 1 ENABLE_GHCR: 1
concurrency: ${{ github.sha }}
jobs: jobs:
build: build:
strategy:
runs-on: ubuntu-latest matrix:
config:
- arch: amd64
runs-on: ubuntu-latest
platform: linux/amd64
- arch: arm64
runs-on: ubuntu-24.04-arm
platform: linux/arm64/v8
runs-on: ${{ matrix.config.runs-on }}
steps: steps:
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Docker Metadata action - name: Set up Docker Buildx
id: meta uses: docker/setup-buildx-action@v3
uses: docker/metadata-action@v4.3.0
with: - name: Docker Metadata action
images: | id: meta
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }} uses: docker/metadata-action@v5
ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }} with:
tags: | images: |
${{ github.ref_type == 'tag' && format('{0}/{1}', secrets.DOCKERHUB_USERNAME, env.APP_NAME) || ''}}
ghcr.io/${{ github.repository_owner }}/${{ env.APP_NAME }}
tags: |
type=schedule type=schedule
type=ref,event=branch type=ref,event=branch
type=ref,event=pr type=ref,event=pr
@ -40,59 +49,119 @@ jobs:
type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}} type=semver,pattern={{major}}
type=sha type=sha
# List of custom labels
# labels: # optional
- name: Docker Setup QEMU - name: Build and save image
uses: docker/setup-qemu-action@v2.1.0 uses: docker/build-push-action@v5
with:
- name: Docker Setup Buildx context: .
uses: docker/setup-buildx-action@v2.5.0 file: ${{ env.DOCKER_FILE }}
with: platforms: ${{ matrix.config.platform }}
buildkitd-flags: --debug push: false
load: true
- name: Docker Login outputs: type=docker,dest=${{ runner.temp }}/${{ matrix.config.arch }}.tar
if: ${{ github.event_name != 'pull_request' && env.ENABLE_DOCKERHUB == 1 }} tags: ${{ env.APP_NAME }}:${{ github.sha }}-${{ matrix.config.arch }}
uses: docker/login-action@v2.1.0 labels: ${{ steps.meta.outputs.labels }}
with: cache-from: type=gha,scope=${{ matrix.config.arch }}
username: ${{ secrets.DOCKERHUB_USERNAME }} cache-to: type=gha,mode=max,scope=${{ matrix.config.arch }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GHCR
if: ${{ github.event_name != 'pull_request' && env.ENABLE_GHCR == 1 }}
uses: docker/login-action@v2.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@v4.0.0
with:
context: .
file: ${{ env.DOCKER_FILE }}
platforms: ${{ env.DOCKER_PLATFORMS }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Docker Hub Registry Description # Upload the tarball as an artifact
if: ${{ env.ENABLE_DOCKERHUB == 1 }} - name: Upload image tarball
uses: peter-evans/dockerhub-description@v3.3.0 uses: actions/upload-artifact@v4
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} name: image-${{ matrix.config.arch }}
password: ${{ secrets.DOCKERHUB_TOKEN }} path: ${{ runner.temp }}/${{ matrix.config.arch }}.tar
repository: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }} retention-days: 1
short-description: |
a web interface to manage your torrents on Real-Debrid, AllDebrid or Premiumize. # Push to registries
readme-filepath: ./README-DOCKER.md push-images:
needs: build
# - name: Github Registry Description runs-on: ubuntu-latest
# if: ${{ env.ENABLE_GHCR == 1 }} if: ${{ github.event_name != 'pull_request' }}
# uses: peter-evans/dockerhub-description@v3.3.0 steps:
# with: - name: Download all image tarballs
# username: ${{ github.repository_owner }} uses: actions/download-artifact@v4
# password: ${{ secrets.GITHUB_TOKEN }} with:
# short-description: | path: /tmp/images
# A web interface to manage your torrents on Real-Debrid, AllDebrid or Premiumize. pattern: image-*
# readme-filepath: ./README-DOCKER.md merge-multiple: true
- name: Docker Metadata action
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.ref_type == 'tag' && format('{0}/{1}', secrets.DOCKERHUB_USERNAME, env.APP_NAME) || ''}}
ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: ${{ env.ENABLE_DOCKERHUB == 1 }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GHCR
if: ${{ env.ENABLE_GHCR == 1 }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Load images
run: |
docker load --input /tmp/images/amd64.tar
docker load --input /tmp/images/arm64.tar
- name: Create and push manifests
run: |
# Process each tag
echo "${{ steps.meta.outputs.tags }}" | while read -r TAG; do
# Skip empty lines
[ -z "$TAG" ] && continue
echo "Processing tag: $TAG"
docker tag ${{ env.APP_NAME }}:${{ github.sha }}-amd64 $TAG-amd64
docker tag ${{ env.APP_NAME }}:${{ github.sha }}-arm64 $TAG-arm64
docker push $TAG-arm64
docker push $TAG-amd64
docker manifest create $TAG \
$TAG-amd64 \
$TAG-arm64
docker manifest push $TAG
done
# Update Docker Hub description
update-description:
needs: push-images
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Docker Hub Registry Description
if: ${{ env.ENABLE_DOCKERHUB == 1 }}
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}
short-description: |
a web interface to manage your torrents on Real-Debrid, AllDebrid or Premiumize.
readme-filepath: ./README-DOCKER.md