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
165
.github/workflows/build-docker-image.yml
vendored
165
.github/workflows/build-docker-image.yml
vendored
|
|
@ -11,35 +11,99 @@ permissions:
|
||||||
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:
|
||||||
|
outputs:
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Extract version and patch .csproj
|
- name: Login to DockerHub
|
||||||
run: |
|
if: ${{ env.ENABLE_DOCKERHUB == 1 }}
|
||||||
VERSION="${GITHUB_REF_NAME#v}"
|
uses: docker/login-action@v3
|
||||||
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
|
with:
|
||||||
sed -i "s|<Version>.*</Version>|<Version>$VERSION</Version>|" server/RdtClient.Web/RdtClient.Web.csproj
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
sed -i "s|<AssemblyVersion>.*</AssemblyVersion>|<AssemblyVersion>$VERSION</AssemblyVersion>|" server/RdtClient.Web/RdtClient.Web.csproj
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Docker Metadata action
|
- name: Login to GHCR
|
||||||
id: meta
|
if: ${{ env.ENABLE_GHCR == 1 }}
|
||||||
uses: docker/metadata-action@v4.3.0
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
images: |
|
registry: ghcr.io
|
||||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}
|
username: ${{ github.repository_owner }}
|
||||||
ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
tags: |
|
|
||||||
|
- 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=schedule
|
||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
type=ref,event=pr
|
type=ref,event=pr
|
||||||
|
|
@ -48,46 +112,23 @@ jobs:
|
||||||
type=semver,pattern={{major}}
|
type=semver,pattern={{major}}
|
||||||
type=sha
|
type=sha
|
||||||
|
|
||||||
- name: Docker Setup QEMU
|
- name: Create manifest list and push
|
||||||
uses: docker/setup-qemu-action@v2.1.0
|
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: Docker Setup Buildx
|
- name: Checkout code
|
||||||
uses: docker/setup-buildx-action@v2.5.0
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
buildkitd-flags: --debug
|
|
||||||
|
|
||||||
- name: Docker Login
|
- name: Docker Hub Registry Description
|
||||||
if: ${{ github.event_name != 'pull_request' && env.ENABLE_DOCKERHUB == 1 }}
|
if: ${{ env.ENABLE_DOCKERHUB == 1 }}
|
||||||
uses: docker/login-action@v2.1.0
|
uses: peter-evans/dockerhub-description@v4
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
repository: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}
|
||||||
- name: Login to GHCR
|
short-description: |
|
||||||
if: ${{ github.event_name != 'pull_request' && env.ENABLE_GHCR == 1 }}
|
A web interface to manage your torrents on debrid providers.
|
||||||
uses: docker/login-action@v2.1.0
|
readme-filepath: ./README-DOCKER.md
|
||||||
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
|
|
||||||
|
|
@ -21,7 +21,7 @@ RUN \
|
||||||
RUN ls -FCla /appclient/root
|
RUN ls -FCla /appclient/root
|
||||||
|
|
||||||
# Stage 2 - Build the backend
|
# 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
|
ARG TARGETPLATFORM
|
||||||
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
|
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
|
||||||
ARG BUILDPLATFORM
|
ARG BUILDPLATFORM
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue