Spaces:
Sleeping
Sleeping
refact: added the module for proper python setup
Browse files12345678910111213141516171819202122232425# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker# you will also find guides on how best to write your DockerfileFROM python:3.10# Create user firstRUN useradd -m -u 1000 user# Install system dependencies (requires root)RUN apt-get update && apt-get install -y libgl1# Switch to non-root userUSER userENV PATH="/home/user/.local/bin:$PATH"WORKDIR /appCOPY --chown=user ./requirements.txt requirements.txtRUN pip install --no-cache-dir --upgrade -r requirements.txtRUN python -m spacy download en_core_web_sm || echo "Failed to download model"COPY --chown=user . /appCMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]12345678910111213141516171819202122232425262728293031323334353637383940# Use official Python 3.10 imageFROM python:3.10-slim# Install system dependencies (requires root)RUN apt-get update && \apt-get install -y --no-install-recommends \libgl1 \build-essential \curl \&& apt-get clean && rm -rf /var/lib/apt/lists/*# Create non-root userRUN useradd -m -u 1000 user# Set environment for pip and pathENV PATH="/home/user/.local/bin:$PATH" \PYTHONDONTWRITEBYTECODE=1 \PYTHONUNBUFFERED=1# Switch to the userUSER userWORKDIR /app# Copy and install requirementsCOPY --chown=user requirements.txt .RUN pip install --no-cache-dir --upgrade pip && \pip install --no-cache-dir -r requirements.txt# Ensure spaCy model is installed (safe fallback if download fails)RUN python -m spacy download en_core_web_sm || echo "spaCy model download failed, continuing..."# Copy rest of the appCOPY --chown=user . .# Expose port (optional but good practice)EXPOSE 7860# Start the appCMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
Dockerfile+29-14