diff --git a/README.md b/README.md index 76c041f..48b34b7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Макросервис авторизации в Modeus через Microsoft [![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE) -[![.NET](https://img.shields.io/badge/.NET-9.0-blue.svg)](https://dotnet.microsoft.com/download/dotnet/9.0) +[![.NET](https://img.shields.io/badge/.NET-10.0-blue.svg)](https://dotnet.microsoft.com/download/dotnet/10.0) ## Зачем нужен этот сервис diff --git a/src/Dockerfile b/src/Dockerfile index 50d3618..1de7f2a 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -1,24 +1,29 @@ -FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine3.24 AS build -ARG BUILD_CONFIGURATION=Release +FROM mcr.microsoft.com/dotnet/sdk:10.0-noble AS restore WORKDIR /src -COPY . . -RUN dotnet restore "ModeusSchedule.MSAuth.csproj" -RUN dotnet publish "ModeusSchedule.MSAuth.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false +COPY ModeusSchedule.MSAuth.csproj . +RUN dotnet restore "ModeusSchedule.MSAuth.csproj" && \ + set -- /root/.nuget/packages/microsoft.playwright/*/.playwright && \ + test "$#" -eq 1 && \ + mkdir -p /opt/playwright/node && \ + cp -a "$1/package" /opt/playwright/ && \ + cp -a "$1/node/linux-x64" /opt/playwright/node/ && \ + cp -a "$1/node/LICENSE" /opt/playwright/node/ && \ + chmod +x /opt/playwright/node/linux-x64/node -FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final +FROM restore AS build +ARG BUILD_CONFIGURATION=Release +COPY . . +RUN dotnet publish "ModeusSchedule.MSAuth.csproj" -c "$BUILD_CONFIGURATION" --no-restore -o /app/publish /p:UseAppHost=false && \ + rm -rf /app/publish/.playwright /app/publish/playwright.ps1 + +FROM mcr.microsoft.com/dotnet/aspnet:10.0-noble AS final EXPOSE 8080 WORKDIR /app - -RUN apt-get update && \ - apt-get install -y --no-install-recommends wget && \ - wget -q https://github.com/PowerShell/PowerShell/releases/download/v7.5.2/powershell_7.5.2-1.deb_amd64.deb && \ - apt-get install -y ./powershell_7.5.2-1.deb_amd64.deb && \ - rm -f powershell_7.5.2-1.deb_amd64.deb && \ - rm -rf /var/lib/apt/lists/* - ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright -COPY --from=build /app/publish . -RUN pwsh ./playwright.ps1 install --with-deps chromium +COPY --from=restore /opt/playwright ./.playwright +RUN ./.playwright/node/linux-x64/node ./.playwright/package/cli.js install --with-deps --only-shell chromium && \ + rm -rf /var/lib/apt/lists/* -ENTRYPOINT ["dotnet", "ModeusSchedule.MSAuth.dll"] \ No newline at end of file +COPY --from=build /app/publish . +ENTRYPOINT ["dotnet", "ModeusSchedule.MSAuth.dll"] diff --git a/src/Services/MicrosoftAuthService.cs b/src/Services/MicrosoftAuthService.cs index 39920b1..abde723 100644 --- a/src/Services/MicrosoftAuthService.cs +++ b/src/Services/MicrosoftAuthService.cs @@ -123,6 +123,12 @@ public class MicrosoftAuthService(ILogger logger, IConfigu try { if (_browsersEnsured) return; + if (string.Equals(Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER"), "true", StringComparison.OrdinalIgnoreCase)) + { + // В Docker браузер и его зависимости уже установлены при сборке образа. + _browsersEnsured = true; + return; + } try { // Устанавливаем Chromium, если не установлен