feat: обновил Dockerfile и добавил проверку для работы в контейнере
Create and publish a Docker image / Publish image (push) Successful in 2m48s

This commit is contained in:
serega404 committed 2026-10-12 13:46:08 +03:00
1 parent 7e27b0742b
commit f5d5b0f68f
3 files changed
+29 -18

No files matched your search

+1 -1
View File
@@ -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)
## Зачем нужен этот сервис
+22 -17
View File
@@ -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"]
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "ModeusSchedule.MSAuth.dll"]
+6
View File
@@ -123,6 +123,12 @@ public class MicrosoftAuthService(ILogger<MicrosoftAuthService> logger, IConfigu
try
{
if (_browsersEnsured) return;
if (string.Equals(Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER"), "true", StringComparison.OrdinalIgnoreCase))
{
// В Docker браузер и его зависимости уже установлены при сборке образа.
_browsersEnsured = true;
return;
}
try
{
// Устанавливаем Chromium, если не установлен