File size: 2,220 Bytes
23df34a
df84e45
 
 
 
 
 
 
 
 
 
 
1d12f00
df84e45
 
1d12f00
df84e45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d992b32
 
df84e45
 
 
 
 
 
 
 
 
 
 
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
# DesignGym: OpenEnv server + editor + headless Chromium for the GUI surface.
FROM python:3.12-slim

ENV PYTHONUNBUFFERED=1 UV_LINK_MODE=copy PLAYWRIGHT_BROWSERS_PATH=/opt/ms-playwright
WORKDIR /app/design_canvas
# skia-python links against EGL/GL and fontconfig even when rendering on the CPU.
RUN apt-get update && apt-get install -y --no-install-recommends libegl1 libgl1 libfontconfig1 \
 && rm -rf /var/lib/apt/lists/* \
 && pip install --no-cache-dir uv

# Dependencies first, for layer caching.
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev --extra daytona --no-install-project

COPY . .
RUN uv sync --frozen --no-dev --extra daytona \
 && .venv/bin/python -m playwright install --with-deps chromium \
 && rm -rf /var/lib/apt/lists/*

# Tasks. With corpus-manifest.json in the build context (the Space), the server
# plays the full Crello corpus from the FineEnvs/crello-bucket mount at /corpus:
# the image holds code and the manifest only. Without it (a plain local
# `docker build`), a small task pack is built into the image instead.
ARG PACK_TRAIN=240
ARG PACK_VALIDATION=60
ARG PACK_TEST=120
ENV HF_HOME=/tmp/hf DESIGN_CANVAS_CACHE=/tmp/design-canvas-cache DESIGN_CANVAS_SOURCE_ROOT=/corpus
RUN if [ -f corpus-manifest.json ]; then \
      echo "serving the bucket-backed corpus"; \
    else \
      .venv/bin/design-canvas prepare --pack /data/pack --train ${PACK_TRAIN} \
        --validation ${PACK_VALIDATION} --test ${PACK_TEST} && rm -rf /tmp/hf; \
    fi
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
# an upload to the Hub does not keep the executable bit
RUN chmod 0755 /usr/local/bin/docker-entrypoint.sh

# The server only reads /app and /data; no chown, which would copy both into a new layer.
RUN useradd --create-home --uid 1000 user
USER user
ENV PATH="/app/design_canvas/.venv/bin:$PATH" PORT=8000 MAX_CONCURRENT_ENVS=64
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
  CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"
ENTRYPOINT ["docker-entrypoint.sh"]
# OpenEnv's entry point: one process, or DESIGN_CANVAS_WORKERS processes behind one URL (server/router.py)
CMD ["server"]