FROM python:3.11-slim ENV HF_HOME=/srv/.hf_cache \ TRANSFORMERS_CACHE=/srv/.hf_cache \ HF_HUB_DISABLE_TELEMETRY=1 \ PIP_NO_CACHE_DIR=1 \ PYTHONUNBUFFERED=1 \ OMP_NUM_THREADS=1 # Runtime-Libs für NumPy/SciPy/Sklearn/Torch RUN apt-get update && apt-get install -y --no-install-recommends \ libgomp1 libstdc++6 libgfortran5 ca-certificates wget && \ rm -rf /var/lib/apt/lists/* WORKDIR /srv # 1) Pip & feste Numerik/Torch (CPU) RUN python -m pip install --upgrade pip && \ pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu "torch==2.2.2" && \ pip install --no-cache-dir "numpy==1.26.4" "scipy==1.11.4" "scikit-learn==1.3.2" # 2) App-Dependencies (ziehen KEIN numpy-Upgrade mehr) RUN pip install --no-cache-dir \ fastapi==0.111.0 \ uvicorn[standard]==0.30.1 \ sentence-transformers==3.0.1 # 3) App-Code COPY ../app/embed_server.py /srv/embed_server.py # 4) Build-Time-Sanity-Check (bricht Build ab, falls was nicht stimmt) RUN python - <<'PY' from sentence_transformers import SentenceTransformer m = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2") e = m.encode(["ping","hallo welt"], normalize_embeddings=False) assert len(e)==2 and len(e[0])==384, "embedding shape mismatch" print("Sanity OK: shape", len(e), len(e[0])) PY EXPOSE 8990 CMD ["uvicorn", "embed_server:app", "--host", "0.0.0.0", "--port", "8990"]