Selaa lähdekoodia

Bump GenHTTP to 2.9, improve docker image. (#5540)

Andreas Nägeli 5 vuotta sitten
vanhempi
commit
30d21eff18

+ 2 - 2
frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj

@@ -18,8 +18,8 @@
   </PropertyGroup>
     
   <ItemGroup>
-    <PackageReference Include="GenHTTP.Core" Version="2.8.3" />
-    <PackageReference Include="GenHTTP.Modules.Webservices" Version="2.8.3" />
+    <PackageReference Include="GenHTTP.Core" Version="2.9.0" />
+    <PackageReference Include="GenHTTP.Modules.Webservices" Version="2.9.0" />
   </ItemGroup>
   
 </Project>

+ 1 - 8
frameworks/CSharp/genhttp/Benchmarks/Tests/JsonResource.cs

@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-using Newtonsoft.Json;
-
-using GenHTTP.Modules.Webservices;
+using GenHTTP.Modules.Webservices;
 
 namespace Benchmarks.Tests
 {
@@ -12,7 +6,6 @@ namespace Benchmarks.Tests
     public class JsonResult
     {
 
-        [JsonProperty("message")]
         public string? Message { get; set; }
 
     }

+ 10 - 12
frameworks/CSharp/genhttp/genhttp.dockerfile

@@ -1,21 +1,19 @@
 FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build
-WORKDIR /app
+WORKDIR /source
 
 # copy csproj and restore as distinct layers
-COPY Benchmarks/*.csproj ./Benchmarks/
-WORKDIR /app/Benchmarks
-RUN dotnet restore
+COPY Benchmarks/*.csproj .
+RUN dotnet restore -r linux-musl-x64
 
-# copy and build app and libraries
-WORKDIR /app/
-COPY Benchmarks/. ./Benchmarks/
-WORKDIR /app/Benchmarks
-RUN dotnet publish -c Release -r linux-musl-x64 -o out --self-contained true /p:PublishTrimmed=true
+# copy and publish app and libraries
+COPY Benchmarks/ .
+RUN dotnet publish -c release -o /app -r linux-musl-x64 --self-contained true --no-restore /p:PublishTrimmed=true /p:PublishReadyToRun=true
 
-FROM mcr.microsoft.com/dotnet/core/runtime-deps:3.1-alpine AS runtime
-ENV DOCKER_FLAVOR=linux
+# final stage/image
+FROM mcr.microsoft.com/dotnet/core/runtime-deps:3.1-alpine
 WORKDIR /app
-COPY --from=build /app/Benchmarks/out ./
+COPY --from=build /app .
+
 ENTRYPOINT ["./Benchmarks"]
 
 EXPOSE 8080