File size: 3,521 Bytes
a31f556
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
FROM python:3.11-slim

# Switch to root to install ALL system dependencies including Playwright browser libs
USER root
RUN apt-get update && apt-get install -y \
    ffmpeg \
    espeak-ng \
    portaudio19-dev \
    python3-dev \
    build-essential \
    # ── Playwright / Chromium system dependencies ──────────────────────────────
    libnss3 \
    libnspr4 \
    libatk1.0-0 \
    libatk-bridge2.0-0 \
    libcups2 \
    libdrm2 \
    libdbus-1-3 \
    libxkbcommon0 \
    libxcomposite1 \
    libxdamage1 \
    libxfixes3 \
    libxrandr2 \
    libgbm1 \
    libasound2 \
    libpango-1.0-0 \
    libcairo2 \
    libatspi2.0-0 \
    libwayland-client0 \
    wget \
    ca-certificates \
    # ── S4: headless Blender runtime links (no X server needed in --background) ─
    curl \
    xz-utils \
    libgl1 \
    libegl1 \
    libx11-6 \
    libxi6 \
    libxxf86vm1 \
    libxrender1 \
    libgomp1 \
    libsm6 \
    && rm -rf /var/lib/apt/lists/*

# ── S4: Blender 4.5 LTS headless (official Linux x64 tarball, URL verified 2026-07-17).
# Geometry processing + GLB export only β€” no rendering β†’ CPU hardware is sufficient.
ARG BLENDER_VERSION=4.5.3
RUN mkdir -p /opt/blender && \
    curl -fsSL "https://download.blender.org/release/Blender4.5/blender-${BLENDER_VERSION}-linux-x64.tar.xz" \
      -o /tmp/blender.tar.xz && \
    tar -xJf /tmp/blender.tar.xz -C /opt/blender --strip-components=1 && \
    rm /tmp/blender.tar.xz && \
    /opt/blender/blender --version

# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user

# Switch to the "user" user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:/opt/blender:$PATH \
    CLOUD_ENV=true \
    PLAYWRIGHT_BROWSERS_PATH=/home/user/.playwright \
    BLENDER_PATH=/opt/blender/blender

# Set the working directory to the user's home directory
WORKDIR $HOME/app

# Copy the requirements file and install dependencies
COPY --chown=user backend/requirements.txt $HOME/app/backend/requirements.txt
RUN awk '!/^#/ && NF' backend/requirements.txt | while read -r req; do \
      req=$(echo "$req" | tr -d '\r'); \
      echo "=== INSTALLING: $req ==="; \
      pip install --no-cache-dir --upgrade "$req" || { echo "FAILED ON: $req"; exit 1; }; \
    done

# Install Playwright Chromium browser binaries (for social media automation)
RUN playwright install chromium

# Copy the rest of the backend source code
COPY --chown=user backend/ $HOME/app/backend/

# Copy required root modules and config
COPY --chown=user modules/ $HOME/app/modules/
COPY --chown=user config.py $HOME/app/config.py

# S4: AR scene bus (started by backend.main at boot; /scene/ws proxies into it)
COPY --chown=user phone/ $HOME/app/phone/

# Copy the centralized database with the vault keys
COPY --chown=user memory.db $HOME/app/memory.db

# ── S4: ship the WebAR client β€” mobile AR loads straight from the Space at /webar/
COPY --chown=user webar/ $HOME/app/webar/

# ── S4: writable pipeline dirs (container FS is ephemeral; durable copies are pushed
# to the private OMEGA models dataset via huggingface_hub at runtime)
RUN mkdir -p $HOME/app/storage/models3d $HOME/app/storage/forge_templates $HOME/app/storage/chroma_db

# Expose the default port for Hugging Face Spaces
EXPOSE 7860

# We use the Self-Healing Supervisor to boot the actual server
CMD ["python", "-u", "backend/supervisor.py"]

# S4 rebuild marker 2026-07-17 β€” Blender pipeline + WebAR serving