From b14d42ec673e65f3719c7e775af492323fb7e255 Mon Sep 17 00:00:00 2001 From: malken21 <77374813+malken21@users.noreply.github.com> Date: Thu, 5 Nov 2026 02:26:00 +0900 Subject: [PATCH 01/10] feat(docker): keep only the run-time files in the image Export the project to a .pck and run it with the release export template instead of the editor. Copy just the programs, the libraries they load and their data onto scratch: no package manager, no editor, only the Intel Vulkan driver. Default to a non-root user. CI: build on pull requests, check that all libraries resolve and the scripts load from the .pck, report the size. Publish from main only, pin actions by commit SHA and limit packages: write to the build job. --- .github/workflows/image.yml | 54 ++++++++++++++++++++++++----- docker/Dockerfile | 58 +++++++++++++++++++++---------- docker/render.sh | 4 +-- docker/rootfs.sh | 68 +++++++++++++++++++++++++++++++++++++ export_presets.cfg | 18 ++++++++++ 5 files changed, 174 insertions(+), 28 deletions(-) create mode 100644 docker/rootfs.sh create mode 100644 export_presets.cfg diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 391120c..b635fea 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -1,38 +1,74 @@ name: image -# Builds the renderer / updater image and publishes it to GHCR: -# ghcr.io/toro-server/toro-renderer:latest and : +# Builds the renderer / updater image. A pull request stops after the checks; main publishes to GHCR: +# ghcr.io/toro-server/toro-renderer: (what compose pins) +# ghcr.io/toro-server/toro-renderer:latest on: push: branches: [main] - paths: + paths: &paths - "project.godot" + - "export_presets.cfg" - "scripts/**" - "shaders/**" - "docker/**" - ".github/workflows/image.yml" + pull_request: + paths: *paths workflow_dispatch: permissions: contents: read - packages: write concurrency: - group: image + group: image-${{ github.ref }} cancel-in-progress: true jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - - uses: actions/checkout@v4 - - uses: docker/setup-buildx-action@v3 - - uses: docker/login-action@v3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + - uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4 + - uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4 + if: github.event_name != 'pull_request' with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - uses: docker/build-push-action@v6 + + - uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 + with: + context: . + file: docker/Dockerfile + load: true + tags: local/toro-renderer:ci + cache-from: type=gha + cache-to: type=gha,mode=max + + # The runner has no GPU, so rendering itself is checked on a machine that has one. Here: every program and + # every library loaded with dlopen resolves its dependencies, and the exported scripts load from the .pck. + - name: Check the image + run: | + lib=/usr/lib/x86_64-linux-gnu + for f in /usr/local/bin/godot /usr/bin/cage /usr/bin/Xwayland $lib/libvulkan_intel.so $lib/libEGL_mesa.so.0 $lib/gbm/dri_gbm.so; do + echo "--- $f" + out=$(docker run --rm --entrypoint /lib64/ld-linux-x86-64.so.2 local/toro-renderer:ci --list "$f") + if echo "$out" | grep 'not found'; then exit 1; fi + done + docker run --rm --entrypoint /bin/sh local/toro-renderer:ci -c 'mkdir -p /tmp/x && nice -n 19 ionice -c3 mkdir -p /tmp/y' + out=$(docker run --rm --read-only --tmpfs /tmp:exec --entrypoint /usr/local/bin/godot local/toro-renderer:ci \ + --headless --main-pack /app/renderer.pck -s res://scripts/main.gd -- help 2>&1 || true) + echo "$out" + echo "$out" | grep -q 'usage: main.gd' + size=$(docker image inspect local/toro-renderer:ci --format '{{.Size}}') + echo "toro-renderer: $((size / 1048576)) MiB" | tee -a "$GITHUB_STEP_SUMMARY" + + - uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 + if: github.event_name != 'pull_request' with: context: . file: docker/Dockerfile diff --git a/docker/Dockerfile b/docker/Dockerfile index 7c9f4bf..9295349 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,34 +1,58 @@ -FROM ubuntu:26.04 +# Three stages: (1) export the project to a .pck, (2) collect only the files needed at run time, (3) put them on scratch. +# The image has no package manager, no editor and no Vulkan driver other than Intel's. Build context: the repository root. + +FROM ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c AS pack ARG GODOT_VERSION=4.7.2-stable ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - ca-certificates curl unzip \ - mesa-vulkan-drivers libvulkan1 libgl1 libegl1 cage \ - libx11-6 libxcursor1 libxinerama1 libxi6 libxrandr2 libxkbcommon0 \ - libwayland-client0 libwayland-cursor0 libwayland-egl1 libdecor-0-0 \ - libasound2t64 libpulse0 libdbus-1-3 libfontconfig1 libudev1 \ + && apt-get install -y --no-install-recommends ca-certificates curl unzip libfontconfig1 \ && rm -rf /var/lib/apt/lists/* -# Godot is verified against the SHA512 sums published with the release. +# Godot is verified against the SHA512 sums published with the release. The editor imports and exports the project; +# the release export template (about half the size of the editor) runs it. RUN set -eux; \ base=https://github.com/godotengine/godot-builds/releases/download/${GODOT_VERSION}; \ - f=Godot_v${GODOT_VERSION}_linux.x86_64.zip; \ + editor=Godot_v${GODOT_VERSION}_linux.x86_64.zip; \ + templates=Godot_v${GODOT_VERSION}_export_templates.tpz; \ cd /tmp; \ - curl -fsSL -o "$f" "$base/$f"; \ - curl -fsSL -o SHA512-SUMS.txt "$base/SHA512-SUMS.txt"; \ - grep " $f\$" SHA512-SUMS.txt | sha512sum -c -; \ - unzip -q "$f"; \ + curl -fsSL -O "$base/$editor" -O "$base/$templates" -O "$base/SHA512-SUMS.txt"; \ + grep -E " ($editor|$templates)\$" SHA512-SUMS.txt | sha512sum -c -; \ + unzip -q "$editor"; \ mv "Godot_v${GODOT_VERSION}_linux.x86_64" /usr/local/bin/godot; \ - rm -f "$f" SHA512-SUMS.txt + mkdir -p /out/usr/local/bin /out/app; \ + unzip -p "$templates" templates/linux_release.x86_64 > /out/usr/local/bin/godot; \ + chmod 755 /out/usr/local/bin/godot; \ + rm -f "$editor" "$templates" SHA512-SUMS.txt WORKDIR /app -COPY project.godot ./ +COPY project.godot export_presets.cfg ./ COPY shaders ./shaders COPY scripts ./scripts -COPY docker ./docker -RUN chmod +x docker/*.sh && godot --headless --path /app --import >/dev/null 2>&1 && chmod -R a+rX /app +RUN godot --headless --path /app --import >/dev/null 2>&1; \ + godot --headless --path /app --export-pack Linux /out/app/renderer.pck \ + && test -s /out/app/renderer.pck + + +FROM ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c AS rootfs + +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + mesa-vulkan-drivers libvulkan1 libgl1 libegl1 cage xwayland busybox-static xkb-data \ + libwayland-client0 libwayland-cursor0 libwayland-egl1 libdecor-0-0 libxkbcommon0 + +COPY --from=pack /out/usr/local/bin/godot /usr/local/bin/godot +COPY docker/rootfs.sh /tmp/rootfs.sh +RUN sh /tmp/rootfs.sh + +FROM scratch +COPY --from=rootfs /rootfs/ / +COPY --from=pack /out/app/renderer.pck /app/renderer.pck +COPY --chmod=755 docker/entrypoint.sh docker/render.sh /app/docker/ +ENV PATH=/usr/local/bin:/usr/bin:/bin HOME=/tmp +# Runs with any uid that may use the render node; see docker/compose.watch.yaml. +USER 65532:65532 ENTRYPOINT ["/app/docker/entrypoint.sh"] diff --git a/docker/render.sh b/docker/render.sh index 6cf3350..486f562 100644 --- a/docker/render.sh +++ b/docker/render.sh @@ -2,6 +2,6 @@ # Runs inside the cage compositor. Arguments: [options] of scripts/main.gd (--data-dir defaults to /data). cmd=$1 shift -exec godot --path /app --rendering-driver vulkan --rendering-method "${GODOT_RENDERING_METHOD:-mobile}" \ +exec godot --main-pack /app/renderer.pck --rendering-driver vulkan --rendering-method "${GODOT_RENDERING_METHOD:-mobile}" \ --display-driver wayland --audio-driver Dummy \ - --resolution 64x64 -s scripts/main.gd -- "$cmd" --data-dir "${DATA_DIR:-/data}" "$@" + --resolution 64x64 -s res://scripts/main.gd -- "$cmd" --data-dir "${DATA_DIR:-/data}" "$@" diff --git a/docker/rootfs.sh b/docker/rootfs.sh new file mode 100644 index 0000000..95a2414 --- /dev/null +++ b/docker/rootfs.sh @@ -0,0 +1,68 @@ +#!/bin/sh +# Copies what the renderer needs at run time into /rootfs: the programs, what they load, and the data they read. +# Everything else in the Ubuntu image (apt, perl, the other Vulkan drivers, documentation...) stays behind. +set -eu + +root=/rootfs +lib=/usr/lib/x86_64-linux-gnu + +# Programs, and the libraries that are opened with dlopen at run time, so ldd on the programs does not list them. +programs=" +/usr/local/bin/godot +/usr/bin/cage +/usr/bin/Xwayland +$lib/libvulkan.so.1 +$lib/libvulkan_intel.so +$lib/libEGL_mesa.so.0 +$lib/gbm/dri_gbm.so +$lib/libwayland-client.so.0 +$lib/libwayland-cursor.so.0 +$lib/libwayland-egl.so.1 +$lib/libxkbcommon.so.0 +$lib/libdecor-0.so.0 +" + +# Data read at run time. +data=" +/usr/share/vulkan/icd.d/intel_icd.x86_64.json +/usr/share/glvnd/egl_vendor.d/50_mesa.json +/usr/share/drirc.d +/usr/share/xkeyboard-config-2 +/usr/share/X11/xkb +" + +copy() { + mkdir -p "$root$(dirname "$1")" + # Regular files in place of symbolic links: only the names that ld.so asks for are copied. + cp -L "$1" "$root$1" +} + +for program in $programs; do + copy "$program" + missing=$(ldd "$program" | grep 'not found' || true) + if [ -n "$missing" ]; then + echo "$program: $missing" >&2 + exit 1 + fi + for library in $(ldd "$program" | awk '$2 == "=>" { print $3 } $1 ~ /^\// { print $1 }'); do + [ -e "$root$library" ] || copy "$library" + done +done + +for path in $data; do + mkdir -p "$root$(dirname "$path")" + cp -a "$path" "$root$(dirname "$path")/" +done + +# A static shell and the few commands the entry scripts use. +copy /usr/bin/busybox +mkdir -p "$root/bin" +for applet in sh mkdir nice ionice; do + ln -s /usr/bin/busybox "$root/bin/$applet" +done + +mkdir -p "$root/tmp" +chmod 1777 "$root/tmp" + +# ld.so finds the libraries by name without a search of every directory. +ldconfig -r "$root" diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..0b18ee9 --- /dev/null +++ b/export_presets.cfg @@ -0,0 +1,18 @@ +[preset.0] + +name="Linux" +platform="Linux" +runnable=true +advanced_options=false +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="docker/*, tools/*, docs/*" +export_path="" +script_export_mode=2 + +[preset.0.options] + +binary_format/embed_pck=false +binary_format/architecture="x86_64" From b82777f0bce2bd4188b1d3ed140d753dd481a4d8 Mon Sep 17 00:00:00 2001 From: malken21 <77374813+malken21@users.noreply.github.com> Date: Thu, 5 Nov 2026 02:45:18 +0900 Subject: [PATCH 02/10] fix(docker): use the ICD file name of Ubuntu 26.04 --- docker/rootfs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/rootfs.sh b/docker/rootfs.sh index 95a2414..9b6bf15 100644 --- a/docker/rootfs.sh +++ b/docker/rootfs.sh @@ -24,7 +24,7 @@ $lib/libdecor-0.so.0 # Data read at run time. data=" -/usr/share/vulkan/icd.d/intel_icd.x86_64.json +/usr/share/vulkan/icd.d/intel_icd.json /usr/share/glvnd/egl_vendor.d/50_mesa.json /usr/share/drirc.d /usr/share/xkeyboard-config-2 From 624153a618e1d629116a65997e568c6b84431f89 Mon Sep 17 00:00:00 2001 From: malken21 <77374813+malken21@users.noreply.github.com> Date: Thu, 5 Nov 2026 02:56:25 +0900 Subject: [PATCH 03/10] fix(docker): create /etc in the rootfs before ldconfig --- docker/rootfs.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/rootfs.sh b/docker/rootfs.sh index 9b6bf15..be3c04f 100644 --- a/docker/rootfs.sh +++ b/docker/rootfs.sh @@ -65,4 +65,5 @@ mkdir -p "$root/tmp" chmod 1777 "$root/tmp" # ld.so finds the libraries by name without a search of every directory. +mkdir -p "$root/etc" ldconfig -r "$root" From 49acbbf04c3e892d81e41ea02ab68e6e2aac005b Mon Sep 17 00:00:00 2001 From: malken21 <77374813+malken21@users.noreply.github.com> Date: Thu, 5 Nov 2026 07:11:48 +0900 Subject: [PATCH 04/10] fix(docker): lower the priority with renice and ionice, which the image has --- .github/workflows/image.yml | 2 +- docker/entrypoint.sh | 4 +++- docker/rootfs.sh | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index b635fea..83df97e 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -59,7 +59,7 @@ jobs: out=$(docker run --rm --entrypoint /lib64/ld-linux-x86-64.so.2 local/toro-renderer:ci --list "$f") if echo "$out" | grep 'not found'; then exit 1; fi done - docker run --rm --entrypoint /bin/sh local/toro-renderer:ci -c 'mkdir -p /tmp/x && nice -n 19 ionice -c3 mkdir -p /tmp/y' + docker run --rm --entrypoint /bin/sh local/toro-renderer:ci -c 'mkdir -p /tmp/x && renice -n 19 -p $$ && ionice -c3 -p $$' out=$(docker run --rm --read-only --tmpfs /tmp:exec --entrypoint /usr/local/bin/godot local/toro-renderer:ci \ --headless --main-pack /app/renderer.pck -s res://scripts/main.gd -- help 2>&1 || true) echo "$out" diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 756e562..433e44a 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -14,4 +14,6 @@ export WLR_RENDERER=gles2 export WLR_RENDER_DRM_DEVICE=${RENDER_NODE:-/dev/dri/renderD128} # lowest CPU and IO priority; the game server always wins -exec nice -n 19 ionice -c3 cage -- /app/docker/render.sh "$@" +renice -n 19 -p $$ > /dev/null +ionice -c3 -p $$ +exec cage -- /app/docker/render.sh "$@" diff --git a/docker/rootfs.sh b/docker/rootfs.sh index be3c04f..e80744e 100644 --- a/docker/rootfs.sh +++ b/docker/rootfs.sh @@ -11,6 +11,8 @@ programs=" /usr/local/bin/godot /usr/bin/cage /usr/bin/Xwayland +/usr/bin/renice +/usr/bin/ionice $lib/libvulkan.so.1 $lib/libvulkan_intel.so $lib/libEGL_mesa.so.0 @@ -54,10 +56,10 @@ for path in $data; do cp -a "$path" "$root$(dirname "$path")/" done -# A static shell and the few commands the entry scripts use. +# A static shell and mkdir for the entry scripts (Ubuntu's busybox has no nice; renice and ionice are copied above). copy /usr/bin/busybox mkdir -p "$root/bin" -for applet in sh mkdir nice ionice; do +for applet in sh mkdir; do ln -s /usr/bin/busybox "$root/bin/$applet" done From 2ad009b7e11c5b3e0f98ef1df38deb18a1a3dc77 Mon Sep 17 00:00:00 2001 From: malken21 <77374813+malken21@users.noreply.github.com> Date: Thu, 5 Nov 2026 07:18:55 +0900 Subject: [PATCH 05/10] fix(docker): name the pack after the binary, since release templates have no --main-pack --- .github/workflows/image.yml | 2 +- docker/Dockerfile | 9 +++++---- docker/render.sh | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 83df97e..9f883aa 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -61,7 +61,7 @@ jobs: done docker run --rm --entrypoint /bin/sh local/toro-renderer:ci -c 'mkdir -p /tmp/x && renice -n 19 -p $$ && ionice -c3 -p $$' out=$(docker run --rm --read-only --tmpfs /tmp:exec --entrypoint /usr/local/bin/godot local/toro-renderer:ci \ - --headless --main-pack /app/renderer.pck -s res://scripts/main.gd -- help 2>&1 || true) + --headless -s res://scripts/main.gd -- help 2>&1 || true) echo "$out" echo "$out" | grep -q 'usage: main.gd' size=$(docker image inspect local/toro-renderer:ci --format '{{.Size}}') diff --git a/docker/Dockerfile b/docker/Dockerfile index 9295349..4434b85 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -21,7 +21,7 @@ RUN set -eux; \ grep -E " ($editor|$templates)\$" SHA512-SUMS.txt | sha512sum -c -; \ unzip -q "$editor"; \ mv "Godot_v${GODOT_VERSION}_linux.x86_64" /usr/local/bin/godot; \ - mkdir -p /out/usr/local/bin /out/app; \ + mkdir -p /out/usr/local/bin; \ unzip -p "$templates" templates/linux_release.x86_64 > /out/usr/local/bin/godot; \ chmod 755 /out/usr/local/bin/godot; \ rm -f "$editor" "$templates" SHA512-SUMS.txt @@ -31,8 +31,8 @@ COPY project.godot export_presets.cfg ./ COPY shaders ./shaders COPY scripts ./scripts RUN godot --headless --path /app --import >/dev/null 2>&1; \ - godot --headless --path /app --export-pack Linux /out/app/renderer.pck \ - && test -s /out/app/renderer.pck + godot --headless --path /app --export-pack Linux /out/usr/local/bin/godot.pck \ + && test -s /out/usr/local/bin/godot.pck FROM ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c AS rootfs @@ -50,7 +50,8 @@ RUN sh /tmp/rootfs.sh FROM scratch COPY --from=rootfs /rootfs/ / -COPY --from=pack /out/app/renderer.pck /app/renderer.pck +# Official release templates have no --main-pack: they load the .pck named after the binary, next to the binary. +COPY --from=pack /out/usr/local/bin/godot.pck /usr/local/bin/godot.pck COPY --chmod=755 docker/entrypoint.sh docker/render.sh /app/docker/ ENV PATH=/usr/local/bin:/usr/bin:/bin HOME=/tmp # Runs with any uid that may use the render node; see docker/compose.watch.yaml. diff --git a/docker/render.sh b/docker/render.sh index 486f562..6c02182 100644 --- a/docker/render.sh +++ b/docker/render.sh @@ -2,6 +2,6 @@ # Runs inside the cage compositor. Arguments: [options] of scripts/main.gd (--data-dir defaults to /data). cmd=$1 shift -exec godot --main-pack /app/renderer.pck --rendering-driver vulkan --rendering-method "${GODOT_RENDERING_METHOD:-mobile}" \ +exec godot --rendering-driver vulkan --rendering-method "${GODOT_RENDERING_METHOD:-mobile}" \ --display-driver wayland --audio-driver Dummy \ --resolution 64x64 -s res://scripts/main.gd -- "$cmd" --data-dir "${DATA_DIR:-/data}" "$@" From 9a55b4dd9eb630df51416162e9d7beeecaed74ff Mon Sep 17 00:00:00 2001 From: malken21 <77374813+malken21@users.noreply.github.com> Date: Fri, 6 Nov 2026 00:22:40 +0900 Subject: [PATCH 06/10] ci: bound the image check and the job by time --- .github/workflows/image.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 9f883aa..632cfe6 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -27,6 +27,7 @@ concurrency: jobs: build: runs-on: ubuntu-latest + timeout-minutes: 30 permissions: contents: read packages: write @@ -60,7 +61,7 @@ jobs: if echo "$out" | grep 'not found'; then exit 1; fi done docker run --rm --entrypoint /bin/sh local/toro-renderer:ci -c 'mkdir -p /tmp/x && renice -n 19 -p $$ && ionice -c3 -p $$' - out=$(docker run --rm --read-only --tmpfs /tmp:exec --entrypoint /usr/local/bin/godot local/toro-renderer:ci \ + out=$(timeout 60 docker run --rm --read-only --tmpfs /tmp:exec --entrypoint /usr/local/bin/godot local/toro-renderer:ci \ --headless -s res://scripts/main.gd -- help 2>&1 || true) echo "$out" echo "$out" | grep -q 'usage: main.gd' From 5d0951e37606623dc1899cb1e8e5663994d1e170 Mon Sep 17 00:00:00 2001 From: malken21 <77374813+malken21@users.noreply.github.com> Date: Fri, 6 Nov 2026 05:28:24 +0900 Subject: [PATCH 07/10] fix(docker): start main.gd as the project's main loop Release export templates are built without path overrides, so they drop -s, --main-loop and the scene path from the command line (main.cpp clears them when OVERRIDE_PATH_ENABLED is off). The image ran the template with -s res://scripts/main.gd, so Godot started an empty SceneTree and never exited: the renderer did nothing, and the CI check waited until the job was cancelled. main.gd now has a class name and project.godot names it in application/run/main_loop_type, which the template honours. render.sh and the CI check drop -s. Every container in the check gets a time limit. --- .github/workflows/image.yml | 9 ++++++--- README.md | 4 ++++ docker/render.sh | 3 ++- project.godot | 1 + scripts/main.gd | 5 ++++- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 632cfe6..6bd3340 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -52,17 +52,20 @@ jobs: # The runner has no GPU, so rendering itself is checked on a machine that has one. Here: every program and # every library loaded with dlopen resolves its dependencies, and the exported scripts load from the .pck. + # Every container gets a time limit, so a program that does not finish fails the step instead of the job. - name: Check the image run: | lib=/usr/lib/x86_64-linux-gnu for f in /usr/local/bin/godot /usr/bin/cage /usr/bin/Xwayland $lib/libvulkan_intel.so $lib/libEGL_mesa.so.0 $lib/gbm/dri_gbm.so; do echo "--- $f" - out=$(docker run --rm --entrypoint /lib64/ld-linux-x86-64.so.2 local/toro-renderer:ci --list "$f") + out=$(timeout 60 docker run --rm --entrypoint /lib64/ld-linux-x86-64.so.2 local/toro-renderer:ci --list "$f") \ + || { echo "ld.so --list $f failed or did not finish"; exit 1; } if echo "$out" | grep 'not found'; then exit 1; fi done - docker run --rm --entrypoint /bin/sh local/toro-renderer:ci -c 'mkdir -p /tmp/x && renice -n 19 -p $$ && ionice -c3 -p $$' + timeout 60 docker run --rm --entrypoint /bin/sh local/toro-renderer:ci -c 'mkdir -p /tmp/x && renice -n 19 -p $$ && ionice -c3 -p $$' + # The release template ignores -s: main.gd must start as the main loop named in project.godot out=$(timeout 60 docker run --rm --read-only --tmpfs /tmp:exec --entrypoint /usr/local/bin/godot local/toro-renderer:ci \ - --headless -s res://scripts/main.gd -- help 2>&1 || true) + --headless -- help 2>&1 || true) echo "$out" echo "$out" | grep -q 'usage: main.gd' size=$(docker image inspect local/toro-renderer:ci --format '{{.Size}}') diff --git a/README.md b/README.md index a6a19e2..a17f587 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,10 @@ tools\run-local.ps1 -Region C:\worlds\flat\region -Tiles "-8,4,2,2" -Out out -Ex godot --path . -s scripts/main.gd -- <コマンド> [--オプション 値] [--フラグ] ``` +コンテナで使う書き出し用テンプレート (release template) は `-s` を受け付けない。そのため `project.godot` の +`application/run/main_loop_type` で `scripts/main.gd` (クラス名 `RendererMain`) を入口にしている。 +`godot --path . -- <コマンド>` でも同じように動く。 + | コマンド | 内容 | | --- | --- | | `render` | タイル矩形を PNG / ロスレス WebP / `manifest.json` へ出力(デバッグ、参照画像との比較) | diff --git a/docker/render.sh b/docker/render.sh index 6c02182..f4ea73a 100644 --- a/docker/render.sh +++ b/docker/render.sh @@ -1,7 +1,8 @@ #!/bin/sh # Runs inside the cage compositor. Arguments: [options] of scripts/main.gd (--data-dir defaults to /data). +# The release template ignores -s, so scripts/main.gd runs as the main loop named in project.godot. cmd=$1 shift exec godot --rendering-driver vulkan --rendering-method "${GODOT_RENDERING_METHOD:-mobile}" \ --display-driver wayland --audio-driver Dummy \ - --resolution 64x64 -s res://scripts/main.gd -- "$cmd" --data-dir "${DATA_DIR:-/data}" "$@" + --resolution 64x64 -- "$cmd" --data-dir "${DATA_DIR:-/data}" "$@" diff --git a/project.godot b/project.godot index 63c3ed1..6f328c8 100644 --- a/project.godot +++ b/project.godot @@ -8,6 +8,7 @@ config_version=5 config/name="TORO Renderer" config/features=PackedStringArray("4.7", "Forward Plus") +run/main_loop_type="RendererMain" [display] diff --git a/scripts/main.gd b/scripts/main.gd index e505a13..74df931 100644 --- a/scripts/main.gd +++ b/scripts/main.gd @@ -1,6 +1,9 @@ +class_name RendererMain extends SceneTree ## Single entry point of the renderer. Run under a display driver (the GPU needs one, see docker/entrypoint.sh): -## godot --path . -s scripts/main.gd -- [options] +## godot --path . -- [options] +## project.godot names this class in application/run/main_loop_type, because the release export template the +## image runs ignores -s. With the editor binary, `-s scripts/main.gd` works as well. ## ## render render tile rectangles to PNG/WebP files (debugging, comparison with reference images) ## scan world scan cache (cx, cz, min_y, max_y per chunk) From 693a3939bbff276914c5e7903754371d08e053e6 Mon Sep 17 00:00:00 2001 From: malken21 <77374813+malken21@users.noreply.github.com> Date: Fri, 6 Nov 2026 05:32:53 +0900 Subject: [PATCH 08/10] fix(docker): give the project an empty main scene The release template stops in setup with "no main scene defined" when the command line names no scene, even if a main loop type is set. main.tscn is an empty Node, so the template starts and RendererMain runs. --- README.md | 1 + main.tscn | 3 +++ project.godot | 1 + scripts/main.gd | 3 ++- 4 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 main.tscn diff --git a/README.md b/README.md index a17f587..4ee9bd2 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ godot --path . -s scripts/main.gd -- <コマンド> [--オプション 値] [-- コンテナで使う書き出し用テンプレート (release template) は `-s` を受け付けない。そのため `project.godot` の `application/run/main_loop_type` で `scripts/main.gd` (クラス名 `RendererMain`) を入口にしている。 +テンプレートは main scene が無いと起動しないので、空の `main.tscn` を main scene にしている。 `godot --path . -- <コマンド>` でも同じように動く。 | コマンド | 内容 | diff --git a/main.tscn b/main.tscn new file mode 100644 index 0000000..0b19160 --- /dev/null +++ b/main.tscn @@ -0,0 +1,3 @@ +[gd_scene format=3] + +[node name="Main" type="Node"] diff --git a/project.godot b/project.godot index 6f328c8..2613057 100644 --- a/project.godot +++ b/project.godot @@ -9,6 +9,7 @@ config_version=5 config/name="TORO Renderer" config/features=PackedStringArray("4.7", "Forward Plus") run/main_loop_type="RendererMain" +run/main_scene="res://main.tscn" [display] diff --git a/scripts/main.gd b/scripts/main.gd index 74df931..2835f9e 100644 --- a/scripts/main.gd +++ b/scripts/main.gd @@ -3,7 +3,8 @@ extends SceneTree ## Single entry point of the renderer. Run under a display driver (the GPU needs one, see docker/entrypoint.sh): ## godot --path . -- [options] ## project.godot names this class in application/run/main_loop_type, because the release export template the -## image runs ignores -s. With the editor binary, `-s scripts/main.gd` works as well. +## image runs ignores -s. The template also refuses to start without a main scene, so main.tscn is an empty one. +## With the editor binary, `-s scripts/main.gd` works as well. ## ## render render tile rectangles to PNG/WebP files (debugging, comparison with reference images) ## scan world scan cache (cx, cz, min_y, max_y per chunk) From bb5a437f34723a6604c4f1598d1db78d6f617ea1 Mon Sep 17 00:00:00 2001 From: malken21 <77374813+malken21@users.noreply.github.com> Date: Fri, 6 Nov 2026 05:40:01 +0900 Subject: [PATCH 09/10] fix(docker): copy main.tscn into the export The pack stage copied only project.godot, export_presets.cfg, scripts and shaders, so the export had no main scene to load. --- .github/workflows/image.yml | 1 + docker/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 6bd3340..d8ea432 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -9,6 +9,7 @@ on: paths: &paths - "project.godot" - "export_presets.cfg" + - "main.tscn" - "scripts/**" - "shaders/**" - "docker/**" diff --git a/docker/Dockerfile b/docker/Dockerfile index 4434b85..f8ec683 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -27,7 +27,7 @@ RUN set -eux; \ rm -f "$editor" "$templates" SHA512-SUMS.txt WORKDIR /app -COPY project.godot export_presets.cfg ./ +COPY project.godot export_presets.cfg main.tscn ./ COPY shaders ./shaders COPY scripts ./scripts RUN godot --headless --path /app --import >/dev/null 2>&1; \ From 50b402f7c654e16d74feeb96b0049c31c758740f Mon Sep 17 00:00:00 2001 From: malken21 <77374813+malken21@users.noreply.github.com> Date: Fri, 6 Nov 2026 05:46:57 +0900 Subject: [PATCH 10/10] ci: keep a pull request image for a day for the GPU test The runner has no GPU, so drawing is checked on the server. The image is saved as an artifact on pull requests only. --- .github/workflows/image.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index d8ea432..10f938c 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -72,6 +72,20 @@ jobs: size=$(docker image inspect local/toro-renderer:ci --format '{{.Size}}') echo "toro-renderer: $((size / 1048576)) MiB" | tee -a "$GITHUB_STEP_SUMMARY" + # The runner cannot draw, so a pull request's image is kept for a day to be tried on a machine with the iGPU: + # gh run download -n toro-renderer-image && gunzip -c toro-renderer.tar.gz | docker load + - name: Save the image for a GPU test + if: github.event_name == 'pull_request' + run: docker save local/toro-renderer:ci | gzip -1 > toro-renderer.tar.gz + + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + if: github.event_name == 'pull_request' + with: + name: toro-renderer-image + path: toro-renderer.tar.gz + retention-days: 1 + compression-level: 0 + - uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 if: github.event_name != 'pull_request' with: