Merge pull request #796 from Cucumberrbob/build/multi-arch-docker
use arm GitHub Actions runner to build arm docker image
This commit is contained in:
commit
e6686aa35d
2 changed files with 110 additions and 69 deletions
177
.github/workflows/build-docker-image.yml
vendored
177
.github/workflows/build-docker-image.yml
vendored
|
|
@ -5,41 +5,105 @@ on:
|
|||
tags:
|
||||
- v*
|
||||
|
||||
permissions:
|
||||
permissions:
|
||||
packages: write
|
||||
|
||||
|
||||
env:
|
||||
APP_NAME: rdtclient
|
||||
DOCKER_FILE: ./Dockerfile
|
||||
DOCKER_PLATFORMS: "linux/arm64/v8,linux/amd64"
|
||||
ENABLE_DOCKERHUB: 1
|
||||
ENABLE_GHCR: 1
|
||||
|
||||
|
||||
concurrency: ${{ github.sha }}
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
digest-amd64: ${{ steps.digest.outputs.digest-amd64 }}
|
||||
digest-arm64: ${{ steps.digest.outputs.digest-arm64 }}
|
||||
strategy:
|
||||
matrix:
|
||||
config:
|
||||
- arch: amd64
|
||||
runs-on: ubuntu-latest
|
||||
platform: linux/amd64
|
||||
- arch: arm64
|
||||
runs-on: ubuntu-24.04-arm
|
||||
platform: linux/arm64
|
||||
runs-on: ${{ matrix.config.runs-on }}
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Extract version and patch .csproj
|
||||
run: |
|
||||
VERSION="${GITHUB_REF_NAME#v}"
|
||||
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
|
||||
sed -i "s|<Version>.*</Version>|<Version>$VERSION</Version>|" server/RdtClient.Web/RdtClient.Web.csproj
|
||||
sed -i "s|<AssemblyVersion>.*</AssemblyVersion>|<AssemblyVersion>$VERSION</AssemblyVersion>|" server/RdtClient.Web/RdtClient.Web.csproj
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Docker Metadata action
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4.3.0
|
||||
with:
|
||||
images: |
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}
|
||||
ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}
|
||||
tags: |
|
||||
- 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: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Docker Metadata action
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}
|
||||
ghcr.io/${{ github.repository_owner }}/${{ env.APP_NAME }}
|
||||
|
||||
- name: Build and push by digest
|
||||
id: build
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}
|
||||
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
|
||||
|
||||
- name: Export digest
|
||||
id: digest
|
||||
run: |
|
||||
echo "digest-${{ matrix.config.arch }}=${{ steps.build.outputs.digest }}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
push-images:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- 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: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Docker Metadata action
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}
|
||||
ghcr.io/${{ github.repository_owner }}/${{ env.APP_NAME }}
|
||||
tags: |
|
||||
type=schedule
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
|
|
@ -47,47 +111,24 @@ jobs:
|
|||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=sha
|
||||
|
||||
- name: Create manifest list and push
|
||||
run: |
|
||||
docker buildx imagetools create \
|
||||
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< '${{ steps.meta.outputs.json }}') \
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}@${{ needs.build.outputs.digest-amd64 }} \
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}@${{ needs.build.outputs.digest-arm64 }}
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Docker Setup QEMU
|
||||
uses: docker/setup-qemu-action@v2.1.0
|
||||
|
||||
- name: Docker Setup Buildx
|
||||
uses: docker/setup-buildx-action@v2.5.0
|
||||
with:
|
||||
buildkitd-flags: --debug
|
||||
|
||||
- name: Docker Login
|
||||
if: ${{ github.event_name != 'pull_request' && env.ENABLE_DOCKERHUB == 1 }}
|
||||
uses: docker/login-action@v2.1.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
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
|
||||
if: ${{ env.ENABLE_DOCKERHUB == 1 }}
|
||||
uses: peter-evans/dockerhub-description@v3.3.0
|
||||
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 debrid providers.
|
||||
readme-filepath: ./README-DOCKER.md
|
||||
- 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 debrid providers.
|
||||
readme-filepath: ./README-DOCKER.md
|
||||
|
|
@ -21,7 +21,7 @@ RUN \
|
|||
RUN ls -FCla /appclient/root
|
||||
|
||||
# Stage 2 - Build the backend
|
||||
FROM mcr.microsoft.com/dotnet/sdk:9.0-bookworm-slim-amd64 AS dotnet-build-env
|
||||
FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS dotnet-build-env
|
||||
ARG TARGETPLATFORM
|
||||
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
|
||||
ARG BUILDPLATFORM
|
||||
|
|
|
|||
Loading…
Reference in a new issue