File size: 7,815 Bytes
92f480e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# t19-blender-rig-full task image.
#
# Standalone (not FROM any suite base): the agent's whole world is Blender
# 5.0.1 plus the four captioned CGDive "Rigging isn't Scary" Level 1 videos in
# Chromium, on the XFCE desktop harbor's computer-1 drives with xdotool. No terminal, no
# network at run time, no Python console / text editor / Scripting workspace
# inside Blender (Sid's rule: the coding tools are disabled).
#
# Build context is THIS directory:
#     docker buildx build --platform linux/amd64 \
#       -t refresh-blender-rig:t19 suite_tasks/t19-blender-rig-full/environment
# (harbor does exactly that for local runs.) Blender is downloaded at build
# time from an official mirror and pinned by the release SHA-256. The
# tutorials (environment/tutorial/*.mp4, gitignored — regenerate with
# tools/fetch-tutorial.sh) and the course's start files are COPY'd in.
FROM debian:bookworm-slim AS desktop-runtime
ARG BLENDER_VERSION=5.0.1
ARG BLENDER_SHA256=8019580ee1b7262e505f4196a00237ccf743c88d205b38d34201510676e60b09
ARG BLENDER_MIRROR=https://ftp.nluug.nl/pub/graphics/blender/release

ENV DEBIAN_FRONTEND=noninteractive \
    HOME=/root \
    LANG=C.UTF-8

