OpenMind v1 : cartes mentales libres, local-first et dockerisees
Premiere version fonctionnelle, demarrable avec `docker compose up -d --build` sur http://localhost:8080. Architecture - Frontend React 18 / TypeScript strict / Vite / Tailwind, canvas @xyflow/react, etat Zustand, persistance IndexedDB via Dexie, auto-layout dagre. - Backend FastAPI / SQLAlchemy 2 / Pydantic v2 / SQLite, qui sert aussi les fichiers statiques du frontend compile. - Image Docker multi-stage, un seul service, bind mount ./data pour SQLite. Local-first Les cartes restent dans le navigateur. Le serveur ne recoit une carte que sur demande explicite de partage. Partage Deux secrets distincts : share_token public en lecture seule dans l'URL, et management_token conserve uniquement cote client, transmis en en-tete pour les modifications et stocke hashe en base. Fonctionnalites Tableau de bord, editeur complet (undo/redo, copier/coller, raccourcis, branches repliables, recherche), 9 themes, 4 dispositions automatiques, panneau de proprietes, import/export .mmap, export PNG/SVG/PDF, impression, page publique en lecture seule, PWA. Qualite 25 tests pytest et 43 tests vitest au vert, ruff et ESLint sans erreur, TypeScript strict sans erreur. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
63
Dockerfile
Normal file
63
Dockerfile
Normal file
@@ -0,0 +1,63 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Etape 1 : compilation du frontend React / Vite
|
||||
# ---------------------------------------------------------------------------
|
||||
FROM node:20-alpine AS frontend-build
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
# Les dependances sont installees avant le code source pour profiter du cache.
|
||||
COPY frontend/package.json frontend/package-lock.json ./
|
||||
RUN npm ci --no-audit --no-fund
|
||||
|
||||
COPY frontend/ ./
|
||||
RUN npm run build
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Etape 2 : dependances Python
|
||||
# ---------------------------------------------------------------------------
|
||||
FROM python:3.12-slim AS backend-deps
|
||||
|
||||
ENV PIP_NO_CACHE_DIR=1 \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=1
|
||||
|
||||
WORKDIR /install
|
||||
COPY backend/requirements.txt ./
|
||||
RUN pip install --prefix=/opt/python -r requirements.txt
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Etape 3 : image finale (un seul service : FastAPI sert l'API et le frontend)
|
||||
# ---------------------------------------------------------------------------
|
||||
FROM python:3.12-slim AS runtime
|
||||
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PATH="/opt/python/bin:$PATH" \
|
||||
PYTHONPATH="/opt/python/lib/python3.12/site-packages" \
|
||||
STATIC_DIR=/app/static \
|
||||
DATABASE_URL=sqlite:////app/data/openmind.db
|
||||
|
||||
# curl sert uniquement au healthcheck du conteneur.
|
||||
RUN apt-get update \
|
||||
&& apt-get install --no-install-recommends -y curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# L'application ne tourne jamais en root.
|
||||
RUN useradd --create-home --uid 10001 openmind
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=backend-deps /opt/python /opt/python
|
||||
COPY backend/app ./app
|
||||
COPY --from=frontend-build /build/dist ./static
|
||||
|
||||
RUN mkdir -p /app/data && chown -R openmind:openmind /app
|
||||
|
||||
USER openmind
|
||||
EXPOSE 8080
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
||||
CMD curl -fsS http://127.0.0.1:8080/api/health || exit 1
|
||||
|
||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080", "--proxy-headers"]
|
||||
Reference in New Issue
Block a user