From 9823ff94171edb7a0cfe3aef6a3502ebf8b2df51 Mon Sep 17 00:00:00 2001 From: seriouz Date: Tue, 21 May 2024 08:58:01 +0200 Subject: [PATCH] feat(Docker): Enabled support for Linux ARM based Docker images (Issue https://github.com/bagetter/BaGetter/issues/134). --- .github/workflows/release.yml | 5 +++++ Dockerfile | 8 +++++--- readme.md | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 867ea7136..c4923bf61 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -98,10 +98,15 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Set release version run: echo "PackageVersion=${{ needs.version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - name: Build and push Docker image uses: docker/build-push-action@v5.1.0 with: context: . + platforms: linux/amd64,linux/arm64 push: true tags: | bagetter/bagetter:latest diff --git a/Dockerfile b/Dockerfile index 0dba90a44..23468b098 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ ARG Version=1.0.0 -FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build ARG Version +ARG TARGETARCH WORKDIR /src ## Create separate layer for `dotnet restore` to allow for caching; useful for local development @@ -12,7 +13,7 @@ RUN for file in $(ls *.csproj); do mkdir -p ${file%.*}/ && mv $file ${file%.*}/; # useful for debugging to display all files #RUN echo $(ls) # restore packages -RUN dotnet restore BaGetter/BaGetter.csproj +RUN dotnet restore BaGetter/BaGetter.csproj --arch $TARGETARCH ## Publish app (implicitly builds the app) FROM build AS publish @@ -27,7 +28,8 @@ RUN dotnet publish BaGetter \ -p DebugType=none \ -p DebugSymbols=false \ -p GenerateDocumentationFile=false \ - -p UseAppHost=false + -p UseAppHost=false \ + -a $TARGETARCH # create default folders RUN mkdir -p "/data/packages" \ diff --git a/readme.md b/readme.md index d48d37258..a7ff28748 100644 --- a/readme.md +++ b/readme.md @@ -28,6 +28,7 @@ For more information, please refer to the [documentation]. ## 📦 Features * **Cross-platform**: runs on Windows, macOS, and Linux! +* **ARM** (64bit) **support**. You can host your NuGets on a device like Raspberry Pi! * **Cloud native**: supports [Docker][Docker doc link], [AWS][AWS doc link], [Google Cloud][GCP doc link], [Alibaba Cloud][Aliyun doc link] * **Offline support**: [Mirror a NuGet server][Read through caching] to speed up builds and enable offline downloads