What a shared base image brings with it
Moving the IMS container onto the platform's FRR base image took an afternoon of build time and two collisions nobody had written down.
The IMS container runs three Kamailio servers under s6 (P-CSCF, I-CSCF and S-CSCF, all in one image), and until October 2025 it started from ubuntu:24.04. CW-2856 moved it onto the infrastructure team's FRR image instead, pinned by digest and not by tag:
ARG BASE_IMAGE=registry.internal/infra/cr-frr:frr-8-jammy-2024.10.21@sha256:d3e7308f…
The reason was routing. The container has to advertise its own address over BGP, and FRR was already in that base image. Packaging a second copy of FRR here would have been a second thing to keep current (same daemon, same version skew). What the base image also brought was two collisions.
Two programs called envtpl
Every Kamailio config in the repository is a template rendered at container start by envtpl, the Python one, which takes {{ VAR }} placeholders and flags like -o and --keep-template. The FRR base image ships a different envtpl — a Go reimplementation — at exactly /usr/local/bin/envtpl. Which of the two ends up at that path after a pip3 install is not a thing to leave to chance. The Dockerfile stopped leaving it.
The fix is one clause in the Dockerfile and nine absolute paths in runtime-config.sh:
RUN rm -f /usr/local/bin/envtpl && apt-get install -y … && pip3 install envtpl
The script's own comment is the clearest record of it: "Force use of Python envtpl to avoid Go version issues". Nine template calls became /usr/local/bin/envtpl /etc/kamailio_scscf/scscf.cfg.tpl and so on, so a bare envtpl on PATH can never be the thing that runs.
s6, in two layouts
The old Dockerfile fetched s6-overlay as a tarball (v2.0.0.1, amd64), checked its sha1, and unpacked it at /. It then set SHELL ["/usr/bin/bash", "-lc"], to stop depending on /bin/sh once the overlay had landed on top of it. All three steps came out — the base image already carries s6, in the newer s6-rc layout.
So the image now has both conventions in it. The three Kamailio services sit where they always did (/etc/services.d/kamailio-pcscf/run, plus two siblings); FRR's own script goes to /etc/s6-overlay/s6-rc.d/frr/run, which is where the base image's supervision tree looks. S6_BEHAVIOUR_IF_STAGE2_FAILS=2 is set, so a failed cont-init stops the container instead of leaving it half-started with no Kamailio.
The listen address is a runtime fact
FRR's config is templated like everything else — hostname, three static routes for the private ranges, one BGP neighbour (advertisement-interval 1, timers 3 12). The one thing a template cannot supply is which address bgpd should bind. start-frr.sh digs it out of the interface list and patches the daemon options in place:
sed -i "s/bgpd_options=\" /bgpd_options=\" -l $(ip -4 -o address | grep ${BGP_LISTEN_IFACE_PREFIX} | head -1 | …)/g" /etc/frr/daemons
That is a sed against a vendor config file at boot (/etc/frr/daemons, owned by the FRR package). It is not something to be proud of; the alternative was a second templating pass over a file FRR's own packaging replaces on upgrade.
What the image actually is
It is large, and deliberately so. The build compiles Kamailio 5.6 from a fork with an explicit include_modules list (24 modules, MEMDBG=1), so the toolchain goes in too (gcc, g++, flex, bison, autoconf, and a row of dev headers). None of it is discarded afterwards, because there is no second stage. Then the utilities go on: tcpdump, tshark, sngrep, nmap, traceroute, mysql-client, iptables and procps — the last two added alongside the IPsec work (CW-2840).
The DNS image next door shows what the other choice looks like. It copies one binary out of coredns/coredns:1.11.1 into alpine:3.20, then adds two packages (gettext for envsubst, ca-certificates). That is the entire image. The IMS image went the other way on purpose: the container is the only place to run kamcmd against a live registration, so pcmd, scmd, icmd and ipsec-status are baked in as wrapper scripts (CW-2804, two commits — the first set of aliases did not survive contact with the build). A debuggable image beats a small one when the fault you are chasing only shows up on a real handset. That is the whole of the argument, and it is worth saying out loud instead of implying it with a layer count.