Team Ai
Modelpublic

shaikhsalman/devsecops-platform

sourceHugging Faceapache-2.0updated 6mo agoView on Hugging Face
0likes
Dockerfile.ml-inference45 linesDownload Raw Back to deployment
1# =============================================================================2# Hardened Dockerfile — ML Inference Server3# =============================================================================4 5FROM python:3.12-slim AS builder6 7RUN apt-get update && apt-get install -y --no-install-recommends \8    build-essential && rm -rf /var/lib/apt/lists/*9 10WORKDIR /build11COPY requirements.txt .12RUN pip install --no-cache-dir --require-hashes -r requirements.txt13 14COPY src/ /build/src/15 16# --- Runtime ---17FROM python:3.12-slim AS runtime18 19RUN apt-get update && apt-get install -y --no-install-recommends \20    libgomp1 && \21    rm -rf /var/lib/apt/lists/*22 23RUN groupadd -g 1000 mluser && \24    useradd -u 1000 -g mluser -s /bin/bash mluser25 26COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages27COPY --from=builder /build/src/ /app/src/28 29WORKDIR /app30 31ENV PYTHONUNBUFFERED=1 \32    PYTHONDONTWRITEBYTECODE=1 \33    TRANSFORMERS_CACHE=/cache/huggingface34 35USER mluser36 37EXPOSE 800038 39HEALTHCHECK --interval=30s --timeout=10s --retries=3 \40    CMD ["python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]41 42ENTRYPOINT ["python", "-m", "vllm.entrypoints.openai.api_server", \43    "--host", "0.0.0.0", "--port", "8000", \44    "--model", "/models/latest"]45