translator-model-api / Dockerfile
arindae's picture
Update Dockerfile
f576211 verified
Raw
History Blame Contribute Delete
1.54 kB
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies (libgomp1 is needed for CTranslate2 multi-threading)
RUN apt-get update && apt-get install -y --no-install-recommends \
libgomp1 \
patchelf \
&& rm -rf /var/lib/apt/lists/*
COPY backend/requirements.txt backend/requirements-convert.txt ./
RUN pip install --no-cache-dir -r requirements.txt \
&& pip install --no-cache-dir -r requirements-convert.txt --extra-index-url https://download.pytorch.org/whl/cpu
# Pinned to v0.3.34, which ships a py3-none-manylinux2014_x86_64 wheel on the
# CPU wheel index — no cp311-specific build required, no compiler, no CMake.
# --only-binary=:all: makes pip HARD-FAIL instead of silently falling back
# to a from-source build if a matching wheel isn't found (fail fast > timeout).
# Confirmed present at: https://abetlen.github.io/llama-cpp-python/whl/cpu/llama-cpp-python/
RUN pip install --no-cache-dir --only-binary=:all: \
llama-cpp-python==0.3.34 \
--extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
RUN SO_FILES=$(find /usr/local/lib/python3.11/site-packages -name '*.so*' -path '*ctranslate2*' 2>/dev/null) \
&& echo "Found CTranslate2 .so files: $SO_FILES" \
&& for f in $SO_FILES; do patchelf --clear-execstack "$f" && echo "Patched: $f"; done
COPY . .
COPY entrypoint.sh .
RUN chmod +x entrypoint.sh
RUN mkdir -p /data/models \
&& useradd -m -u 1000 user \
&& chown -R user:user /app /data
ENV OMP_NUM_THREADS=8
USER user
EXPOSE 7860
CMD ["./entrypoint.sh"]