Mise à jour automatique (Gitea + Watchtower) et conteneurisation Docker

- Détection de version via l'API Gitea, application via Watchtower
- Router système, UI admin (intégrations), bandeau de mise à jour
- Dockerfile multi-étapes, docker-compose, scripts/release.sh
- Version centralisée dans app/version.py (pyproject ou OHM_VERSION au build)
This commit is contained in:
Roman
2026-09-22 11:58:03 +00:00
parent 41566ab5fb
commit 9148b5fb6a
21 changed files with 1092 additions and 49 deletions
+56
View File
@@ -0,0 +1,56 @@
# ---------------------------------------------------------------------------
# Étape 1 — dépendances Python via uv (cache couche par couche)
# ---------------------------------------------------------------------------
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS builder
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
WORKDIR /opt/ohm
# D'abord les métadonnées seules : couche réutilisable tant que uv.lock ne bouge pas
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev --no-install-project --no-cache
# Puis le code
COPY app ./app
RUN uv sync --frozen --no-dev --no-cache
# ---------------------------------------------------------------------------
# Étape 2 — image d'exécution minimale
# ---------------------------------------------------------------------------
FROM python:3.13-slim-bookworm
# ffmpeg (téléchargements HLS), ca-certificates (scraping HTTPS),
# gosu (bascule utilisateur non-root dans l'entrypoint)
RUN apt-get update \
&& apt-get install -y --no-install-recommends ffmpeg ca-certificates gosu \
&& rm -rf /var/lib/apt/lists/*
# Utilisateur non-root
RUN useradd --create-home --uid 1000 ohm
WORKDIR /opt/ohm
COPY --from=builder --chown=ohm:ohm /opt/ohm/.venv ./.venv
COPY --chown=ohm:ohm app ./app
COPY --chown=ohm:ohm docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENV PATH="/opt/ohm/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
# Chemins montés en volumes par docker-compose
OHM_DATA_DIR=/data \
OHM_DOWNLOAD_DIR=/downloads \
OHM_DATABASE_PATH=/data/ohm.db
# Version cuite dans l'image par scripts/release.sh (build-arg VERSION)
ARG VERSION=dev
ENV OHM_VERSION=${VERSION}
RUN mkdir -p /data /downloads && chown -R ohm:ohm /opt/ohm /data /downloads
# Root par défaut : l'entrypoint chown les volumes puis passe en « ohm »
EXPOSE 8777
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD ["python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8777/health', timeout=4)"]
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8777"]