ci: adjust project for .net 8 support
All checks were successful
Build, Package and Push Images / preprocess (push) Successful in 3s
Build, Package and Push Images / build (push) Successful in 28s
Build, Package and Push Images / sbom-scan (push) Successful in 37s
Build, Package and Push Images / sonarqube (push) Successful in 1m20s
Build, Package and Push Images / container-build (push) Successful in 1m31s
Build, Package and Push Images / container-sbom-scan (push) Successful in 37s

This commit is contained in:
Timothy Schenk 2023-11-06 14:17:46 +01:00
parent 5f6fa601ee
commit 510ae3173c
2 changed files with 19 additions and 9 deletions

View file

@ -1,18 +1,28 @@
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
FROM mcr.microsoft.com/dotnet/runtime:8.0-bookworm-slim AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim AS build
ARG TARGETARCH
ENV TZ=Etc/UTC
ENV DOTNET_TieredPGO=1
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
RUN echo "Target: $TARGETARCH"
RUN echo "Build: $BUILDPLATFORM"
WORKDIR /src
COPY ["Wonderking/Wonderking.csproj", "Wonderking/"]
COPY ["Server/Server.csproj", "Server/"]
RUN dotnet restore "Server/Server.csproj"
RUN dotnet restore "Wonderking/Wonderking.csproj" -a $TARGETARCH
RUN dotnet restore "Server/Server.csproj" -a $TARGETARCH
COPY . .
WORKDIR "/src/Server"
RUN dotnet build "Server.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Server.csproj" -c Release -o /app/publish /p:UseAppHost=false
RUN dotnet publish "Server/Server.csproj" -c Release -a $TARGETARCH --no-restore -f net8.0 -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Server.dll"]
COPY --from=publish /app .
USER $APP_UID
ENTRYPOINT ["./Server"]

View file

@ -2,13 +2,13 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>warnings</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<RootNamespace>Server</RootNamespace>
<LangVersion>default</LangVersion>
<ServerGarbageCollection>true</ServerGarbageCollection>
<TargetFrameworks>net8.0;net7.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>