diff --git a/Dockerfile b/Dockerfile index 566383f..2fc1394 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ FROM gitea.okami101.io/okami101/stagex/core-gcc:latest AS gcc FROM gitea.okami101.io/okami101/stagex/core-make:latest AS make FROM gitea.okami101.io/okami101/stagex/core-musl:latest AS musl FROM gitea.okami101.io/okami101/stagex/core-busybox:latest AS busybox +FROM gitea.okami101.io/okami101/stagex/core-diffutils:latest AS diffutils FROM scratch AS bootstrap-c-toolchain COPY --from=binutils / / @@ -129,8 +130,40 @@ RUN make -j $(nproc) headers ARCH=x86_64 && \ RUN mkdir -p /rootfs/usr/include && \ cp -rv usr/include/* /rootfs/usr/include +FROM bootstrap-c-toolchain AS build-musl +COPY --from=diffutils / / + +ENV CFLAGS="" +ENV CXXFLAGS="" +ENV LDFLAGS="" + +ARG VERSION=1.2.5 + +WORKDIR /source + +RUN wget https://www.musl-libc.org/releases/musl-${VERSION}.tar.gz -O musl.tar.xz + +RUN tar -xzf musl.tar.gz --strip-components=1 && \ + mkdir build && \ + cd build && \ + ../configure --prefix=/usr + +RUN cd build && \ + make -j $(nproc) + +RUN cd build && \ + make DESTDIR=/rootfs install && \ + ARCH=$(uname -m) && \ + mkdir -p /rootfs/usr/bin /rootfs/usr/lib && \ + rm -rf /rootfs/lib && \ + ln -sf /usr/lib/ld-musl-${ARCH}.so.1 /rootfs/usr/bin/ldd && \ + mv -f /rootfs/usr/lib/libc.so /rootfs/usr/lib/ld-musl-${ARCH}.so.1 && \ + ln -sf ld-musl-${ARCH}.so.1 /rootfs/usr/lib/libc.musl-${ARCH}.so.1 && \ + ln -sf /usr/lib/ld-musl-${ARCH}.so.1 /rootfs/usr/lib/libc.so + FROM busybox AS final COPY --from=build-make /rootfs/ / COPY --from=build-binutils /rootfs/ / COPY --from=build-gcc /rootfs/ / COPY --from=build-linux-headers /rootfs/ / +COPY --from=build-musl /rootfs/ /