Spaces:
Running
Running
FROM python:3.10-slim | |
# Install git and other dependencies | |
RUN apt update && apt install -y git && apt clean | |
# Set up environment | |
ENV PYTHONUNBUFFERED=1 \ | |
PORT=8000 \ | |
HF_HOME=/home/user/huggingface \ | |
GRADIO_ALLOW_FLAGGING=never \ | |
GRADIO_NUM_PORTS=1 \ | |
GRADIO_SERVER_NAME=0.0.0.0 \ | |
GRADIO_THEME=huggingface \ | |
SYSTEM=spaces \ | |
PATH=/home/user/.local/bin:$PATH \ | |
HOME=/home/user \ | |
PYTHONPATH=/home/user/app | |
# Create user and required dirs | |
RUN useradd -m -u 1000 user && mkdir -p /home/user/huggingface /home/user/app | |
# Set working directory to user's app dir | |
WORKDIR /home/user/app | |
# Copy source as the correct user | |
COPY --chown=user . . | |
# Switch to user for safer permissions | |
USER user | |
# Install Python dependencies | |
COPY requirements.txt /home/user/app/requirements.txt | |
RUN pip install --no-cache-dir -r /home/user/app/requirements.txt | |
# Expose the correct port | |
EXPOSE 8000 | |
# Run FastAPI (no __main__ needed) | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"] | |