Created
July 9, 2025 08:40
-
-
Save jmahmood/e312146fafe9cd091891ae335ee3a0cd to your computer and use it in GitHub Desktop.
Build a statically linked version of DTC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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