File size: 1,392 Bytes
f368481
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Agent harness — deploy image.
# Uses a plain Python base and installs Chromium + its OS deps via Playwright, so
# the CNC simulator tool (headless browser) works on a server.
FROM python:3.11-slim

ENV PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1 \
    CNC_HEADLESS=1 \
    PORT=8080 \
    HOME=/app \
    PLAYWRIGHT_BROWSERS_PATH=/ms-playwright

WORKDIR /app

# Install Python deps first (better layer caching), then the matching Chromium
# build + its system libraries (--with-deps runs apt-get for us). Browsers go to
# a fixed, world-readable path so the app finds them even if the platform (e.g.
# Hugging Face Spaces) runs the container as a non-root user.
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt \
 && python -m playwright install --with-deps chromium \
 && chmod -R a+rx /ms-playwright \
 && apt-get update && apt-get install -y --no-install-recommends curl \
 && rm -rf /var/lib/apt/lists/*

COPY . .

# Writable dirs for the modules' generated output + uploads (any runtime user).
RUN mkdir -p modules/cnc_websim/cncwebsim/agent_outputs var/uploads \
 && chmod -R a+rwx modules var

EXPOSE 8080

# Single worker on purpose: the app serializes tool runs behind one lock and one
# shared browser; multiple workers would each spawn their own Chromium.
CMD ["sh", "-c", "uvicorn harness.webapp:app --host 0.0.0.0 --port ${PORT:-8080} --workers 1"]