File size: 4,394 Bytes
7ec48b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# 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.
#
# This is T37's image without the notepad: nothing in this task's score depends
# on written notes, so the writable GUI surface that needed its own unprivileged
# user is simply not here.
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 \
    && 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 console is the one GUI surface that could script the simulation, so the
# pinned executable is patched to refuse to open it. Scripting would hand the
# agent land ownership for free, which is the entire task.
COPY restrict-console.py /usr/local/lib/t39/restrict-console.py
RUN python3 /usr/local/lib/t39/restrict-console.py /opt/OpenRCT2/openrct2 \
    > /opt/OpenRCT2/console-restriction.json

COPY entrypoint.sh /usr/local/bin/t39-entrypoint
COPY await-assets.sh /usr/local/bin/onetile-await-assets
COPY terminal-blocked.sh /usr/local/bin/t39-terminal-blocked
COPY game-process.py collect.py run-supervisor.py /usr/local/lib/t39/
# The scenario configuration and the controller are installed as one plugin by
# the supervisor, in this order.
COPY onetile-config.js controller.js /usr/local/lib/t39/
COPY openbox-rc.xml /etc/xdg/openbox/rc.xml
COPY openbox-menu.xml /etc/xdg/openbox/menu.xml
COPY onetile-base.park /opt/onetile/onetile-base.park

RUN chmod +x /usr/local/bin/t39-entrypoint /usr/local/bin/onetile-await-assets \
       /usr/local/bin/t39-terminal-blocked \
    && chown -R root:rct2 /usr/local/lib/t39 && chmod 750 /usr/local/lib/t39 \
    && chmod 444 /opt/onetile/onetile-base.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/t39-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

# The guest target is a build argument so this one Dockerfile produces both
# tasks' images: t39 at 200 and t40 at 1,000. On Daytona there is no compose file
# to carry it -- harbor boots the published snapshot directly -- so the target has
# to be in the image. Locally compose.yaml also sets it in the environment, with
# the same number. Left empty it stays empty, and await-assets.sh refuses to
# start rather than guessing a target.
ARG T39_TARGET_GUESTS=""
ENV T39_TARGET_GUESTS=${T39_TARGET_GUESTS}

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/onetile-await-assets"]