# nl2sql-bench/server/Dockerfile # ───────────────────────────────────────────────────────────────────────────── # NL2SQL-Bench OpenEnv Server # Hugging Face Spaces compatible (port 7860, non-root user). # Build: docker build -t nl2sql-bench:latest . # Run: docker run -p 7860:7860 nl2sql-bench:latest # ───────────────────────────────────────────────────────────────────────────── FROM python:3.11-slim # HF Spaces runs as non-root by default ARG UID=1000 RUN useradd -m -u $UID appuser WORKDIR /app # ── System deps ─────────────────────────────────────────────────────────── RUN apt-get update -qq && \ apt-get install -y --no-install-recommends curl && \ rm -rf /var/lib/apt/lists/* # ── Python deps ─────────────────────────────────────────────────────────── COPY server/requirements.txt /app/requirements.txt RUN pip install --no-cache-dir -r requirements.txt # ── Application code ────────────────────────────────────────────────────── # Copy server code COPY server/ /app/server/ # Copy shared models (client imports from parent — we flatten for Docker) COPY models.py /app/models.py # Flatten server submodules into /app so Python can find them # (avoids complex PYTHONPATH games inside the container) RUN cp -r /app/server/tasks /app/tasks && \ cp -r /app/server/db /app/db && \ cp /app/server/grader.py /app/grader.py && \ cp /app/server/environment.py /app/environment.py && \ cp /app/server/app.py /app/app.py # 🚨 CRITICAL FIX: Give appuser ownership of /app so SQLite can create the database RUN chown -R appuser:appuser /app # ── Runtime config ──────────────────────────────────────────────────────── ENV PYTHONPATH=/app ENV PYTHONUNBUFFERED=1 # HF Spaces requires port 7860 ENV PORT=7860 ENV NL2SQL_DEFAULT_TASK=simple-filter ENV NL2SQL_MAX_STEPS=5 USER appuser WORKDIR /app EXPOSE 7860 HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \ CMD curl -sf http://localhost:${PORT}/health || exit 1 CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port ${PORT} --workers 2 --log-level info"]