From 35212b439a49c50e3e2d66e623414a5cbc3cda32 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Mon, 6 Jan 2025 22:44:49 -0500 Subject: [PATCH 1/2] PeopleService (.NET): decrease container size and improve security posture --- people-service/Dockerfile | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/people-service/Dockerfile b/people-service/Dockerfile index 3ce0cde5..2be06106 100644 --- a/people-service/Dockerfile +++ b/people-service/Dockerfile @@ -1,22 +1,20 @@ -# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/dotnet/.devcontainer/base.Dockerfile +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-noble AS build +ARG TARGETARCH +WORKDIR /source +COPY PeopleService.WebApi/PeopleService.WebApi.csproj PeopleService.WebApi/ +COPY PeopleService.Core/PeopleService.Core.csproj PeopleService.Core/ +RUN dotnet restore PeopleService.WebApi/PeopleService.WebApi.csproj -a $TARGETARCH +COPY PeopleService.WebApi/ PeopleService.WebApi/ +COPY PeopleService.Core/ PeopleService.Core/ -# [Choice] .NET version: 8.0 /8.0-bookworm, 8.0-jammy, 7.0 /7.0-bookworm, 7.0-bullseye, 7.0-jammy, 6.0 /6.0-bookworm, 6.0-bullseye, 6.0-jammy, 6.0-focal -ARG VARIANT="8.0" -FROM mcr.microsoft.com/vscode/devcontainers/dotnet:${VARIANT} - -WORKDIR /people-service -COPY . . +FROM build AS publish +WORKDIR /source/PeopleService.WebApi +RUN dotnet publish PeopleService.WebApi.csproj -p:PublishSingleFile=true -a $TARGETARCH --self-contained true -c release -o /app +FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-noble-chiseled +WORKDIR /app +COPY --from=publish /app . EXPOSE 18089 - -# [Choice] Node.js version: none, lts/*, 18, 16, 14 -ARG NODE_VERSION="18" -RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi - -# [Optional] Uncomment this section to install additional OS packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends - -# [Optional] Uncomment this line to install global node packages. -# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 -ENTRYPOINT cd PeopleService.WebApi && dotnet run \ No newline at end of file +ENV ASPNETCORE_HTTP_PORTS=18089 +ENV ASPNETCORE_ENVIRONMENT=Development +ENTRYPOINT ["./PeopleService.WebApi"] From 4d66dbc74da8455a7e92b9fef5d7a5ca6666782c Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Mon, 6 Jan 2025 22:58:36 -0500 Subject: [PATCH 2/2] Fix typo on Logon to test PeopleService --- people-service/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/people-service/README.md b/people-service/README.md index 4a782fb1..5f09ce13 100644 --- a/people-service/README.md +++ b/people-service/README.md @@ -26,4 +26,4 @@ Visit the forwarded port `/swagger` to open the SwaggerUI. Example URL: -`/People/GetPerson?LoginId=user01` +`/People/GetPerson?LogonId=user01`