Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
Multi-stage Builds in Depth: Targets, a Test Stage, Parallel Stages and Image Size
In a multi-stage build the final image holds only the last stage's content, and BuildKit builds only the stages that lead to the target, running independent ones in parallel. We split Bookstore.Tools into restore, build, test, export, debug and final stages, cut the image from 1.34 GB to 143 MB, see the limits of a test stage and a chiseled image, and produce a two-architecture image without QEMU using --platform=$BUILDPLATFORM.
Dockerfile Basics: FROM, RUN, COPY, WORKDIR, ENV, ARG, USER, EXPOSE, CMD and ENTRYPOINT
In a Dockerfile, RUN, COPY, ADD and WORKDIR touch the file system and produce layers; ENV, ARG, USER, EXPOSE, CMD and ENTRYPOINT are only written to the image config. We write the first Dockerfile for Bookstore.Tools, catch the draft's mistakes with docker build --check, and see with real output how ENTRYPOINT and CMD combine, how a token passed as ARG shows up in docker history, what .dockerignore changes, why EXPOSE opens no port, and the apt-get cache trap.