Tsah00/sql-env
0
1# SQL Query Learning Environment - Dockerfile2# Compatible with Hugging Face Spaces (port 7860, non-root user)3 4FROM python:3.11-slim5 6# System deps7RUN apt-get update && apt-get install -y --no-install-recommends \8 sqlite3 \9 && rm -rf /var/lib/apt/lists/*10 11# Non-root user required by Hugging Face Spaces12RUN useradd -m -u 1000 appuser13WORKDIR /app14 15# Install Python dependencies16COPY requirements.txt .17COPY pyproject.toml .18RUN pip install --no-cache-dir -r requirements.txt19 20# Copy application code21COPY models.py .22COPY client.py .23COPY openenv.yaml .24COPY inference.py .25COPY server/ ./server/26 27# Ensure server package is importable28RUN touch server/__init__.py29 30# Set ownership31RUN chown -R appuser:appuser /app32USER appuser33 34# Environment variables (overridden at runtime)35ENV API_BASE_URL=""36ENV MODEL_NAME=""37ENV HF_TOKEN=""38ENV PYTHONPATH="/app"39 40# Expose Hugging Face Spaces port41EXPOSE 786042 43# Health check44HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \45 CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/health')" || exit 146 47CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]48 