j2damax's picture
Deploy app with models and artifacts (force update)
575d22a verified
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
WORKDIR /app
# Install system dependencies (minimal) & Python deps as root so console scripts land in /usr/local/bin
RUN apt-get update && apt-get install -y --no-install-recommends build-essential && rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -r requirements.txt
# Create non-root user & cache dirs AFTER deps so uvicorn already on PATH
RUN useradd -m appuser && mkdir -p /app/models /app/artifacts /app/hf-cache && chown -R appuser:appuser /app /home/appuser
USER appuser
# Copy application files
COPY . .
# Expose port 7860 (Hugging Face Spaces default)
EXPOSE 7860
# Environment (HF cache path can be overridden at runtime)
ENV PORT=7860 HF_HUB_CACHE=/app/hf-cache
# Run the application (python -m form removes reliance on entrypoint script PATH issues)
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]