]> git.deb.at Git - rhonda/impostor.git/commitdiff
Multiarch dockerfile
authorAeonLucid <aeonlucid@gmail.com>
Wed, 30 Sep 2020 21:34:12 +0000 (23:34 +0200)
committerAeonLucid <aeonlucid@gmail.com>
Wed, 30 Sep 2020 21:34:12 +0000 (23:34 +0200)
.github/workflows/docker.yml
Dockerfile
src/Impostor.Server/Impostor.Server.csproj

index cf1b936370426de5a3c958034f81101b1b786d17..54e67cba91c4cdb6e321f60ae8888aee0fa43433 100644 (file)
@@ -67,6 +67,6 @@ jobs:
         with:
           context: .
           file: ./Dockerfile
-          platforms: linux/amd64,linux/arm/v7,linux/arm64
+          platforms: linux/amd64,linux/arm/v7
           push: ${{ github.event_name != 'pull_request' }}
           tags: ${{ steps.prep.outputs.tags }}
index 472694a078b9d54092d2298260635f2a09797a46..656237d3293af3d78b559bce390e0de39654fa17 100644 (file)
@@ -1,4 +1,9 @@
-FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
+
+# See for all possible platforms
+# https://github.com/containerd/containerd/blob/master/platforms/platforms.go#L17
+ARG TARGETARCH
+
 WORKDIR /source
 
 # Copy csproj and restore.
@@ -6,17 +11,29 @@ COPY src/Impostor.Server/Impostor.Server.csproj ./src/Impostor.Server/Impostor.S
 COPY src/Impostor.Shared/Impostor.Shared.csproj ./src/Impostor.Shared/Impostor.Shared.csproj
 COPY submodules/Hazel-Networking/Hazel/Hazel.csproj ./submodules/Hazel-Networking/Hazel/Hazel.csproj
 
-RUN dotnet restore -r linux-musl-x64 ./src/Impostor.Server/Impostor.Server.csproj && \
-    dotnet restore -r linux-musl-x64 ./src/Impostor.Shared/Impostor.Shared.csproj && \
-    dotnet restore -r linux-musl-x64 ./submodules/Hazel-Networking/Hazel/Hazel.csproj
+RUN case "$TARGETARCH" in \
+    amd64)  NETCORE_PLATFORM='linux-x64';; \
+    arm64)  NETCORE_PLATFORM='linux-arm64';; \
+    arm)    NETCORE_PLATFORM='linux-arm';; \
+    *) echo "unsupported architecture"; exit 1 ;; \
+  esac && \
+  dotnet restore -r "$NETCORE_PLATFORM" ./src/Impostor.Server/Impostor.Server.csproj && \
+  dotnet restore -r "$NETCORE_PLATFORM" ./src/Impostor.Shared/Impostor.Shared.csproj && \
+  dotnet restore -r "$NETCORE_PLATFORM" ./submodules/Hazel-Networking/Hazel/Hazel.csproj
 
 # Copy everything else.
 COPY submodules/. ./submodules/
 COPY src/. ./src/
-RUN dotnet publish -c release -o /app -r linux-musl-x64 --no-restore ./src/Impostor.Server/Impostor.Server.csproj
+RUN case "$TARGETARCH" in \
+    amd64)  NETCORE_PLATFORM='linux-x64';; \
+    arm64)  NETCORE_PLATFORM='linux-arm64';; \
+    arm)    NETCORE_PLATFORM='linux-arm';; \
+    *) echo "unsupported architecture"; exit 1 ;; \
+  esac && \
+  dotnet publish -c release -o /app -r "$NETCORE_PLATFORM" --no-restore ./src/Impostor.Server/Impostor.Server.csproj
 
 # Final image.
-FROM mcr.microsoft.com/dotnet/core/runtime-deps:3.1-alpine
+FROM mcr.microsoft.com/dotnet/core/runtime-deps:3.1
 WORKDIR /app
 COPY --from=build /app ./
 EXPOSE 22023/udp
index 0387f844c0e7b3a6e57d317698e579e75b25654a..617d2908f09317930e8d518486f49b4e1dbaba3d 100644 (file)
@@ -3,7 +3,6 @@
     <PropertyGroup>
         <OutputType>Exe</OutputType>
         <TargetFramework>netcoreapp3.1</TargetFramework>
-        <RuntimeIdentifiers>win-x64;linux-x64;linux-musl-x64</RuntimeIdentifiers>
         <PublishTrimmed>true</PublishTrimmed>
         <AssemblyTitle>Impostor.Server</AssemblyTitle>
         <Product>Impostor.Server</Product>