Files
momentum-system/Dockerfile
T
momentum devandClaude Fable 5 82273d9d4e feat: image version identity + DB-config parity for nightly scripts
Version: CI now tags images YYYY.MM.DD-<shortsha> alongside :latest/:sha
and passes GIT_SHA/BUILD_TAG build-args; the running app reports them via
dashboard /api/health and admin /api/status (TrueNAS custom apps only show
'custom/1.0.0', so the app self-reports what it actually runs).

Config parity: every scheduler-run script (nightly_tune, eod_replay,
premarket_eval, regime, market_context, experiments cli) now loads
config_overrides at startup like the live services do — a bare env would
replay under DEFAULT exits (the documented 4.5x-baseline landmine).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-22 23:28:06 -05:00

53 lines
1.9 KiB
Docker

# Momentum System — container image
#
# Single image for every run mode (the app is a monolith run from the repo root
# with PYTHONPATH=/app, not a pip-installed wheel — see pyproject.toml
# `package = false`). The Kubernetes workloads override CMD:
# - app Deployment : python run_live_paper.py (loop + embedded dashboard)
# - CronJobs : python eod_replay.py / nightly_tune.py / momentum_cli.py journal
FROM python:3.13-slim
# psycopg2-binary ships its own libpq, so no build toolchain is needed; we only
# add a tiny client for healthchecks/debugging and clean up the apt cache.
# ffmpeg: yt-dlp audio extraction for the transcripts pipeline; curl: healthchecks
RUN apt-get update \
&& apt-get install -y --no-install-recommends libpq5 ffmpeg curl \
&& rm -rf /var/lib/apt/lists/*
# Image identity: CI passes the git sha + a date tag so the RUNNING app can
# report exactly what it is (TrueNAS custom apps show only 'custom/1.0.0').
ARG GIT_SHA=dev
ARG BUILD_TAG=dev
ENV APP_GIT_SHA=$GIT_SHA \
APP_BUILD_TAG=$BUILD_TAG
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH=/app \
PIP_NO_CACHE_DIR=1 \
TZ=America/New_York
WORKDIR /app
# Install dependencies first so they cache across code-only changes.
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt \
# transcripts pipeline (CPU whisper); heavy layer, cached separately
&& pip install --no-cache-dir faster-whisper yt-dlp
# Application code.
COPY . .
# Run as a non-root user that owns the writable data dir (DuckDB research file,
# logs, learned_params.json, schwab tokens). In K8s this path is a mounted PVC.
RUN useradd --create-home --uid 10001 app \
&& mkdir -p /app/data \
&& chown -R app:app /app/data
USER app
EXPOSE 8765
# Default to the headless loop; the chart's app Deployment runs it WITH the
# dashboard, and the CronJobs override this entirely.
CMD ["python", "run_live_paper.py", "--no-dashboard"]