TanujInsane
fix: update server/app.py imports and Dockerfile CMD
847096d
Raw History Blame Contribute Delete
1.07 kB
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"]