stagex/packages/zig/Containerfile
2024-08-26 11:24:57 -07:00

43 lines
1.2 KiB
Docker

FROM scratch AS base
ENV VERSION=0.11.0
ENV SRC_HASH=72014e700e50c0d3528cef3adf80b76b26ab27730133e8202716a187a799e951
ENV SRC_FILE=zig-${VERSION}.tar.xz
ENV SRC_SITE=https://ziglang.org/download/${VERSION}/${SRC_FILE}
FROM base AS fetch
ADD --checksum=sha256:${SRC_HASH} ${SRC_SITE} .
COPY static-glibc.patch .
FROM fetch AS build
COPY --from=stagex/binutils . /
COPY --from=stagex/busybox . /
COPY --from=stagex/clang16 . /
COPY --from=stagex/cmake . /
COPY --from=stagex/gcc . /
COPY --from=stagex/libzstd . /
COPY --from=stagex/lld . /
COPY --from=stagex/llvm16 . /
COPY --from=stagex/make . /
COPY --from=stagex/musl . /
COPY --from=stagex/openssl . /
COPY --from=stagex/zlib . /
RUN --network=none tar -xf ${SRC_FILE}
WORKDIR /zig-${VERSION}
RUN --network=none patch -p1 -i ../static-glibc.patch
RUN --network=none <<-EOF
set -eux
cmake -Bbuild \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=None \
-DZIG_STATIC=ON \
-DZIG_TARGET_TRIPLE=native-linux-musl \
-DZIG_TARGET_MCPU=baseline
cmake --build build
EOF
FROM build AS install
RUN --network=none DESTDIR=/rootfs cmake --install build
FROM stagex/filesystem AS package
COPY --from=install /rootfs/. /