# syntax=docker/dockerfile:1.7 # # Encelado — immagine del bot (motore + interfaccia web su Kestrel). # # Tre stadi: build (restore + compilazione), test (la suite xunit gira dentro la # build: un'immagine con i test rossi non esiste), publish (framework-dependent, # non trimmed: il server ospita ASP.NET Core minimal e non è AOT). Il runtime è # l'immagine ufficiale aspnet, con gosu per scendere ai PUID/PGID di Unraid. # # docker build -t 192.168.30.23:3000/alby96/encelado:5.1.0 --build-arg GIT_COMMIT=$(git rev-parse --short=12 HEAD) . # docker run -p 8080:8080 -v ./config:/config -v ./data:/data -e ENCELADO_PASSWORD=… 192.168.30.23:3000/alby96/encelado:5.1.0 # # L'unica variabile da dare al container è ENCELADO_PASSWORD (la password # dell'interfaccia): tutto il resto si imposta dall'interfaccia. Le ENV qui sotto sono # interne all'immagine (PUID/PGID/TZ restano i default di Unraid e UTC). # # Vedi docs/DOCKER.md per volumi, variabili, healthcheck e aggiornamento. ARG DOTNET_VERSION=10.0 # ---------------------------------------------------------------- build FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS build ARG GIT_COMMIT=n/d WORKDIR /src # Prima i file di progetto, così il restore resta in cache finché non cambiano. COPY Directory.Build.props Encelado.slnx ./ COPY src/Encelado.Core/Encelado.Core.csproj src/Encelado.Core/ COPY src/Encelado.Etoro/Encelado.Etoro.csproj src/Encelado.Etoro/ COPY src/Encelado.Engine/Encelado.Engine.csproj src/Encelado.Engine/ COPY src/Encelado.Server/Encelado.Server.csproj src/Encelado.Server/ COPY tools/Encelado.Backtest/Encelado.Backtest.csproj tools/Encelado.Backtest/ COPY tests/Encelado.Tests/Encelado.Tests.csproj tests/Encelado.Tests/ RUN dotnet restore Encelado.slnx COPY . . RUN dotnet build Encelado.slnx -c Release --no-restore -p:GitCommit=${GIT_COMMIT} # ---------------------------------------------------------------- test FROM build AS test RUN dotnet test tests/Encelado.Tests -c Release --no-build --nologo -v q # ---------------------------------------------------------------- publish FROM build AS publish ARG GIT_COMMIT=n/d # Dipende dallo stadio test solo per ordine: la publish parte se i test sono verdi. COPY --from=test /src/tests/Encelado.Tests/bin/Release/net10.0/Encelado.Tests.dll /tmp/tests-ok RUN dotnet publish src/Encelado.Server/Encelado.Server.csproj -c Release --no-build --no-restore -p:GitCommit=${GIT_COMMIT} -o /app # ---------------------------------------------------------------- runtime FROM mcr.microsoft.com/dotnet/aspnet:${DOTNET_VERSION} AS runtime ARG VERSION=dev ARG GIT_COMMIT=n/d LABEL org.opencontainers.image.title="Encelado" \ org.opencontainers.image.description="Correlation Baskets su eToro: motore, ledger e interfaccia web" \ 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/Encelado" # gosu per cambiare utente dopo aver sistemato i permessi; tzdata per TZ; curl # non serve: il healthcheck è il server stesso con --health. RUN apt-get update \ && apt-get install -y --no-install-recommends gosu tzdata ca-certificates \ && rm -rf /var/lib/apt/lists/* ENV ENCELADO_IN_CONTAINER=1 \ ENCELADO_WEB_PORT=8080 \ DOTNET_gcServer=1 \ DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 \ ASPNETCORE_URLS= \ ASPNETCORE_HTTP_PORTS= \ TZ=UTC \ PUID=99 \ PGID=100 WORKDIR /app COPY --from=publish /app ./ COPY deploy/docker/entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh && mkdir -p /config /data VOLUME ["/config", "/data"] EXPOSE 8080 # Il server risponde da solo alla sonda: GET /api/health sulla porta configurata. HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ CMD ["dotnet", "/app/Encelado.Server.dll", "--health"] # SIGTERM arriva al processo dotnet (exec nell'entrypoint): stop pulito, ledger # chiuso, posizioni lasciate sul conto con gli stop nativi (closeOnShutdown). STOPSIGNAL SIGTERM ENTRYPOINT ["/entrypoint.sh"] CMD ["dotnet", "/app/Encelado.Server.dll"]