Shipping an Elixir release I did not write
My whole surface on this Phoenix service is a 40-line Makefile and two version files — and the thing that bit was a pin sitting in the wrong one.
Who wrote what
The application is a Phoenix 1.6 PCAP extractor with 33 direct hex dependencies, clustered with
libcluster over Consul and authenticating through exldap against LDAP. It carries no database
at all (ecto_sql is a dependency; the single use Ecto.Schema in the tree is a LiveView form
struct). It dates from 2018, moved onto mix releases in 2021 (ENGDESK-12467, Telephony squad), and
was forked and extended for wireless protocols by a colleague in August 2024 (CW-1329).
The primary_maintainer line in meta-dev.yml names him, and that line is my own commit.
The Dockerfile is not mine either (122 lines, two stages, zero commits from me). What I own is everything that calls it: the Makefile, the build arguments, the version files, the pipeline and the deploy specs. That is a smaller job than writing the app, and it is where the breakage lived.
The build arguments are the whole interface
The Dockerfile declares its versions as arguments and builds from a tag assembled out of them:
ARG ELIXIR_VERSION
ARG ERLANG_VERSION
ARG DEBIAN_VERSION
FROM hexpm/elixir:${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-debian-${DEBIAN_VERSION} as base
The values live in my Makefile, so the Elixir version the image compiles against is set in a file
the application developers never open. Theirs is .tool-versions (elixir 1.14.3,
erlang 25.3), which asdf reads for local work. Two files, one fact, no link between them.
On 19 August 2024 a colleague bumped .tool-versions under CW-1481. I matched the Makefile to it
at 20:55 and reverted at 21:05 (two commits, ten minutes apart). A build on an untried
Elixir/Erlang pair was not something I wanted to debug at the tail of a migration. The image still
builds on 1.12.3 and 24.1.7 today, so the two files have disagreed for two years — a known
divergence now, a revert at the time.
Hex auth fails before anything else does
The base stage authenticates to the private hex organisation before it fetches a single dependency:
ARG ELIXIR_HEX_KEY=""
RUN mix local.hex --force; \
mix local.rebar --force; \
mix hex.organization auth <org> --key=${ELIXIR_HEX_KEY};
So an absent key fails the build at mix deps.get — with an error about dependency resolution
instead of one about credentials. That is why three string credentials went into the pipeline by
hand the first time it ran (hex key, Oban key, Oban fingerprint). Two of those three
(ELIXIR_OBAN_KEY, ELIXIR_OBAN_PUBLIC_KEY_FINGERPRINT) are build args the Dockerfile never
declares, so Docker accepts them and drops them on the floor.
Two version files, and a fallback you do not want
app_version.exs reads the VERSION file and, when it cannot, shells out to git describe and
logs a warning that this is slow:
defp handle_file_version({:error, _}) do
retrieve_version_from_git() |> String.split("-") |> case do
[tag] -> tag
[tag, _num_commits, commit] -> "#{tag}-#{commit}"
end
end
Inside an image built from a copied tree with no .git, that fallback returns 0.0.0. So
VERSION is load-bearing for the compiled release, while the pipeline tags the image from a
different file (IMAGEVERSION, one line, holding red). Collapsing the two into one file cost
me five commits in a single evening. Keeping them apart is the answer, because the semver the
application reports and the rolling tag the registry serves are not the same thing.
What it runs on
make build pulls its own previous image first (docker pull $(docker_image) || true) so a cold
registry degrades to a slow build instead of a failed one. The release stage is plain Debian with
three packages (ca-certificates, openssl, tshark), running as uid 999. It exposes three ports
(1968 for Phoenix, 4369 for EPMD, 9200 for a remote console). tshark sits in both stages because
filtering shells out to it; host-mounted pcap directories are the only reason deployment stayed on
ansible.
The spec is one instance, 256 CPU shares and 256 MB — identical in dev and prod. I copied those
numbers across into meta-prod.yml on 28 August 2024 and nobody has revisited them since.