# Desktop stack expected by harbor computer-1 (it execs Xvfb, startxfce4,
# x11vnc, /usr/bin/chromium, xdotool, wmctrl, ImageMagick `import`, cwebp —
# none of it is installed by the harness), plus:
#   * Mesa software GL (llvmpipe): Xvfb has no GPU; Blender needs OpenGL 4.3
#     and llvmpipe reports 4.5.
#   * Blender's X11 runtime deps (the tarball bundles Python, libs, ffmpeg).
#   * thunar + xfdesktop4: Desktop icons (relaunch routes) and a file manager
#     the agent can use to find the start file.
#   * python3 + pytest: the verifier runs in-container with no network.
#   * Debian chromium plays H.264 (the captioned tutorials).
RUN apt-get update \
 && apt-get install -y --no-install-recommends \
      ca-certificates curl xz-utils procps \
      chromium xvfb xfce4-session xfwm4 xfce4-panel xfce4-settings xfdesktop4 \
      x11vnc xdotool wmctrl imagemagick webp dbus-x11 \
      thunar xdg-utils \
      fonts-dejavu-core fonts-liberation fonts-noto-color-emoji \
      libgl1-mesa-dri libglx-mesa0 libegl1 libgl1 libglu1-mesa \
      libx11-6 libxi6 libxxf86vm1 libxfixes3 libxrender1 libxext6 libxinerama1 \
      libxrandr2 libxcursor1 libxkbcommon0 libxkbcommon-x11-0 libsm6 libice6 \
      libfontconfig1 libfreetype6 libdbus-1-3 libpulse0 libasound2 libgomp1 \
      libtbb12 libzstd1 libsndfile1 libopenal1 libjack0 libwayland-client0 \
      python3 python3-pip python3-tk ffmpeg \
 && pip3 install --no-cache-dir --break-system-packages \
      pytest==8.4.1 pytest-json-ctrf==0.3.5 \
 && rm -rf /var/lib/apt/lists/*

FROM desktop-runtime AS task
ARG BLENDER_VERSION=5.0.1
ARG BLENDER_SHA256=8019580ee1b7262e505f4196a00237ccf743c88d205b38d34201510676e60b09
ARG BLENDER_MIRROR=https://ftp.nluug.nl/pub/graphics/blender/release

# Blender: official Linux x64 tarball, SHA-256 pinned (blender-5.0.1.sha256
# on the release server). ldd assertion fails the build if a runtime lib is
# missing rather than at the agent's first launch.
RUN set -eux; \
    curl -fsSL -A "Mozilla/5.0" -o /tmp/blender.tar.xz \
      "${BLENDER_MIRROR}/Blender$(echo "${BLENDER_VERSION}" | cut -d. -f1,2)/blender-${BLENDER_VERSION}-linux-x64.tar.xz"; \
    echo "${BLENDER_SHA256}  /tmp/blender.tar.xz" | sha256sum -c -; \
    mkdir -p /opt/blender; \
    tar -xJf /tmp/blender.tar.xz -C /opt/blender --strip-components=1; \
    rm -f /tmp/blender.tar.xz; \
    test -x /opt/blender/blender; \
    missing="$(ldd /opt/blender/blender | grep 'not found' || true)"; \
    if [ -n "$missing" ]; then echo "blender: unresolved libs:"; echo "$missing"; exit 1; fi

# NO CODING TOOLS (Sid): remove the Python console backend + operators, strip
# "Run Script" from the text editor UI, install the startup guard that deletes
# the Scripting workspace and converts Console/Text areas away (see the
# headers of nocode-patch.py and nocode_guard.py). The patch asserts each edit.
COPY nocode-patch.py nocode_guard.py /tmp/nocode/
RUN python3 /tmp/nocode/nocode-patch.py /opt/blender/5.0/scripts \
 && test ! -e /opt/blender/5.0/scripts/startup/bl_operators/console.py \
 && test ! -e /opt/blender/5.0/scripts/modules/_console_python.py \
 && test -f /opt/blender/5.0/scripts/startup/nocode_guard.py \
 && ! grep -q "text.run_script" /opt/blender/5.0/scripts/startup/bl_ui/space_text.py \
 && rm -rf /tmp/nocode

# Preferences baked for the first launch (no splash, no Python tooltips, no
# developer extras, no auto-run scripts, autosave 2 min). Running Blender
# headless here also proves the patched script tree still starts.
COPY setprefs.py /tmp/setprefs.py
RUN /opt/blender/blender -b -Y --python /tmp/setprefs.py 2>&1 | tail -5 \
 && test -f /root/.config/blender/5.0/config/userpref.blend \
 && rm -f /tmp/setprefs.py

# The tutorials (captions burned in, no audio needed) + the player page that is
# the browser start_url, and the course's start files (RiS_StartFiles_v2.zip
# from the link under the video, unzipped): Beginner_01.blend is the character
# Level 1 rigs; horse_01 / Novice_01 belong to the challenge and Level 2 and
# ship untouched for fidelity.
COPY tutorial/index.html tutorial/part1.mp4 tutorial/part2.mp4 tutorial/part3.mp4 tutorial/part4.mp4 /opt/tutorial/
COPY assets/start-files/ /root/Downloads/RiS_StartFiles_v2/
RUN for i in 1 2 3 4; do test -s /opt/tutorial/part$i.mp4 || { echo "missing part$i.mp4"; exit 1; }; done \
 && test -s /root/Downloads/RiS_StartFiles_v2/Beginner_01.blend \
 && mkdir -p /root/rig /logs/verifier /root/Desktop /usr/share/applications

# Browser hardening for both chromiums (harness + Tutorial launcher): Debian's
# /usr/bin/chromium sources /etc/chromium.d/*.
COPY chromium-safe-flags /etc/chromium.d/90-t19-safe
RUN grep -q "chromium.d" /usr/bin/chromium && test -s /etc/chromium.d/90-t19-safe

# Desktop launchers (relaunch routes without a shell) + the entrypoint/launcher.
COPY blender.desktop tutorial.desktop /root/Desktop/
COPY blender-relaunch.sh /usr/local/bin/blender-relaunch
COPY blender-launcher.sh /usr/local/bin/blender-launcher
COPY start-blender-task.sh /usr/local/bin/start-blender-task
COPY smoke-desktop.sh /usr/local/bin/smoke-desktop
COPY screen-recorder.py /usr/local/bin/t19-screen-recorder
COPY screen-recorder.desktop /root/Desktop/
RUN chmod 755 /root/Desktop/*.desktop /usr/local/bin/blender-relaunch /usr/local/bin/blender-launcher \
      /usr/local/bin/start-blender-task /usr/local/bin/smoke-desktop /usr/local/bin/t19-screen-recorder \
 && cp /root/Desktop/blender.desktop /root/Desktop/tutorial.desktop /root/Desktop/screen-recorder.desktop /usr/share/applications/ \
 && xdg-mime default thunar.desktop inode/directory || true

# No terminal for the agent. Nothing above installs one, but XFCE ships
# launcher stubs pointing at absent programs; remove them so no menu offers
# one, and fail the build if any terminal emulator is present after all.
RUN rm -f /usr/share/applications/xfce4-terminal-emulator.desktop \
          /usr/share/applications/debian-xterm.desktop /usr/share/applications/debian-uxterm.desktop \
 && rm -f /usr/share/xfce4/helpers/*term*.desktop /usr/share/xfce4/helpers/debian-x-terminal-emulator.desktop \
 && for b in xterm uxterm xfce4-terminal x-terminal-emulator gnome-terminal konsole; do \
      command -v "$b" >/dev/null 2>&1 && { echo "terminal $b present" >&2; exit 1; }; done; \
    ! ls /usr/share/applications | grep -qi term && echo "no terminal emulator in image"

ENV DISPLAY=:1 \
    LIBGL_ALWAYS_SOFTWARE=1 \
    GALLIUM_DRIVER=llvmpipe \
    XDG_CONFIG_HOME=/root/.config \
    XDG_DATA_HOME=/root/.local/share \
    XDG_CACHE_HOME=/root/.cache

WORKDIR /root
CMD ["/usr/local/bin/start-blender-task"]