Skip to content

Instantly share code, notes, and snippets.

@tuomassalo
Created March 10, 2025 17:14
Show Gist options
  • Save tuomassalo/6ff29d2f0404975a50bcb0d9fc53784d to your computer and use it in GitHub Desktop.
Save tuomassalo/6ff29d2f0404975a50bcb0d9fc53784d to your computer and use it in GitHub Desktop.
Dockerfile for building static dropbear, busybox and tcpdump for armv7l
FROM alpine:latest
# docker build --progress=plain -t arm-tools .
# docker create --name temp-extract arm-tools && docker cp temp-extract:/out . && docker rm temp-extract
# Install build tools
RUN apk add --no-cache \
build-base \
curl \
bash \
autoconf \
automake \
libtool \
musl-dev \
linux-headers \
xz \
flex \
bison \
bzip2
# Target config
ENV TARGET=arm-linux-musleabi
ENV CROSS_DIR=/usr/$TARGET-cross
ENV CROSS_PREFIX=$CROSS_DIR/bin/$TARGET-
ENV PATH=$CROSS_DIR/bin:$PATH
RUN mkdir /out
# Install musl-cross for armv7l
RUN curl -LO https://musl.cc/$TARGET-cross.tgz && \
tar -xzf $TARGET-cross.tgz -C /usr && \
rm $TARGET-cross.tgz
WORKDIR /build
# ---- Dropbear ----
RUN curl -LO https://matt.ucc.asn.au/dropbear/releases/dropbear-2025.87.tar.bz2 && \
tar -xjf dropbear-2025.87.tar.bz2 && \
rm dropbear-2025.87.tar.bz2
WORKDIR /build/dropbear-2025.87
RUN ./configure --host=$TARGET \
--disable-zlib \
--disable-lastlog \
--disable-utmp \
--disable-wtmp \
--disable-loginfunc \
--disable-pututline \
--disable-pututxline \
--enable-static && \
make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" MULTI=1 STATIC=1
RUN cp dropbearmulti /out/dropbear-armv7l
# ---- BusyBox ----
WORKDIR /build
RUN curl -LO https://www.busybox.net/downloads/busybox-1.36.1.tar.bz2 && \
tar -xjf busybox-1.36.1.tar.bz2 && \
rm busybox-1.36.1.tar.bz2
WORKDIR /build/busybox-1.36.1
RUN make defconfig && \
sed -i 's/.*CONFIG_STATIC.*/CONFIG_STATIC=y/' .config && \
yes "" | make oldconfig && \
make CROSS_COMPILE=$CROSS_PREFIX -j$(nproc) && \
cp busybox /out/busybox-armv7l
# ---- libpcap ----
WORKDIR /build
RUN curl -LO https://www.tcpdump.org/release/libpcap-1.10.5.tar.xz && \
tar -xJf libpcap-1.10.5.tar.xz && \
rm libpcap-1.10.5.tar.xz
WORKDIR /build/libpcap-1.10.5
RUN ./configure --host=$TARGET --enable-static --disable-shared && \
make CC=${CROSS_PREFIX}gcc -j$(nproc)
# ---- tcpdump ----
WORKDIR /build
RUN curl -LO https://www.tcpdump.org/release/tcpdump-4.99.5.tar.xz && \
tar -xJf tcpdump-4.99.5.tar.xz && \
rm tcpdump-4.99.5.tar.xz
WORKDIR /build/tcpdump-4.99.5
RUN ./configure --host=$TARGET \
--with-crypto=no \
--disable-smb \
--disable-ipv6 \
--with-pcap=/build/libpcap-1.10.5 \
--enable-static
RUN make CC="${CROSS_PREFIX}gcc" \
CFLAGS="-Os -static" \
LDFLAGS="-static" \
-j$(nproc) && \
cp tcpdump /out/tcpdump-armv7l
# ---- Final output ----
CMD ["sh", "-c", "ls -la /out/ && echo Build complete."]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment