File size: 4,694 Bytes
5463b45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Self-contained game desktop: OpenRCT2 0.5.5 with no browser, no terminal and
# no in-game console. The purchased RCT2 data is mounted at run time, never
# baked into this image.
FROM debian:bookworm-slim

ARG OPENRCT2_VERSION=0.5.5
ARG OPENRCT2_SHA256=db233a2cde7861057f5d70982cb7299066222888f7c796540085ee4eb9a0a7a0

RUN apt-get update && apt-get install -y --no-install-recommends \
    ca-certificates curl tini bash python3 procps \
    libsdl2-2.0-0 libsdl2-ttf-2.0-0 libcurl4 libfontconfig1 libfreetype6 \
    libicu72 libpng16-16 libspeexdsp1 libzip4 libzstd1 libssl3 \
    libflac12 libvorbisfile3 libgomp1 libgl1 \
    xvfb xauth x11-utils x11vnc openbox novnc python3-websockify \
    xdotool wmctrl scrot fonts-dejavu-core \
    imagemagick webp \
    mousepad \
    && rm -rf /var/lib/apt/lists/*

RUN test "$(dpkg --print-architecture)" = amd64 \
    && curl --fail --location --retry 3 \
      "https://github.com/OpenRCT2/OpenRCT2/releases/download/v${OPENRCT2_VERSION}/OpenRCT2-v${OPENRCT2_VERSION}-Linux-bookworm-x86_64.tar.gz" \
      -o /tmp/openrct2.tar.gz \
    && echo "${OPENRCT2_SHA256}  /tmp/openrct2.tar.gz" | sha256sum -c - \
    && tar -xzf /tmp/openrct2.tar.gz -C /opt \
    && rm /tmp/openrct2.tar.gz \
    && ln -s /opt/OpenRCT2/openrct2 /usr/local/bin/openrct2

ENV DISPLAY=:1 \
    SDL_AUDIODRIVER=dummy \
    SDL_VIDEODRIVER=x11 \
    SDL_RENDER_DRIVER=opengl \
    LIBGL_ALWAYS_SOFTWARE=1 \
    LP_NUM_THREADS=2 \
    TMPDIR=/tmp \
    LD_LIBRARY_PATH=/opt/OpenRCT2

RUN openrct2 --version \
    && useradd --create-home --uid 1000 --shell /bin/bash rct2 \
    && mkdir -p /home/rct2/.config/OpenRCT2 /artifacts /opt/rct2-assets \
    && mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix \
    && chown -R rct2:rct2 /home/rct2 /artifacts

# The notepad is a writable GUI surface, so it is not the game's user. A text
# editor's Save As can reach anywhere its process may write, and the engine
# loads every .js in the game profile's plugin directory at start-up: one saved
# file there would hand the agent the scripting surface this task withholds.
# This user can write /notes and nothing else, and cannot read the game profile
# or the trusted controller source either.
RUN useradd --create-home --uid 1001 --shell /usr/sbin/nologin notes \
    && mkdir -p /notes /home/notes/.config/glib-2.0/settings \
    && printf '[org/xfce/mousepad/preferences/view]\nword-wrap=true\nshow-line-numbers=true\nfont-name=%s\n' \
       "'Monospace 11'" > /home/notes/.config/glib-2.0/settings/keyfile \
    && chown -R notes:notes /home/notes \
    && chown notes:rct2 /notes && chmod 2775 /notes \
    && chmod 750 /home/rct2

# The console is the one GUI surface that could script the simulation, so the
# pinned executable is patched to refuse to open it.
COPY restrict-console.py /usr/local/lib/t37/restrict-console.py
RUN python3 /usr/local/lib/t37/restrict-console.py /opt/OpenRCT2/openrct2 \
    > /opt/OpenRCT2/console-restriction.json

COPY entrypoint.sh /usr/local/bin/t37-entrypoint
COPY await-assets.sh /usr/local/bin/micropark-await-assets
COPY terminal-blocked.sh /usr/local/bin/t37-terminal-blocked
COPY notepad-keeper.sh /usr/local/bin/t37-notepad-keeper
COPY game-process.py collect.py try-supervisor.py /usr/local/lib/t37/
# The notepad's starting contents, kept as a file so its size is a known
# quantity the supervisor can report and the grader can measure against.
COPY notes-seed.txt /usr/local/lib/t37/notes-seed.txt
COPY controller.js /usr/local/lib/t37/observer.js
COPY openbox-rc.xml /etc/xdg/openbox/rc.xml
COPY openbox-menu.xml /etc/xdg/openbox/menu.xml
COPY micropark-seed.park /opt/micropark/micropark-seed.park

RUN chmod +x /usr/local/bin/t37-entrypoint /usr/local/bin/micropark-await-assets \
       /usr/local/bin/t37-terminal-blocked /usr/local/bin/t37-notepad-keeper \
    && chown -R root:rct2 /usr/local/lib/t37 && chmod 750 /usr/local/lib/t37 \
    && chmod 444 /opt/micropark/micropark-seed.park \
    && mkdir -p /logs/artifacts /logs/verifier/artifacts \
    && chown -R rct2:rct2 /logs \
    && for app in xterm uxterm lxterm koi8rxterm x-terminal-emulator \
       xfce4-terminal xfce4-appfinder xfrun4 lxterminal gnome-terminal; do \
       ln -sf /usr/local/bin/t37-terminal-blocked "/usr/bin/$app"; done \
    && find /usr/share/applications -name '*.desktop' -delete \
    && printf '[Desktop Entry]\nType=Application\nName=OpenRCT2\nExec=openrct2\nCategories=Game;\nTerminal=false\n' \
       > /usr/share/applications/openrct2.desktop

WORKDIR /home/rct2
EXPOSE 6080
# Root only waits for the private assets, then drops to the game user.
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/micropark-await-assets"]