0f35a0c484
Consolidated merge of feat/tag-suggestions branch. Original 64-commit history was lost to git-object corruption in a Nextcloud-synced checkout; this single commit captures the equivalent diff. Includes: - pgvector-backed tag suggestion infra (WD14 + SigLIP centroids, ml-worker container, Celery tasks, suggestion service, accept/reject endpoints + modal UI with green/red chip buttons) - Character/fandom integrity: title-case normalization on every write path, fandom-id backfill, maintenance task + settings button, migrations g26041901 + h26041901 to canonicalize legacy rows with case-only duplicate merging - Tag-underscores + modal polish: WD14 name canonicalization at emit + accept + add/bulk-add paths, migration i26041901 for legacy-row rename-or-merge across character/fandom/NULL kinds, suggestion-accept refresh parity via awaited loadTags, persistent chip tint
43 lines
1.8 KiB
OCaml
43 lines
1.8 KiB
OCaml
# syntax=docker/dockerfile:1
|
|
FROM python:3.12-slim AS base
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
ML_MODEL_DIR=/models
|
|
|
|
# System deps: Pillow / image handling + psycopg2 build deps (binary wheel usually fine but libpq is needed at runtime on slim)
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
libgl1 \
|
|
libglib2.0-0 \
|
|
libpq5 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
# Install PyTorch CPU wheel first from its dedicated index to avoid pulling CUDA libs.
|
|
# Floor only — buildkit will pick the latest matching CPU wheel; keep this above the app-deps
|
|
# layer so transformers on PyPI doesn't accidentally resolve a mismatched torch.
|
|
RUN pip install --no-cache-dir \
|
|
--index-url https://download.pytorch.org/whl/cpu \
|
|
"torch>=2.5"
|
|
|
|
# Pre-install only what the model downloader needs, then fetch models. By keeping the model-download
|
|
# layer above the full requirements install, a change to requirements-ml.txt won't invalidate the
|
|
# (slow, ~2 GB) model download layer.
|
|
RUN pip install --no-cache-dir "huggingface_hub>=0.25"
|
|
COPY scripts/download_models.py /app/scripts/download_models.py
|
|
RUN mkdir -p ${ML_MODEL_DIR} && python /app/scripts/download_models.py
|
|
|
|
# Install the rest of the ML requirements. Model files are already on disk from the step above.
|
|
COPY requirements-ml.txt /app/requirements-ml.txt
|
|
RUN pip install --no-cache-dir -r requirements-ml.txt
|
|
|
|
# Copy application code (needed so Celery can import app.tasks.ml and app.ml).
|
|
# config.py lives at the repo root and is imported by app/__init__.py via 'config.Config'.
|
|
COPY app /app/app
|
|
COPY config.py /app/config.py
|
|
|
|
# Celery needs these env vars set at runtime via docker-compose.
|
|
CMD ["celery", "-A", "app.celery_app:celery", "worker", "--loglevel=info", "-Q", "ml", "--concurrency=1"]
|