Python 3.12 from deadsnakes on Ubuntu 22.04 drops `distutils` from the stdlib, and Ubuntu's system pip still imports from it — so `pip install` fails immediately with ModuleNotFoundError: distutils. Switch to the uv standalone installer, which doesn't need pip at all. Caught during the first deploy build. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
67 lines
2.5 KiB
Docker
67 lines
2.5 KiB
Docker
# InfoXtractor container image.
|
|
#
|
|
# Base image ships CUDA 12.4 runtime libraries so the Surya OCR client can
|
|
# use the RTX 3090 on the deploy host. Ubuntu 22.04 is the LTS used across
|
|
# the home-server stack (immich-ml, monitoring) so GPU drivers line up.
|
|
FROM nvidia/cuda:12.4.0-runtime-ubuntu22.04
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive \
|
|
PYTHONUNBUFFERED=1 \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1
|
|
|
|
# --- System deps --------------------------------------------------------
|
|
# - python3.12 via deadsnakes PPA (pinned; Ubuntu 22.04 ships 3.10 only)
|
|
# - libmagic1 : python-magic backend for MIME sniffing
|
|
# - libgl1 : libGL.so needed by Pillow/OpenCV wheels used by Surya
|
|
# - libglib2.0 : shared by Pillow/PyMuPDF headless rendering
|
|
# - curl : post-receive hook's /healthz probe & general ops
|
|
# - ca-certs : httpx TLS verification
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
software-properties-common \
|
|
ca-certificates \
|
|
curl \
|
|
gnupg \
|
|
&& add-apt-repository -y ppa:deadsnakes/ppa \
|
|
&& apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
python3.12 \
|
|
python3.12-venv \
|
|
python3.12-dev \
|
|
libmagic1 \
|
|
libgl1 \
|
|
libglib2.0-0 \
|
|
&& ln -sf /usr/bin/python3.12 /usr/local/bin/python \
|
|
&& ln -sf /usr/bin/python3.12 /usr/local/bin/python3 \
|
|
&& apt-get clean \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# --- uv (dependency resolver used by the project) -----------------------
|
|
# Install via the standalone installer; avoids needing a working system pip
|
|
# (python3.12 on Ubuntu 22.04 has no `distutils`, which breaks Ubuntu pip).
|
|
RUN curl -LsSf https://astral.sh/uv/install.sh | sh \
|
|
&& ln -sf /root/.local/bin/uv /usr/local/bin/uv
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy just the dependency manifests first so the heavy `uv sync` layer
|
|
# caches whenever only application code changes.
|
|
COPY pyproject.toml uv.lock .python-version ./
|
|
|
|
# Prod + OCR extras, no dev tooling. --frozen means "must match uv.lock";
|
|
# CI catches drift before it reaches the image.
|
|
RUN uv sync --frozen --no-dev --extra ocr
|
|
|
|
# --- Application code ---------------------------------------------------
|
|
COPY src src
|
|
COPY alembic alembic
|
|
COPY alembic.ini ./
|
|
|
|
EXPOSE 8994
|
|
|
|
# Migrations are idempotent (alembic upgrade head is a no-op on a current
|
|
# DB) so running them on every start keeps the image + DB aligned without
|
|
# an extra orchestration step.
|
|
CMD ["sh", "-c", "uv run alembic upgrade head && uv run uvicorn ix.app:create_app --factory --host 0.0.0.0 --port 8994"]
|