Skip to content
AgileLogics
4 min read

Packaging & Deployment

Prerequisites: Security fundamentals

Unlike a JVM or Python program, a compiled C binary has no runtime dependency on the language itself being installed on the target machine — it's already native machine code. What does matter is matching the target's architecture and any dynamically-linked shared libraries it expects.

FROM gcc:14 AS build
COPY . /src
WORKDIR /src
RUN gcc -O2 -o myapp main.c

FROM debian:bookworm-slim
COPY --from=build /src/myapp /usr/local/bin/myapp
ENTRYPOINT ["myapp"]

This two-stage Docker build compiles in a full toolchain image, then copies only the finished binary into a minimal runtime image — keeping the final deployed image small. Cross-compilation (building for a different CPU architecture than the one doing the building) is common in embedded contexts, where the target device can't run a compiler itself.