Skip to content

Commit

Permalink
Change busybox to be musl linked
Browse files Browse the repository at this point in the history
  • Loading branch information
errge committed Mar 4, 2024
1 parent 24e514b commit d2cfb87
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# We build our own busybox-static with musl, because the default
# debian one links to glibc, and glibc implements rfc3484, and
# "rule 9" of that rfc is grossly incompatible with kube headless
# services. We would like to start a discussion about all this
# on the glibc mailing list, and for that we need nilcons-debian to
# contain both glibc based (normal) and musl based (busybox) wget,
# for demonstration purposes.
#
# Once this rfc3484 based glibc behaviour is fixed, we can remove this
# hack and go back to using normal busybox-static from debian.
FROM debian:bookworm AS busybox-build
RUN </etc/apt/sources.list.d/debian.sources sed s/deb$/deb-src/ >/etc/apt/sources.list.d/debian-src.sources
RUN apt-get update -q && apt-get install -y build-essential musl-tools && apt-get build-dep -y busybox
RUN ln -s /usr/include/linux /usr/include/asm-generic /usr/include/*-gnu*/asm /usr/include/*-musl*
RUN mkdir /tmp/bb && cd /tmp/bb \
&& apt-get source busybox \
&& mv /tmp/bb/busybox-* /tmp/bb/busybox \
&& cd /tmp/bb/busybox \
&& mkdir build-musl && cat debian/config/os/linux debian/config/pkg/static >build-musl/.config \
&& sed -i s/CONFIG_EXTRA_COMPAT=y/CONFIG_EXTRA_COMPAT=n/ build-musl/.config \
&& sed -i s/CONFIG_FEATURE_VI_REGEX_SEARCH=y/CONFIG_FEATURE_VI_REGEX_SEARCH=n/ build-musl/.config \
&& sed -i s/CONFIG_UBIRENAME=y/CONFIG_UBIRENAME=n/ build-musl/.config \
&& yes "" | make CC=musl-gcc LD=musl-gcc -C build-musl -f $PWD/Makefile KBUILD_SRC=$PWD oldconfig \
&& make CC=musl-gcc LD=musl-gcc -C build-musl -f $PWD/Makefile KBUILD_SRC=$PWD

FROM debian:bookworm
RUN apt-get update -q \
&& apt-get install -y -q --no-install-recommends \
Expand All @@ -9,6 +34,8 @@ RUN apt-get update -q \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY bash-if-tty tini-if-1 /usr/bin/
RUN dpkg-divert --rename --add /usr/bin/busybox
COPY --from=busybox-build /tmp/bb/busybox/build-musl/busybox /usr/bin/busybox
ENTRYPOINT [ "/usr/bin/tini-if-1" ]
CMD [ "/usr/bin/bash-if-tty" ]

Expand Down

0 comments on commit d2cfb87

Please sign in to comment.