Files
Anubis/deploy/docker/Dockerfile
T
Alby96andClaude Opus 5.5 1bc7e067fd
ci / test (postgres) (push) Successful in 4m50s
ci / test (sqlite) (push) Failing after 4m21s
ci / image (push) Skipped
Fase 10 — Nuova rotta: solo Docker (#184)
ADR 0021-0026 for the new course of 2 December 2026, roadmap of phases 10-24. The desktop application is gone: Docker is the only form, and outside a container the server runs only for development and tests with --data-dir, on this computer only. Lighter image (829 MB to 410 MB), rotating logs, backtest and learning as one-shot commands.

refs #113 #114 #115 #78 #80 #81

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
2026-12-03 19:59:00 +01:00

56 lines
3.6 KiB
Docker

# Anubis image (ADR 0003, SPEC 15.2). Build from the repository root:
# docker build -f deploy/docker/Dockerfile -t gitea.encke-hake.ts.net/balbosoft/anubis:dev .
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY global.json Directory.Build.props Directory.Build.targets Directory.Packages.props ./
COPY src/Anubis/Anubis.csproj src/Anubis/packages.lock.json src/Anubis/
COPY src/Anubis.Server/Anubis.Server.csproj src/Anubis.Server/packages.lock.json src/Anubis.Server/
COPY src/Anubis.Guard/Anubis.Guard.csproj src/Anubis.Guard/packages.lock.json src/Anubis.Guard/
# Only Linux x64 (ADR 0022): the native libraries of the other platforms stay out of the image.
RUN dotnet restore src/Anubis.Server/Anubis.Server.csproj -r linux-x64 --locked-mode && \
dotnet restore src/Anubis.Guard/Anubis.Guard.csproj -r linux-x64 --locked-mode
COPY src/Anubis/ src/Anubis/
COPY src/Anubis.Server/ src/Anubis.Server/
COPY src/Anubis.Guard/ src/Anubis.Guard/
# The logo is embedded from docs/design/logo, its only source (ADR 0005).
COPY docs/design/logo/ docs/design/logo/
# The backtest outcomes are read at the first start (SPEC 12.3); .dockerignore lets only their JSON files through.
COPY docs/backtests/ docs/backtests/
COPY docs/learning/ docs/learning/
# The commit goes into the version shown by the diagnostics report; empty when not given.
ARG ANUBIS_COMMIT=
RUN dotnet publish src/Anubis.Server/Anubis.Server.csproj -c Release -r linux-x64 --self-contained false --no-restore -o /app ${ANUBIS_COMMIT:+-p:SourceRevisionId=$ANUBIS_COMMIT}
# The guard (SPEC 9.3, ADR 0012) is the main process and starts the engine next to it, from the same folder.
RUN dotnet publish src/Anubis.Guard/Anubis.Guard.csproj -c Release -r linux-x64 --self-contained false --no-restore -o /app ${ANUBIS_COMMIT:+-p:SourceRevisionId=$ANUBIS_COMMIT}
# No Windows library in /app (Directory.Build.targets): if one comes back, the image does not build.
RUN if ls /app | grep -qiE '^onnxruntime.*\.dll$'; then echo "Librerie di Windows in /app" >&2; exit 1; fi
FROM mcr.microsoft.com/dotnet/aspnet:10.0
WORKDIR /app
COPY --from=build /app ./
COPY --chmod=755 deploy/docker/entrypoint.sh /usr/local/bin/anubis-entrypoint
# The port comes from PORT (8787 by default), read by the app; the base image's own port setting is cleared. The base
# image also sets DOTNET_RUNNING_IN_CONTAINER=true: server and guard know by themselves they are in the container (ADR 0022).
ENV ASPNETCORE_HTTP_PORTS= \
TZ=Europe/Rome \
PUID=99 \
PGID=100
EXPOSE 8787
VOLUME /data
# Starts as root only to give /data to PUID:PGID, then runs the guard as that user (entrypoint.sh); the guard starts
# the engine. "docker run --rm <image> drill" runs the guard drill instead (issue #48).
# Health through bash's /dev/tcp: no curl or wget in the image. 503 (database down, loops stopped, no prices) counts as unhealthy.
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD ["bash", "-c", "exec 3<>/dev/tcp/127.0.0.1/${PORT:-8787} && printf 'GET /health HTTP/1.0\r\nHost: localhost\r\n\r\n' >&3 && head -n 1 <&3 | grep -q ' 200 '"]
ENTRYPOINT ["anubis-entrypoint"]
ARG ANUBIS_VERSION=dev
ARG ANUBIS_COMMIT=
LABEL org.opencontainers.image.title="Anubis" \
org.opencontainers.image.description="Bot di trading personale: azioni USA e crypto spot, senza leva" \
org.opencontainers.image.vendor="BalboSoft" \
org.opencontainers.image.url="https://gitea.encke-hake.ts.net/BalboSoft/Anubis" \
org.opencontainers.image.source="https://gitea.encke-hake.ts.net/BalboSoft/Anubis" \
org.opencontainers.image.version="$ANUBIS_VERSION" \
org.opencontainers.image.revision="$ANUBIS_COMMIT"