feat(finlab): console Claude Code finance in-cluster + toolkit d'analyse (#64)

* feat(finlab): console Claude Code finance in-cluster + toolkit d'analyse

Intègre finlab (ex-projet Projets/Finance) au lab comme une console Claude Code
web spécialisée finance — l'esprit OpenAlice, mais c'est le vrai Claude Code sur
l'abonnement (login persisté, pas d'API facturée), agentique, avec la boîte à
outils finlab (Yahoo Finance) branchée en MCP.

- tools/finlab/ : source finlab rapatriée + Dockerfile (Python 3.12 + Node +
  claude-code + ttyd) + persona workspace/CLAUDE.md + branchement MCP + entrypoint
  (seed du workspace no-clobber sur le PVC)
- .github/workflows/build-finlab.yml : build GHCR funk-finlab + bump manifest (main)
- k8s/apps/finlab/ : Deployment/Service/PVC/IngressRoute (finance.lab.local) +
  Middleware basicAuth (shell web protégé) ; PVC = HOME (login) + workspace
- k8s/apps-of-apps/apps/finlab.yaml : Application ArgoCD
- .mcp.json (racine) : outils finlab dans les sessions Claude Code du lab
- admin/ia/finlab.md + READMEs + CLAUDE.md : doc + enregistrement

Analyse/aide à la décision uniquement — aucun ordre réel (paper trading Alpaca
fictif seul exécutable).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(finlab): ttyd absent des dépôts bookworm → binaire statique GitHub

Le build amont échouait (`E: Package 'ttyd' has no installation candidate`) :
ttyd n'est pas packagé dans Debian bookworm. On récupère le binaire statique
(musl, pin TTYD_VERSION=1.7.7) depuis les releases GitHub. Build complet validé
en local (podman) : ttyd 1.7.7, claude-code 2.1.195, import finlab + seed OK.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ALI YESILKAYA 2026-06-29 23:26:09 +02:00 committed by GitHub
parent 35ad1deb64
commit 54f6f7c634
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 2115 additions and 2 deletions

55
tools/finlab/Dockerfile Normal file
View file

@ -0,0 +1,55 @@
# funk-finlab — console Claude Code web, spécialisée finance.
#
# Une vraie session Claude Code (sur l'ABONNEMENT de l'utilisateur, login persisté sur le
# PVC) servie dans un terminal web (ttyd), dans un workspace où vit la boîte à outils finlab
# (exposée en MCP). C'est l'esprit OpenAlice, mais c'est Claude Code + le toolkit maison —
# aucune facturation API, aucun broker, lecture/analyse uniquement.
FROM python:3.12-slim-bookworm
# Node (pour le CLI claude-code) + git + tini (PID 1 propre). ttyd n'est PAS dans les dépôts
# Debian bookworm → on récupère le binaire statique (musl) depuis les releases GitHub (pin).
ARG TTYD_VERSION=1.7.7
RUN apt-get update && apt-get install -y --no-install-recommends \
curl ca-certificates git tini procps \
&& curl -fsSL "https://github.com/tsl0922/ttyd/releases/download/${TTYD_VERSION}/ttyd.x86_64" \
-o /usr/local/bin/ttyd \
&& chmod +x /usr/local/bin/ttyd \
&& ttyd --version \
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& npm install -g @anthropic-ai/claude-code \
&& npm cache clean --force \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Dépendances Python de finlab dans un venv dédié (séparé du workspace, donc non altérable
# depuis la session). finlab lui-même est importé depuis le workspace (PYTHONPATH au runtime).
COPY requirements.txt /opt/finlab/requirements.txt
RUN python -m venv /opt/venv \
&& /opt/venv/bin/pip install --no-cache-dir -r /opt/finlab/requirements.txt
# « Seed » du workspace : copié dans le PVC au premier boot (sans écraser les edits ensuite).
# Contient le code finlab, les configs (portefeuille/watchlists/alertes), la persona Claude
# (CLAUDE.md), le branchement MCP finlab et les réglages d'autorisation.
COPY finlab/ /opt/seed/finlab/
COPY webapp/ /opt/seed/webapp/
COPY portfolio.yaml watchlists.yaml alerts.yaml /opt/seed/
COPY workspace/CLAUDE.md /opt/seed/CLAUDE.md
COPY workspace/.mcp.json /opt/seed/.mcp.json
COPY workspace/.claude/ /opt/seed/.claude/
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# uid non-root (PodSecurity « restricted » du namespace ai). HOME et workspace vivent sur le
# PVC monté en /home/finlab : ainsi ~/.claude (login abonnement) ET le workspace persistent.
RUN useradd -m -u 1000 -s /bin/bash finlab
ENV HOME=/home/finlab \
WORKSPACE=/home/finlab/workspace \
PATH=/opt/venv/bin:/usr/local/bin:/usr/bin:/bin \
PYTHONPATH=/home/finlab/workspace \
PYTHONUNBUFFERED=1 \
TZ=Europe/Paris
USER 1000
WORKDIR /home/finlab/workspace
EXPOSE 7681
ENTRYPOINT ["tini", "--", "/usr/local/bin/entrypoint.sh"]