66 lines
2.5 KiB
Docker
66 lines
2.5 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
#
|
|
# Mindnet-Image für API und Streamlit-UI (ein Image, Modus per CMD: api | ui | preflight).
|
|
# Build-Kontext ist das Repository-Root; die Allowlist steht in /.dockerignore.
|
|
#
|
|
# docker build -f deploy/Dockerfile -t mindnet:<git-sha> .
|
|
#
|
|
# Reproduzierbarkeit: Basis-Image per Digest, Abhängigkeiten per Hash-Lock
|
|
# (deploy/requirements.lock). Kein torch / sentence-transformers: Embeddings
|
|
# kommen ausschließlich von Ollama (nomic-embed-text, 768 Dimensionen).
|
|
|
|
ARG PYTHON_IMAGE=python:3.12-slim-bookworm@sha256:e697c81897302a4c4333bade000d98038fbb21eb064f8ee1fd42d02ebcd9d337
|
|
|
|
# --- Abhängigkeiten in ein isoliertes venv -----------------------------------
|
|
FROM ${PYTHON_IMAGE} AS deps
|
|
ENV PIP_NO_CACHE_DIR=1 \
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
|
PYTHONDONTWRITEBYTECODE=1
|
|
COPY deploy/requirements.lock /tmp/requirements.lock
|
|
RUN python -m venv /opt/venv \
|
|
&& /opt/venv/bin/pip install --require-hashes --no-deps -r /tmp/requirements.lock
|
|
|
|
# --- Laufzeit-Image -------------------------------------------------------------
|
|
FROM ${PYTHON_IMAGE} AS runtime
|
|
ARG MINDNET_UID=10001
|
|
ENV PATH=/opt/venv/bin:${PATH} \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
PYTHONPATH=/app \
|
|
HOME=/tmp \
|
|
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
|
|
|
|
RUN groupadd --system --gid ${MINDNET_UID} mindnet \
|
|
&& useradd --system --uid ${MINDNET_UID} --gid mindnet --no-create-home --shell /usr/sbin/nologin mindnet
|
|
|
|
COPY --from=deps /opt/venv /opt/venv
|
|
|
|
WORKDIR /app
|
|
# Code und Konfiguration gehören root und sind für den Laufzeitnutzer nur lesbar.
|
|
COPY app/ app/
|
|
COPY config/ config/
|
|
COPY scripts/ scripts/
|
|
COPY deploy/entrypoint.py deploy/healthcheck.py /opt/mindnet/
|
|
|
|
# Einzige beschreibbare Pfade (als Volumes gemountet): Logs und Laufzeitdaten.
|
|
RUN install -d -o mindnet -g mindnet -m 0750 /app/logs /app/data /app/data/logs
|
|
|
|
USER mindnet:mindnet
|
|
EXPOSE 8000 8501
|
|
ENTRYPOINT ["python", "/opt/mindnet/entrypoint.py"]
|
|
CMD ["api"]
|
|
|
|
# --- Test-Image (nur für nichtproduktive Läufe) ---------------------------------
|
|
FROM runtime AS test
|
|
USER root
|
|
COPY deploy/requirements-test.lock /tmp/requirements-test.lock
|
|
RUN pip install --no-cache-dir --require-hashes --no-deps -r /tmp/requirements-test.lock
|
|
COPY tests/ tests/
|
|
COPY deploy/ deploy/
|
|
COPY .dockerignore ./
|
|
COPY .gitea/workflows/ .gitea/workflows/
|
|
USER mindnet:mindnet
|
|
ENTRYPOINT []
|
|
CMD ["python", "-m", "pytest", "-q", "-p", "no:cacheprovider", \
|
|
"tests/test_container_preflight.py", "tests/test_container_connectivity.py"]
|