·5 min read
A BEAM image for Pterodactyl: SIGTERM, stderr-only scripts, honest hints
The BEAM image in my Pterodactyl yolks repo had three small problems to solve before it could run a single Phoenix app: how the container stops, what the start script prints, and where it prints it. None of them is hard on its own. Each one is the kind of detail that decides whether a game-panel user sees a clean shutdown and a readable error, or a hung console and a wall of noise.
- Project
- Pterodactyl yolks
- Date
- Oct 2026
- Stack
- Docker, bash, Elixir, Gleam, Pterodactyl
- Commit
- f12bf95
One image per OTP major
The Dockerfile takes its base from a build argument:
ARG BASE=hexpm/elixir:1.20.4-erlang-29.1.2-debian-bookworm-20261005-slim
FROM ${BASE}The comment at the top of the file gives the reason. hexpm's prebuilt Elixir images are Debian bookworm-slim with Erlang and Elixir already compiled for amd64 and arm64. Building OTP from source for the arm64 variant under QEMU is slow, so I let someone else's CI do it and pick the image per OTP major through BASE.
On top of that base the Dockerfile adds Gleam 1.19.2, rebar3 3.27.3 and Node 24.22.0. rebar3 is there because Gleam builds rebar3 Hex packages with it. Node is there because Gleam's JavaScript target runs on it, and because many Phoenix asset pipelines still call npm. The download step switches on TARGETARCH to map amd64 and arm64 onto the different names Gleam and Node use for the same architectures, and ends with elixir --version; gleam --version; rebar3 version; node --version so a broken download fails the image build instead of the first customer start.
Why SIGTERM and not SIGINT
The last lines of the Dockerfile are the part I would not have guessed on my own:
# SIGTERM, not SIGINT: the BEAM answers SIGINT with its interactive BREAK
# menu and waits for a key, while SIGTERM runs init:stop() and shuts the
# application down cleanly. Wings' "^C" stop sends the image's stop signal.
STOPSIGNAL SIGTERM
ENTRYPOINT ["/usr/bin/tini", "-g", "--"]Ctrl+C in an Erlang shell opens the BREAK menu, which is a prompt waiting for input. A container has nobody to type at that prompt. If the panel's stop button sent SIGINT, the VM would sit at a menu in a console no one is reading. SIGTERM goes to init:stop(), which shuts the application tree down in order. So the image declares the signal and the panel sends the right one.
tini -g runs as PID 1 and forwards signals to the process group. The start scripts end with exec, so the process that receives the signal is mix and the VM it started, not a bash wrapper sitting in between.
stdout belongs to the entrypoint
entrypoint.sh expands the panel's startup template and then runs it:
MODIFIED_STARTUP=$(echo -e ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')
eval ${MODIFIED_STARTUP}It uses the same expansion as the parkervcp yolks so eggs written for them behave the same. The consequence is in the header comment of elixir-start: "Everything this script says goes to stderr: some entrypoints capture the startup command's stdout and execute it." If a start script printed a status line to stdout and an entrypoint ran eval "$(elixir-start)", the status line would be executed as a command. So the logging helper is one line, and it only ever writes to fd 2:
say() { printf '\033[1m\033[36m[elixir-start]\033[0m %s\n' "$*" >&2; }The same discipline shows on every command: mix deps.get --only "$MIX_ENV" >&2, mix compile >&2, and so on. Mix's own output is redirected too, not just my messages.
Deciding whether it is Phoenix
The script does not ask the user whether the project is Phoenix. It reads mix.exs:
if grep -Eqs '\{[[:space:]]*:phoenix[[:space:]]*,' mix.exs; then
phoenix=1
fiA dependency tuple that starts with :phoenix means Phoenix. Then PHX_SERVER=true is exported, mix assets.deploy runs only if the string "assets.deploy" appears in mix.exs, and the final command is mix phx.server. Anything else gets mix run --no-halt. ELIXIR_START overrides the whole choice, for people who know better than a grep.
The two Phoenix checks that can stop the boot are explicit. In prod, an empty SECRET_KEY_BASE exits with a message, and a key shorter than 64 characters exits with its actual length. An empty PHX_HOST does not stop anything; it falls back to localhost and says so, because LiveView websockets from the real domain would be refused.
Rewriting the hints
The follow-up commit, 01c2b8f, changed only message text. The first version told users to set SECRET_KEY_BASE "on the Startup tab". The new one says the panel generates it when the server is created. The PHX_HOST hint used to say to set it on the Startup tab; now it says to set PHX_HOST to your domain, or set check_origin in config/runtime.exs.
I read that change as removing two assumptions. A hint that names a UI location is wrong the moment the egg is configured differently, and it hides the second way out: an app can allow origins in its own config instead of through an environment variable. The message now describes the cause, not the place to click.
What I took from it
Most of the work in a runtime image is not the Dockerfile's install steps. It is the contract around the process: which signal stops it, which stream is safe to write to, and which messages a person will read at 3 a.m. in a panel console. Those lines are short, and each one has a reason that is easy to lose if it is not written next to the code. I wrote the reasons as comments in the files themselves for that reason.
#docker#elixir#pterodactyl#signals#bash
Keep reading
Have a project in mind?