·5 min read
Zig images for Pterodactyl: four compiler versions, two tarball names
A Zig project is a strange fit for a game-panel container. There is no runtime to install, but there are four live compiler versions people pin to, two tarball naming schemes across them, a build script that may or may not accept -Doptimize, and an entrypoint contract that expects a start command to exist. I wanted one Dockerfile that could build any of them, and a start script that failed with a sentence a panel user could act on.
- Project
- Pterodactyl Yolks
- Date
- Oct 2026
- Stack
- Docker, Bash, GitHub Actions, Zig
- Commit
- d0f53cd
One image per compiler release
Projects pin to a Zig version, so a single "latest" image would move everyone on every release. The workflow keeps a matrix of four versions and tags each one:
matrix:
include:
- version: 0.17.0
tags: zig_0.17,zig_latest
- version: 0.16.0
tags: zig_0.16
- version: 0.15.2
tags: zig_0.15
- version: 0.14.1
tags: zig_0.14zig_latest is an alias of the newest entry, not its own build, so the two tags can never drift apart. Each version has its own GitHub Actions cache scope, zig-${{ matrix.version }}, so adding 0.18 later builds one new image and reuses the others. A cron entry rebuilds everything on the first of each month, for Debian security updates, with fail-fast: false so one broken version does not cancel the other three.
The image itself is deliberately small. Zig ships its own C compiler and libc, so beyond git (for git+https dependencies in build.zig.zon), curl and xz-utils, the base debian:bookworm-slim needs nothing to build a project from source. The package cache is pointed into the container's persistent home, through ZIG_GLOBAL_CACHE_DIR=/home/container/.cache/zig, so dependencies are fetched once per server and not on every restart.
Two tarball names
Downloading the compiler looks trivial until you try more than one version. The Dockerfile comment states the cause: Zig renamed its tarballs in 0.14.1, from zig-linux-x86_64 to zig-x86_64-linux. The supported matrix now includes 0.14.1 and newer only, but the fallback means the same Dockerfile can build either naming scheme by changing a build argument:
base="https://ziglang.org/download/${ZIG_VERSION}"; \
curl -fsSL -o /tmp/zig.tar.xz "${base}/zig-${arch}-linux-${ZIG_VERSION}.tar.xz" \
|| curl -fsSL -o /tmp/zig.tar.xz "${base}/zig-linux-${arch}-${ZIG_VERSION}.tar.xz"; \curl -f is what makes this work: without it, a 404 page would be saved as a file and tar would fail later with an error about the archive and not about the URL. TARGETARCH maps amd64 to x86_64 and arm64 to aarch64, and anything else exits with a message. The last step of that RUN is zig version, so a bad download fails the image build and does not ship.
A start script that explains itself
Pterodactyl's entrypoint expands a STARTUP string and evals it. That string is configured in the panel, so the script has to cope with whatever the user uploaded. zig-start is built around what can go wrong in that situation.
If there is no build.zig, it says so and where to put one:
if [ ! -f build.zig ]; then
say "No build.zig in $(pwd). Upload your project with SFTP or the file manager, or link a repository on the GitHub tab."
exit 1
fiThe optimize level is validated against the four real values. Then comes the part I like least in principle and most in practice:
opt_flag=()
if grep -qs 'standardOptimizeOption\|"optimize"' build.zig; then
opt_flag=("-Doptimize=$optimize")
else
say "build.zig declares no optimize option; building as it decides."
fiA -Doptimize option exists only when build.zig asks for it with standardOptimizeOption. Passing it to a build script that does not is an "invalid option" failure, and the user would see a compiler error about a flag they never typed. A grep on the build file is a heuristic and I know it: a project could build the option name dynamically. The failure mode is mild, though. The build runs with the script's own defaults and a line says so.
Choosing the binary is similar. It runs the only executable directly inside zig-out/bin, or the one ZIG_BIN names. With zero executables or several it refuses and names the cause, including the list of candidates. The find excludes *.so and *.so.*, since a library in that directory is not something to run.
Ziex apps, which the script detects by ziex in build.zig.zon, take a longer path: zig build, then zig build zx -- bundle, then a copy of the bundle into .renode-app/. It is copied with cp -a, not replaced, because Ziex keeps KV data under that directory and a rebuild must not take it away.
One more detail: everything zig-start prints goes to stderr. The script comment gives the reason: some entrypoints capture the start command's stdout and execute it, so a progress message on stdout would be run as a command.
What I would do differently
I did not boot-test every version of the image against a real Zig project in this commit, and the history shows no such step, so I cannot claim the four tags have been exercised end to end.
The lesson I keep from this image is to spend the effort on failure messages. Compiling a Zig project is the easy part. The support questions are "it started and did nothing" and "it says invalid option", and each of those now has a sentence that points at the cause.
#docker#zig#pterodactyl#github-actions#bash
Keep reading
Have a project in mind?