# syntax=docker/dockerfile:1.7 # # Hugging Face Space (sdk: docker) for the CADGenBench leaderboard. # # HF builds this server-side on each git push. Local smoke test: # # docker buildx build --platform linux/amd64 -t cadgenbench-space-test . # # cadgenbench is installed from github.com/huggingface/cadgenbench, which # is Public. No build secrets or auth required. FROM python:3.12-slim-bookworm ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ PLAYWRIGHT_BROWSERS_PATH=/opt/ms-playwright \ GRADIO_SERVER_NAME=0.0.0.0 \ GRADIO_SERVER_PORT=7860 # OS deps: # git, ca-certificates -> pip install from git+https:// # libgl1, libglib2.0-0, libsm6, # libxext6, libxrender1, -> OCP / build123d / Pillow runtime # libgomp1, libfontconfig1 # Chromium's own runtime libs are added by `playwright install --with-deps` # below, so they aren't repeated here. RUN apt-get update && apt-get install -y --no-install-recommends \ git ca-certificates \ libgl1 libglib2.0-0 libsm6 libxext6 libxrender1 libgomp1 libfontconfig1 \ && rm -rf /var/lib/apt/lists/* # Space-side Python deps (gradio, pandas, huggingface_hub, datasets). COPY requirements.txt /tmp/requirements.txt RUN pip install --no-cache-dir -r /tmp/requirements.txt \ && rm /tmp/requirements.txt # Playwright + headless Chromium for cadgenbench's STEP -> PNG renderer # (cadgenbench.common.viewer wraps tcv-screenshots -> playwright). Browsers # land in /opt/ms-playwright (world-readable) so the non-root runtime user # below can find them via PLAYWRIGHT_BROWSERS_PATH. ~200 MB layer. RUN pip install --no-cache-dir playwright \ && playwright install --with-deps chromium # cadgenbench from the Public GitHub repo, pinned to a commit. Bumping # CADGENBENCH_SHA is the one-line path to picking up a new cadgenbench. ARG CADGENBENCH_SHA=056cfbb RUN pip install --no-cache-dir \ "cadgenbench @ git+https://github.com/huggingface/cadgenbench.git@${CADGENBENCH_SHA}" # Drop privileges. HF Spaces conventionally run as uid 1000 with # WORKDIR /home/user/app. RUN useradd -m -u 1000 user \ && mkdir -p /home/user/app \ && chown -R user:user /home/user/app USER user WORKDIR /home/user/app COPY --chown=user:user *.py results.jsonl ./ EXPOSE 7860 CMD ["python", "app.py"]