imDrizzle's picture
fix(backend): enable PYTHONUNBUFFERED for real-time logging
94f9d3d
Raw
History Blame Contribute Delete
955 Bytes
FROM python:3.11-slim
# Create user with UID 1000 as required by Hugging Face Spaces
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PYTHONUNBUFFERED=1
WORKDIR $HOME/app
# Install system dependencies (must switch to root temporarily if needed, but python-slim might need them as root)
USER root
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
USER user
# Install Python dependencies
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cpu -r requirements.txt
# Copy source code
COPY --chown=user . $HOME/app
# Expose port
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s CMD curl -f http://localhost:7860/health || exit 1
# Run the application
CMD ["uvicorn", "src.api.main:app", "--host", "0.0.0.0", "--port", "7860"]