# Hugging Face Space wrapper for the GitHub repository root. # The repository keeps the runnable app under polyguard-rl/, while Spaces expect # Dockerfile at the Space root. FROM node:20-bookworm-slim AS frontend WORKDIR /build COPY polyguard-rl/app/ui/frontend/package.json polyguard-rl/app/ui/frontend/package-lock.json ./ RUN npm ci COPY polyguard-rl/app/ui/frontend/ ./ ENV VITE_API_BASE=/api RUN npm run build FROM python:3.11-slim-bookworm WORKDIR /app ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends nginx && rm -rf /var/lib/apt/lists/* COPY polyguard-rl/requirements-space.txt /app/requirements-space.txt RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu && pip install --no-cache-dir -r /app/requirements-space.txt COPY polyguard-rl/ /app/ COPY --from=frontend /build/dist /app/static RUN chmod +x /app/docker/space/entrypoint.sh && mkdir -p /app/data /app/checkpoints/active ENV PORT=7860 ENV POLYGUARD_ALLOW_HF_SPACE_CORS=true ENV POLYGUARD_ENABLE_OLLAMA=false ENV POLYGUARD_ENABLE_ACTIVE_MODEL=true ENV POLYGUARD_HF_MODEL=Qwen/Qwen2.5-0.5B-Instruct ENV POLYGUARD_PROVIDER_PREFERENCE=transformers ENV POLYGUARD_ALLOW_WEB_FETCH=false ENV POLYGUARD_DATA_DIR=/app/data ENV PYTHONUNBUFFERED=1 EXPOSE 7860 CMD ["/app/docker/space/entrypoint.sh"]