# syntax=docker/dockerfile:1.7 # # Mimante: un solo container con motore, interfaccia web e Chromium per l'accesso # assistito a Bidoo. # # docker build -f docker/Dockerfile --build-arg VERSION=2.0.0 --build-arg GIT_COMMIT=$(git rev-parse --short=12 HEAD) -t mimante:2.0.0 . # # Stadi: build (restore + compilazione), test (i test di logica pura; quelli su PostgreSQL # saltano da soli senza TEST_DB_HOST), publish (ReadyToRun per linux-x64), runtime. # # Il runtime è Debian 13 con il runtime ASP.NET copiato dall'immagine ufficiale: per .NET 10 # Microsoft pubblica solo immagini Ubuntu/Alpine/Azure Linux, e su Ubuntu «apt install # chromium» installa soltanto il rimando a snap, che in un container non funziona. Su Debian # il pacchetto chromium è il browser vero (docs/adr/0010-immagine-debian-con-runtime-copiato.md). ARG DOTNET_VERSION=10.0 # ─────────────────────────────────────────────────────────────── build FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS build WORKDIR /src COPY Directory.Build.props Directory.Packages.props Mimante.slnx ./ COPY src/Mimante/Mimante.csproj src/Mimante/ COPY tests/Mimante.Tests/Mimante.Tests.csproj tests/Mimante.Tests/ RUN dotnet restore src/Mimante/Mimante.csproj -r linux-x64 \ && dotnet restore tests/Mimante.Tests/Mimante.Tests.csproj COPY src/ src/ COPY tests/ tests/ RUN dotnet build tests/Mimante.Tests/Mimante.Tests.csproj -c Release --no-restore -nologo # ─────────────────────────────────────────────────────────────── test FROM build AS test # Le prove della CI (Packaging) leggono .gitea, che non entra nel contesto di costruzione: girano nel lavoro «prove». # Anche quelle sui tempi (PrecisionWait) girano solo lì: dentro buildx i core sono condivisi con la # compilazione e la misura al millisecondo non dice nulla del codice. RUN dotnet test tests/Mimante.Tests/Mimante.Tests.csproj -c Release --no-build --nologo -v q \ --filter "FullyQualifiedName!~Mimante.Tests.Packaging&FullyQualifiedName!~Mimante.Tests.PrecisionWaitTests" \ && touch /tmp/test-ok # ─────────────────────────────────────────────────────────────── publish FROM build AS publish # La publish parte solo con i test verdi. COPY --from=test /tmp/test-ok /tmp/test-ok RUN dotnet publish src/Mimante/Mimante.csproj -c Release -r linux-x64 --self-contained false \ -p:PublishReadyToRun=true -nologo -o /app # ─────────────────────────────────────────────────────────────── runtime ASP.NET FROM mcr.microsoft.com/dotnet/aspnet:${DOTNET_VERSION} AS dotnet # ─────────────────────────────────────────────────────────────── runtime FROM debian:trixie-slim AS runtime ARG VERSION=dev ARG GIT_COMMIT=n/d LABEL org.opencontainers.image.title="mimante" \ org.opencontainers.image.description="Mimante: segue le aste al centesimo di Bidoo, decide con un modello appreso se puntare. Le aste entrano in Osserva." \ org.opencontainers.image.version="${VERSION}" \ org.opencontainers.image.revision="${GIT_COMMIT}" \ org.opencontainers.image.authors="Alberto Balbo" \ org.opencontainers.image.source="http://192.168.30.23:3000/Alby96/Mimante" # Dipendenze del runtime .NET (ICU, OpenSSL, zlib), fuso orario, certificati, Chromium con # i caratteri per l'accesso assistito, setpriv (util-linux) per scendere a PUID/PGID. RUN apt-get update \ && apt-get install -y --no-install-recommends \ ca-certificates tzdata libicu76 libssl3t64 libstdc++6 zlib1g libgcc-s1 \ chromium fonts-liberation util-linux \ && rm -rf /var/lib/apt/lists/* COPY --from=dotnet /usr/share/dotnet /usr/share/dotnet RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet ENV DOTNET_ROOT=/usr/share/dotnet \ DOTNET_gcServer=0 \ DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=0 \ DOTNET_NOLOGO=1 \ ASPNETCORE_URLS= \ ASPNETCORE_HTTP_PORTS= \ PORT=8080 \ TZ=Europe/Rome \ PUID=99 \ PGID=100 WORKDIR /app COPY --from=publish /app ./ COPY docker/entrypoint.sh /entrypoint.sh RUN sed -i 's/\r$//' /entrypoint.sh && chmod +x /entrypoint.sh && mkdir -p /config VOLUME ["/config"] EXPOSE 8080 # /salute risponde 200 solo con configurazione e database a posto. Nell'immagine non c'è # curl: la sonda è il programma stesso con --salute. HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD ["dotnet", "/app/Mimante.dll", "--salute"] # SIGTERM arriva al processo dotnet (exec nell'entrypoint): spegnimento ordinato in 10 s. STOPSIGNAL SIGTERM ENTRYPOINT ["/entrypoint.sh"] CMD ["dotnet", "/app/Mimante.dll"]