File size: 1,070 Bytes
866d61e 8ddfad6 49234f8 8ddfad6 d75ab36 49234f8 8ddfad6 13f2931 8ddfad6 49234f8 8ddfad6 49234f8 8ddfad6 49234f8 8ddfad6 49234f8 83964d7 49234f8 847096d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt --upgrade
# Copy application files
COPY . .
# Create non-root user for HF Spaces
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
USER appuser
# Port layout (Option A):
# 7860 = FastAPI / OpenEnv API (HF Spaces primary port — grader connects here)
# 7861 = Gradio demo UI (human-accessible demo)
EXPOSE 7860
EXPOSE 7861
# Health check against the FastAPI server
HEALTHCHECK --interval=30s --timeout=10s --start-period=90s --retries=3 \
CMD curl -f http://localhost:7860/ || exit 1
# startup.py:
# 1. Pre-trains .pkl models if missing
# 2. Spawns Gradio UI on port 7861
# 3. Runs FastAPI (OpenEnv API) on port 7860 (main thread, blocks)
CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "7860"]
|