Skip to content

Instantly share code, notes, and snippets.

@jmahmood
Created July 9, 2025 08:40
Show Gist options
  • Select an option

  • Save jmahmood/e312146fafe9cd091891ae335ee3a0cd to your computer and use it in GitHub Desktop.

Select an option

Save jmahmood/e312146fafe9cd091891ae335ee3a0cd to your computer and use it in GitHub Desktop.
Build a statically linked version of DTC
# syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM debian:bookworm AS builder
ARG DTC_REF=v1.7.0 # or any commit / tag
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential git flex bison pkg-config \
libfdt-dev \
zlib1g-dev \
libyaml-dev ca-certificates libyaml*
WORKDIR /src
RUN git clone --depth 1 --branch "v1.7.0" https://github.com/dgibson/dtc.git .
# full static build — we don’t care about size
RUN make -C /src -j"$(nproc)" \
HAVE_LIBYAML=0 \
CFLAGS="-O2 -pipe -static" \
LDFLAGS="-static" \
dtc
ENTRYPOINT ["/src/dtc"]
FROM --platform=$TARGETARCH scratch
COPY --from=builder /src/dtc /
ENTRYPOINT ["/dtc"]
# docker build --platform linux/arm64 --progress=plain --output ./output -f ./Dockerfile.dtc .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment