# SQL Agent OpenEnv — Docker build for Hugging Face Spaces # # Stage 1: Build React frontend # Stage 2: Python FastAPI app serving both the API and static UI # # HF Spaces expects the app to listen on port 7860. # ── Stage 1: Frontend build ─────────────────────────────────────────────────── FROM node:20-slim AS frontend-builder WORKDIR /app/frontend # Install deps first (layer cache) COPY frontend/package.json frontend/package-lock.json* ./ RUN npm ci --prefer-offline --no-audit # Build the app COPY frontend/ ./ RUN npm run build # ── Stage 2: Python runtime ─────────────────────────────────────────────────── FROM python:3.11-slim # System deps RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Python deps COPY backend/requirements.txt ./requirements.txt RUN pip install --no-cache-dir -r requirements.txt # Copy backend source COPY backend/ ./backend/ # Copy built frontend COPY --from=frontend-builder /app/frontend/dist ./frontend/dist # Copy repo-root artefacts COPY inference.py openenv.yaml README.md ./ # Ensure data dir exists (RL weights, GEPA prompts, SQLite DB) RUN mkdir -p ./backend/data # ── HF Spaces config ────────────────────────────────────────────────────────── EXPOSE 7860 ENV PORT=7860 \ PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 # Run from backend/ so relative imports and data/ paths resolve correctly WORKDIR /app/backend CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]