21e865ffb0
Espone la GUI Streamlit su https://cerbero-bite.tielogic.xyz tramite il Traefik già attivo sull'host (label allineate al pattern di cerbero-mcp, TLS via Let's Encrypt, websocket pass-through). Aggiunge: - nuova tab `📚 Strategia` con stato live dei gate §2 confrontati con l'ultimo tick di market_snapshots, pannello P/L parametrico affiancato Conservativa vs Aggressiva, tabella di sensibilità win-rate → APR e rendering del documento canonico esteso. - doc `13-strategia-spiegata.md` che lega ogni regola §2-§9 al campo di market_snapshots che la alimenta, con sezioni §4-bis (P/L atteso realistico, win-rate empirico, drawdown, Sharpe) e §4-ter (confronto fra i due profili e quando passare dall'uno all'altro). - `strategy.conservativa.yaml` (golden config v1.0.0 esplicita) e `strategy.aggressiva.yaml` (cap_per_trade 4×, max_concurrent 2×, max_contracts 4×, deroga §11 documentata) con config_hash validi. - nel compose: servizio dedicato `cerbero-bite-gui` (Streamlit su 0.0.0.0:8765, healthcheck su /_stcore/health, label Traefik), env condivisi via anchor YAML `x-bite-env`, `--environment mainnet` passato a `start` per allineare il boot check al token del .env (era testnet vs mainnet → kill switch armato all'avvio). - Dockerfile installa anche l'extra `gui` (streamlit) e copia `docs/` + i due nuovi profili nell'immagine; `.dockerignore` non esclude più `docs/` (causa del primo build silenzioso). Fix bonus: `_try_load` nella pagina ritornava `LoadedConfig` ma la GUI leggeva `.sizing.*` direttamente — l'`except: pass` mascherava l'AttributeError facendo cadere sui default conservativi sia nel pannello P/L sia nello stato gate (stesso pattern presente nella Calibrazione). Ora ritorna `.config`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
64 lines
2.0 KiB
Docker
64 lines
2.0 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
FROM python:3.13-slim AS builder
|
|
|
|
# uv ships static binaries; pin a version for reproducibility.
|
|
COPY --from=ghcr.io/astral-sh/uv:0.4.27 /uv /usr/local/bin/uv
|
|
|
|
WORKDIR /app
|
|
|
|
ENV UV_PROJECT_ENVIRONMENT=/opt/venv \
|
|
UV_LINK_MODE=copy \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1
|
|
|
|
# Install only the dependencies first so the layer is cached when the
|
|
# source tree changes.
|
|
COPY pyproject.toml uv.lock ./
|
|
RUN uv sync --frozen --no-dev --no-install-project --extra gui
|
|
|
|
# Now copy the source tree and install the project itself.
|
|
COPY src ./src
|
|
COPY README.md ./
|
|
RUN uv sync --frozen --no-dev --extra gui
|
|
|
|
|
|
FROM python:3.13-slim AS runtime
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends sqlite3 ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Non-root user with a stable UID for volume permissions.
|
|
RUN useradd --system --uid 10001 --home-dir /app --shell /usr/sbin/nologin bite
|
|
WORKDIR /app
|
|
|
|
ENV PATH=/opt/venv/bin:$PATH \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1
|
|
|
|
COPY --from=builder /opt/venv /opt/venv
|
|
COPY --from=builder /app/src /app/src
|
|
COPY scripts /app/scripts
|
|
COPY strategy.yaml /app/strategy.yaml
|
|
# Profili alternativi confrontati nella pagina "📚 Strategia".
|
|
COPY strategy.conservativa.yaml /app/strategy.conservativa.yaml
|
|
COPY strategy.aggressiva.yaml /app/strategy.aggressiva.yaml
|
|
# Documentation is shipped at runtime so the Streamlit "Strategia"
|
|
# page can render the canonical strategy doc directly.
|
|
COPY docs /app/docs
|
|
|
|
# Persistent state + audit go into /app/data, mounted as a volume in
|
|
# docker-compose.yml.
|
|
RUN mkdir -p /app/data/log /app/data/backups \
|
|
&& chown -R bite:bite /app
|
|
|
|
USER bite
|
|
|
|
# The healthcheck rides on the same Click entrypoint: it queries the
|
|
# SQLite singleton and exits 0/1 based on kill_switch + last_health_check.
|
|
HEALTHCHECK --interval=60s --timeout=5s --start-period=120s --retries=3 \
|
|
CMD ["cerbero-bite", "healthcheck", "--db", "/app/data/state.sqlite"]
|
|
|
|
ENTRYPOINT ["cerbero-bite"]
|
|
CMD ["status"]
|