From 94a0414b549dc032937d38775b1429d34c6557ea Mon Sep 17 00:00:00 2001 From: Rune Johansen Date: Tue, 14 May 2024 14:49:07 +0200 Subject: [PATCH] .NET 8.0 update (#29) * Change TargetFramework to net8.0 * Update README.md * Use new template for Dockerfile --------- Co-authored-by: Rune Johansen <6797636+runejo@users.noreply.github.com> --- Dockerfile | 54 +++++++++++++--------- Px.Abstractions/Px.Abstractions.csproj | 2 +- Px.Search.Lucene/Px.Search.Lucene.csproj | 2 +- Px.Search/Px.Search.csproj | 2 +- PxWeb.UnitTests/PxWeb.UnitTests.csproj | 2 +- PxWeb/PxWeb.csproj | 2 +- PxWebApi.BigTests/PxWebApi.BigTests.csproj | 2 +- README.md | 4 +- global.json | 2 +- 9 files changed, 41 insertions(+), 31 deletions(-) diff --git a/Dockerfile b/Dockerfile index a944d798..191b4fd5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,39 @@ -FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS base -WORKDIR /app -EXPOSE 8080 +# Learn about building .NET container images: +# https://github.com/dotnet/dotnet-docker/blob/main/samples/README.md +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0.203-alpine3.19 AS build +ARG TARGETARCH +WORKDIR /source -ENV DOTNET_EnableDiagnostics=0 -ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false -ENV ASPNETCORE_URLS=http://*:8080 +COPY . . +RUN dotnet restore -a $TARGETARCH -RUN apk add --no-cache icu-libs -# Creates a non-root user with an explicit UID and adds permission to access the /app folder -# For more info, please refer to https://aka.ms/vscode-docker-dotnet-configure-containers -RUN adduser -u 1000 --disabled-password --gecos "" appuser && chown -R appuser /app -USER 1000 +RUN dotnet publish -a $TARGETARCH --no-restore -o /app "PxWeb/PxWeb.csproj" -FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build -WORKDIR /src -COPY . . -RUN dotnet restore "PxWeb.sln" -RUN dotnet build "PxWeb/PxWeb.csproj" -c Release -o /app/build -FROM build AS publish -RUN dotnet publish "PxWeb/PxWeb.csproj" -c Release -o /app/publish +# Enable globalization and time zones: +# https://github.com/dotnet/dotnet-docker/blob/main/samples/enable-globalization.md +# final stage/image +FROM mcr.microsoft.com/dotnet/aspnet:8.0.3-alpine3.19 +EXPOSE 8080 + +ENV \ + DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \ + LC_ALL=en_US.UTF-8 \ + LANG=en_US.UTF-8 \ + DOTNET_EnableDiagnostics=0 \ + ASPNETCORE_HTTP_PORTS=8080 \ + ASPNETCORE_ENVIRONMENT=Production +RUN apk add --no-cache \ + icu-data-full \ + icu-libs -FROM base AS final WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "PxWeb.dll"] + +# Creates a non-root user with an explicit UID and adds permission to access the /app folder +# For more info, please refer to https://aka.ms/vscode-docker-dotnet-configure-containers +#RUN adduser -u 1000 --disabled-password --gecos "" appuser && chown -R appuser /app +#USER 1000 + +COPY --from=build /app . +USER $APP_UID +ENTRYPOINT [ "./PxWeb" ] diff --git a/Px.Abstractions/Px.Abstractions.csproj b/Px.Abstractions/Px.Abstractions.csproj index 59af71e8..336ccf88 100644 --- a/Px.Abstractions/Px.Abstractions.csproj +++ b/Px.Abstractions/Px.Abstractions.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable diff --git a/Px.Search.Lucene/Px.Search.Lucene.csproj b/Px.Search.Lucene/Px.Search.Lucene.csproj index 8d15423c..570b45ea 100644 --- a/Px.Search.Lucene/Px.Search.Lucene.csproj +++ b/Px.Search.Lucene/Px.Search.Lucene.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 enable enable diff --git a/Px.Search/Px.Search.csproj b/Px.Search/Px.Search.csproj index 4fa2240d..26e62f3f 100644 --- a/Px.Search/Px.Search.csproj +++ b/Px.Search/Px.Search.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable diff --git a/PxWeb.UnitTests/PxWeb.UnitTests.csproj b/PxWeb.UnitTests/PxWeb.UnitTests.csproj index bc0bec77..225aca52 100644 --- a/PxWeb.UnitTests/PxWeb.UnitTests.csproj +++ b/PxWeb.UnitTests/PxWeb.UnitTests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable false diff --git a/PxWeb/PxWeb.csproj b/PxWeb/PxWeb.csproj index 0dddfca5..062c4b5a 100644 --- a/PxWeb/PxWeb.csproj +++ b/PxWeb/PxWeb.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable disabled diff --git a/PxWebApi.BigTests/PxWebApi.BigTests.csproj b/PxWebApi.BigTests/PxWebApi.BigTests.csproj index d5504b96..2310806b 100644 --- a/PxWebApi.BigTests/PxWebApi.BigTests.csproj +++ b/PxWebApi.BigTests/PxWebApi.BigTests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 enable true false diff --git a/README.md b/README.md index d96ef005..dc5a7256 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,4 @@ We use [dotnet format](https://github.com/dotnet/format) to clean the source cod If you don't want to manually run `dotnet format` or Code Cleanup in Visual Studio you can use git [pre-commit](https://pre-commit.com/). After installing pre-commit for your operating system, run `pre-commit install`from the root of this repo and you're done. -The rules for formatting are set in the [.editorconfig]([.editorconfig]) file. Visual Studio supports this automatically, and for VS Code we have the [EditorConfig extension](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig). - -More information on [EditorConfig](https://editorconfig.org/) +The rules for formatting are set in the [.editorconfig](.editorconfig) file. Visual Studio supports this automatically, and for VS Code we have the [EditorConfig extension](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig). More information on [EditorConfig](https://editorconfig.org/) diff --git a/global.json b/global.json index 2ca974fe..090e95c7 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.100", + "version": "8.0.100", "rollForward": "latestFeature" } }