File size: 2,351 Bytes
900c7c1
 
 
 
 
 
a80542f
900c7c1
a80542f
 
900c7c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a80542f
900c7c1
ff674cc
a80542f
 
900c7c1
 
 
 
 
 
 
 
f26021f
900c7c1
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 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"]