ritvik360/nl2sql-bench
0
1# nl2sql-bench/server/Dockerfile2# ─────────────────────────────────────────────────────────────────────────────3# NL2SQL-Bench OpenEnv Server4# Hugging Face Spaces compatible (port 7860, non-root user).5# Build: docker build -t nl2sql-bench:latest .6# Run: docker run -p 7860:7860 nl2sql-bench:latest7# ─────────────────────────────────────────────────────────────────────────────8 9FROM python:3.11-slim10 11# HF Spaces runs as non-root by default12ARG UID=100013RUN useradd -m -u $UID appuser14 15WORKDIR /app16 17# ── System deps ───────────────────────────────────────────────────────────18RUN apt-get update -qq && \19 apt-get install -y --no-install-recommends curl && \20 rm -rf /var/lib/apt/lists/*21 22# ── Python deps ───────────────────────────────────────────────────────────23COPY server/requirements.txt /app/requirements.txt24RUN pip install --no-cache-dir -r requirements.txt25 26# ── Application code ──────────────────────────────────────────────────────27# Copy server code28COPY server/ /app/server/29# Copy shared models (client imports from parent — we flatten for Docker)30COPY models.py /app/models.py31 32# Flatten server submodules into /app so Python can find them33# (avoids complex PYTHONPATH games inside the container)34RUN cp -r /app/server/tasks /app/tasks && \35 cp -r /app/server/db /app/db && \36 cp /app/server/grader.py /app/grader.py && \37 cp /app/server/environment.py /app/environment.py && \38 cp /app/server/app.py /app/app.py39 40# 🚨 CRITICAL FIX: Give appuser ownership of /app so SQLite can create the database41RUN chown -R appuser:appuser /app42 43# ── Runtime config ────────────────────────────────────────────────────────44ENV PYTHONPATH=/app45ENV PYTHONUNBUFFERED=146# HF Spaces requires port 786047ENV PORT=786048ENV NL2SQL_DEFAULT_TASK=simple-filter49ENV NL2SQL_MAX_STEPS=550 51USER appuser52WORKDIR /app53 54EXPOSE 786055 56HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \57 CMD curl -sf http://localhost:${PORT}/health || exit 158 59CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port ${PORT} --workers 2 --log-level info"]60 