The Dockerfile

Multi-stage: a fat build, a slim ship

Open the real Dockerfile. The first thing to notice is it has three FROM lines, not one β€” that's a multi-stage build. Stage one (base) sets shared config. Stage two (build) installs everything needed to COMPILE gems β€” a C compiler, git, dev headers β€” and runs bundle install. Stage three (final) starts fresh FROM base again and copies over only the compiled result, never the compiler toolchain. The image you actually ship never contains build-essential at all.