CoolFace
Apppublic

Spectr28/llm-router

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
Dockerfile43 linesDownload Raw Back to root
1FROM python:3.11-slim2 3# Set up user 1000 required by Hugging Face4RUN useradd -m -u 1000 user5WORKDIR /home/user/app6 7# Install system tools8RUN apt-get update && apt-get install -y --no-install-recommends \9    build-essential \10    && rm -rf /var/lib/apt/lists/*11 12# Copy requirements FIRST for caching benefits13COPY --chown=user:user requirements.txt .14RUN pip install --no-cache-dir --upgrade pip && \15    pip install --no-cache-dir -r requirements.txt16 17# Copy the rest of the application files18COPY --chown=user:user . .19 20# Set up clean environment variables21ENV HOME=/home/user \22    PATH=/home/user/.local/bin:$PATH \23    PYTHONPATH=/home/user/app:/home/user/app/src \24    HF_HOME=/home/user/app/model_cache25 26# 1. Switch back to root to create folders inside the root-owned app directory27USER root28 29# 2. Create the cache directories30RUN mkdir -p /home/user/app/model_cache /home/user/app/src/cache_store31 32# 3. Give the 'user' account full ownership of the entire app directory (including the new caches)33RUN chown -R user:user /home/user/app34 35# 4. NOW switch back to the restricted user36USER user37 38# 5. Run your Python scripts safely (the user now owns the folders)39RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2', cache_folder='/home/user/app/model_cache')"40RUN python -c "import sys; sys.path.append('src'); from classifier import _train_model; _train_model()"41 42# Start the application43CMD ["uvicorn", "src.api:app", "--host", "0.0.0.0", "--port", "7860"]