init
This commit is contained in:
+301
@@ -0,0 +1,301 @@
|
||||
ARG MOUSE_ROOTFS_STAGE=rootfs-builder
|
||||
|
||||
FROM alpine@sha256:28bd5fe8b56d1bd048e5babf5b10710ebe0bae67db86916198a6eec434943f8b AS toolchain
|
||||
|
||||
RUN apk add --no-cache \
|
||||
bc=1.08.2-r1 \
|
||||
build-base=0.5-r4 \
|
||||
clang22=22.1.3-r2 \
|
||||
cmake=4.2.3-r0 \
|
||||
curl=8.21.0-r0 \
|
||||
diffutils=3.12-r0 \
|
||||
elfutils-dev=0.195-r0 \
|
||||
file=5.47-r2 \
|
||||
findutils=4.10.0-r1 \
|
||||
gawk=5.3.2-r2 \
|
||||
lld22=22.1.3-r0 \
|
||||
linux-headers=7.0.0-r1 \
|
||||
llvm=22-r0 \
|
||||
patch=2.8-r0 \
|
||||
perl=5.42.2-r0 \
|
||||
python3=3.14.5-r0 \
|
||||
rustup=1.29.0-r0 \
|
||||
rsync=3.4.3-r1 \
|
||||
openssl-dev=3.5.7-r0 \
|
||||
xz=5.8.3-r0
|
||||
|
||||
RUN apk add --no-cache flex=2.6.4-r8
|
||||
|
||||
ENV RUSTUP_HOME=/opt/rustup
|
||||
ENV CARGO_HOME=/opt/cargo
|
||||
ENV PATH=/opt/cargo/bin:/usr/lib/llvm22/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
RUN rustup-init -y \
|
||||
--profile minimal \
|
||||
--default-toolchain 1.94.0 \
|
||||
--target x86_64-unknown-linux-musl \
|
||||
&& chmod -R a+rX /opt/rustup /opt/cargo
|
||||
|
||||
WORKDIR /work/mouse-src
|
||||
ARG MOUSE_BUILD_JOBS=8
|
||||
ENV MOUSE_BUILD_JOBS=${MOUSE_BUILD_JOBS}
|
||||
|
||||
FROM scratch AS toolchain-sources
|
||||
COPY mouse-sources/toolchain/ /opt/mouse-sources/
|
||||
|
||||
FROM scratch AS kernel-sources
|
||||
COPY mouse-sources/kernel/ /opt/mouse-sources/
|
||||
|
||||
FROM scratch AS firmware-sources
|
||||
COPY mouse-sources/firmware/ /opt/mouse-sources/
|
||||
|
||||
FROM scratch AS facilities-sources
|
||||
COPY mouse-sources/facilities/ /opt/mouse-sources/
|
||||
|
||||
FROM scratch AS storage-sources
|
||||
COPY mouse-sources/storage/ /opt/mouse-sources/
|
||||
|
||||
FROM scratch AS pkgsrc-sources
|
||||
COPY mouse-sources/pkgsrc/ /opt/mouse-sources/
|
||||
|
||||
FROM scratch AS software-sources
|
||||
COPY mouse-sources/software/ /opt/mouse-sources/
|
||||
|
||||
FROM --platform=linux/amd64 alpine@sha256:28bd5fe8b56d1bd048e5babf5b10710ebe0bae67db86916198a6eec434943f8b AS pkgsrc-seed-tools
|
||||
|
||||
FROM toolchain AS kernel-builder
|
||||
|
||||
RUN apk add --no-cache bison=3.8.2-r3
|
||||
|
||||
COPY --from=kernel-sources /opt/mouse-sources/ /opt/mouse-sources/
|
||||
COPY mouse-src/base/kernel/ /work/mouse-src/base/kernel/
|
||||
COPY mouse-src/scripts/build-kernel.sh /work/mouse-src/scripts/build-kernel.sh
|
||||
|
||||
RUN MOUSE_SOURCE_DIR=/opt/mouse-sources \
|
||||
/work/mouse-src/scripts/build-kernel.sh
|
||||
|
||||
FROM kernel-builder AS kernel-test-builder
|
||||
|
||||
COPY mouse-src/tests/fixtures/kernel-module/ /work/mouse-src/tests/fixtures/kernel-module/
|
||||
COPY mouse-src/scripts/build-kernel-test-module.sh /work/mouse-src/scripts/build-kernel-test-module.sh
|
||||
|
||||
RUN /work/mouse-src/scripts/build-kernel-test-module.sh
|
||||
|
||||
# Keep the resource-heavy kernel and LLVM builds from running concurrently.
|
||||
# The constant marker adds an ordering edge without passing kernel artifacts
|
||||
# into the static-base cache key.
|
||||
FROM kernel-builder AS kernel-ready
|
||||
|
||||
RUN install -m 0444 /dev/null /kernel-ready
|
||||
|
||||
FROM toolchain AS static-base-bootstrap
|
||||
|
||||
RUN apk add --no-cache \
|
||||
bison=3.8.2-r3 \
|
||||
byacc=20260126-r0
|
||||
|
||||
COPY --from=kernel-ready /kernel-ready /tmp/kernel-ready
|
||||
|
||||
COPY --from=toolchain-sources /opt/mouse-sources/ /opt/mouse-sources/
|
||||
COPY --from=kernel-sources /opt/mouse-sources/ /opt/mouse-sources/
|
||||
COPY --from=software-sources /opt/mouse-sources/ /opt/mouse-sources/
|
||||
COPY mouse-src/base/support/cross-compiler-driver /work/mouse-src/base/support/cross-compiler-driver
|
||||
COPY mouse-src/base/support/rust-eh-personality.c /work/mouse-src/base/support/rust-eh-personality.c
|
||||
COPY mouse-src/scripts/configure-cross-toolchain.sh /work/mouse-src/scripts/configure-cross-toolchain.sh
|
||||
COPY mouse-src/scripts/static-base/common.sh /work/mouse-src/scripts/static-base/common.sh
|
||||
COPY mouse-src/scripts/static-base/bootstrap.sh /work/mouse-src/scripts/static-base/bootstrap.sh
|
||||
|
||||
RUN MOUSE_SOURCE_DIR=/opt/mouse-sources \
|
||||
sh /work/mouse-src/scripts/static-base/bootstrap.sh
|
||||
|
||||
FROM static-base-bootstrap AS static-base-libraries
|
||||
|
||||
COPY mouse-src/scripts/static-base/libraries-and-accounts.sh /work/mouse-src/scripts/static-base/libraries-and-accounts.sh
|
||||
|
||||
RUN MOUSE_SOURCE_DIR=/opt/mouse-sources \
|
||||
sh /work/mouse-src/scripts/static-base/libraries-and-accounts.sh
|
||||
|
||||
FROM static-base-libraries AS static-base-toolchain
|
||||
|
||||
COPY mouse-src/scripts/static-base/native-toolchain.sh /work/mouse-src/scripts/static-base/native-toolchain.sh
|
||||
|
||||
RUN MOUSE_NATIVE_TOOLCHAIN_PHASE=llvm \
|
||||
MOUSE_SOURCE_DIR=/opt/mouse-sources \
|
||||
sh /work/mouse-src/scripts/static-base/native-toolchain.sh
|
||||
|
||||
RUN MOUSE_NATIVE_TOOLCHAIN_PHASE=package-tools \
|
||||
MOUSE_SOURCE_DIR=/opt/mouse-sources \
|
||||
sh /work/mouse-src/scripts/static-base/native-toolchain.sh
|
||||
|
||||
COPY mouse-src/scripts/static-base/dynamic-runtime.sh /work/mouse-src/scripts/static-base/dynamic-runtime.sh
|
||||
|
||||
RUN sh /work/mouse-src/scripts/static-base/dynamic-runtime.sh
|
||||
|
||||
FROM static-base-toolchain AS static-base-system
|
||||
|
||||
COPY mouse-src/base/patches/chimerautils-native-cdefs.patch /work/mouse-src/base/patches/chimerautils-native-cdefs.patch
|
||||
COPY mouse-src/base/patches/chimerautils-scanflike.patch /work/mouse-src/base/patches/chimerautils-scanflike.patch
|
||||
COPY mouse-src/base/patches/tcsh-gethost-native.patch /work/mouse-src/base/patches/tcsh-gethost-native.patch
|
||||
COPY mouse-src/scripts/static-base/system-services.sh /work/mouse-src/scripts/static-base/system-services.sh
|
||||
|
||||
RUN MOUSE_SOURCE_DIR=/opt/mouse-sources \
|
||||
sh /work/mouse-src/scripts/static-base/system-services.sh
|
||||
|
||||
FROM static-base-system AS static-base-facilities
|
||||
|
||||
COPY --from=facilities-sources /opt/mouse-sources/ /opt/mouse-sources/
|
||||
COPY mouse-src/base/patches/nftables-posix-configure.patch /work/mouse-src/base/patches/nftables-posix-configure.patch
|
||||
COPY mouse-src/scripts/static-base/facilities.sh /work/mouse-src/scripts/static-base/facilities.sh
|
||||
|
||||
RUN MOUSE_SOURCE_DIR=/opt/mouse-sources \
|
||||
sh /work/mouse-src/scripts/static-base/facilities.sh
|
||||
|
||||
FROM static-base-facilities AS static-base-storage
|
||||
|
||||
COPY --from=storage-sources /opt/mouse-sources/ /opt/mouse-sources/
|
||||
COPY mouse-src/scripts/static-base/storage.sh /work/mouse-src/scripts/static-base/storage.sh
|
||||
|
||||
RUN MOUSE_SOURCE_DIR=/opt/mouse-sources \
|
||||
sh /work/mouse-src/scripts/static-base/storage.sh
|
||||
|
||||
FROM static-base-storage AS static-base-builder
|
||||
|
||||
COPY mouse-src/scripts/static-base/finish.sh /work/mouse-src/scripts/static-base/finish.sh
|
||||
|
||||
RUN MOUSE_SOURCE_DIR=/opt/mouse-sources \
|
||||
sh /work/mouse-src/scripts/static-base/finish.sh
|
||||
|
||||
FROM --platform=linux/amd64 scratch AS pkgsrc-seed-builder
|
||||
|
||||
ARG MOUSE_BUILD_JOBS=8
|
||||
|
||||
COPY --from=static-base-builder /work/mouse-src/build/static/rootfs /
|
||||
COPY --from=pkgsrc-sources /opt/mouse-sources/pkgsrc-2026Q2.tar.gz /usr/share/mouse/pkgsrc-2026Q2.tar.gz
|
||||
COPY mouse-src/base/rootfs/etc/group /etc/group
|
||||
COPY mouse-src/base/rootfs/etc/mouse-release /etc/mouse-release
|
||||
COPY mouse-src/base/rootfs/etc/passwd /etc/passwd
|
||||
COPY mouse-src/base/patches/pkgsrc-bootstrap-mouse.patch /usr/share/mouse/pkgsrc-bootstrap-mouse.patch
|
||||
COPY mouse-src/scripts/build-pkgsrc-seed.sh /usr/libexec/mouse-build-pkgsrc-seed
|
||||
COPY --from=pkgsrc-seed-tools /bin/busybox /usr/libexec/mouse-build-busybox
|
||||
|
||||
RUN MOUSE_BUILD_JOBS="$MOUSE_BUILD_JOBS" \
|
||||
sh /usr/libexec/mouse-build-pkgsrc-seed
|
||||
|
||||
FROM toolchain AS btrfs-image-builder
|
||||
|
||||
RUN apk add --no-cache \
|
||||
mtools=4.0.49-r0 \
|
||||
pkgconf=2.5.1-r0 \
|
||||
sfdisk=2.42.1-r0 \
|
||||
util-linux-dev=2.42.1-r0 \
|
||||
zlib-dev=1.3.2-r0 \
|
||||
zstd-dev=1.5.7-r2
|
||||
|
||||
COPY --from=storage-sources /opt/mouse-sources/btrfs-progs-v7.0.tar.xz /opt/
|
||||
COPY --from=storage-sources /opt/mouse-sources/limine-binary-12.3.2.tar.xz /opt/mouse-sources/limine-binary-12.3.2.tar.xz
|
||||
|
||||
RUN tar -C /work -xf /opt/btrfs-progs-v7.0.tar.xz \
|
||||
&& cd /work/btrfs-progs-v7.0 \
|
||||
&& ./configure \
|
||||
--prefix=/usr \
|
||||
--disable-backtrace \
|
||||
--disable-documentation \
|
||||
--disable-convert \
|
||||
--disable-lzo \
|
||||
--disable-libudev \
|
||||
--disable-python \
|
||||
--disable-zoned \
|
||||
--with-crypto=builtin \
|
||||
&& make \
|
||||
-j"$MOUSE_BUILD_JOBS" \
|
||||
mkfs.btrfs \
|
||||
&& install -m 0755 \
|
||||
/work/btrfs-progs-v7.0/mkfs.btrfs \
|
||||
/opt/mkfs.btrfs
|
||||
|
||||
FROM static-base-builder AS image-commands-builder
|
||||
|
||||
COPY mouse-src/base/support/mouse-bootenv /work/mouse-src/base/support/mouse-bootenv
|
||||
COPY mouse-src/scripts/audit-static-base.sh /work/mouse-src/scripts/audit-static-base.sh
|
||||
COPY mouse-src/scripts/build-image-commands.sh /work/mouse-src/scripts/build-image-commands.sh
|
||||
|
||||
RUN /work/mouse-src/scripts/build-image-commands.sh \
|
||||
&& /work/mouse-src/scripts/audit-static-base.sh /work/mouse-src/build/static/rootfs
|
||||
|
||||
FROM image-commands-builder AS test-fixtures-builder
|
||||
|
||||
COPY mouse-src/tests/fixtures/mouse-echo/mouse-echo.c /work/mouse-src/tests/fixtures/mouse-echo/mouse-echo.c
|
||||
|
||||
RUN /work/mouse-src/build/static/cross-tools/bin/x86_64-mouse-linux-musl-cc \
|
||||
-O2 -Wall -Wextra -Werror \
|
||||
/work/mouse-src/tests/fixtures/mouse-echo/mouse-echo.c \
|
||||
-o /opt/mouse-echo
|
||||
|
||||
FROM image-commands-builder AS cheesed-builder
|
||||
|
||||
COPY mouse-src/base/cheesed/ /work/mouse-src/base/cheesed/
|
||||
|
||||
RUN CHEESED_TARGET=x86_64-unknown-linux-musl \
|
||||
/work/mouse-src/base/cheesed/scripts/build-static.sh \
|
||||
&& install -m 0755 \
|
||||
/work/mouse-src/base/cheesed/target/x86_64-unknown-linux-musl/release/cheesed \
|
||||
/opt/cheesed
|
||||
|
||||
FROM btrfs-image-builder AS rootfs-common
|
||||
|
||||
COPY --from=cheesed-builder /work/mouse-src/build/static/rootfs /work/mouse-src/build/static/rootfs
|
||||
COPY --from=cheesed-builder /opt/cheesed /opt/cheesed
|
||||
COPY --from=kernel-builder /work/mouse-src/build/vmlinuz-virt /work/mouse-src/build/vmlinuz-virt
|
||||
COPY --from=pkgsrc-seed-builder /usr/local /opt/mouse-pkgsrc-seed/usr/local
|
||||
COPY --from=pkgsrc-seed-builder /var/db/pkg /opt/mouse-pkgsrc-seed/var/db/pkg
|
||||
COPY mouse-src/base/rootfs/ /work/mouse-src/base/rootfs/
|
||||
COPY mouse-src/base/patches/pkgsrc-rc.subr-cgroup.patch /work/mouse-src/base/patches/pkgsrc-rc.subr-cgroup.patch
|
||||
COPY mouse-src/scripts/audit-static-base.sh /work/mouse-src/scripts/audit-static-base.sh
|
||||
COPY mouse-src/scripts/build-image.sh /work/mouse-src/scripts/build-image.sh
|
||||
COPY mouse-src/scripts/build-boot-disk.sh /work/mouse-src/scripts/build-boot-disk.sh
|
||||
COPY mouse-src/base/limine.conf /work/mouse-src/base/limine.conf
|
||||
|
||||
FROM rootfs-common AS rootfs-builder
|
||||
|
||||
COPY --from=kernel-builder /work/mouse-src/build/kernel/modules /opt/mouse-kernel-modules
|
||||
|
||||
RUN MOUSE_SOURCE_DIR=/opt/mouse-sources \
|
||||
MOUSE_CHEESED_BINARY=/opt/cheesed \
|
||||
MOUSE_BTRFS_IMAGE_TOOL=/opt/mkfs.btrfs \
|
||||
MOUSE_PKGSRC_SEED=/opt/mouse-pkgsrc-seed \
|
||||
MOUSE_KERNEL_MODULES=/opt/mouse-kernel-modules \
|
||||
/work/mouse-src/scripts/build-image.sh
|
||||
|
||||
FROM rootfs-common AS rootfs-test-builder
|
||||
|
||||
COPY --from=kernel-test-builder /work/mouse-src/build/kernel/test-modules /opt/mouse-kernel-modules
|
||||
COPY --from=test-fixtures-builder /opt/mouse-echo /opt/mouse-echo
|
||||
COPY mouse-src/tests/fixtures/ /work/mouse-src/tests/fixtures/
|
||||
|
||||
RUN MOUSE_SOURCE_DIR=/opt/mouse-sources \
|
||||
MOUSE_CHEESED_BINARY=/opt/cheesed \
|
||||
MOUSE_BTRFS_IMAGE_TOOL=/opt/mkfs.btrfs \
|
||||
MOUSE_PKGSRC_SEED=/opt/mouse-pkgsrc-seed \
|
||||
MOUSE_KERNEL_MODULES=/opt/mouse-kernel-modules \
|
||||
MOUSE_MOUSE_ECHO_BINARY=/opt/mouse-echo \
|
||||
MOUSE_INCLUDE_TEST_FIXTURES=1 \
|
||||
/work/mouse-src/scripts/build-image.sh
|
||||
|
||||
FROM ${MOUSE_ROOTFS_STAGE} AS selected-rootfs
|
||||
|
||||
FROM toolchain AS artifact-packer
|
||||
|
||||
COPY --from=selected-rootfs /work/mouse-src/build/mouse-disk.img /
|
||||
COPY --from=firmware-sources /opt/mouse-sources/ovmf-0.0.202605-r0.apk /opt/
|
||||
|
||||
RUN mkdir -p /opt/ovmf \
|
||||
&& tar -xf /opt/ovmf-0.0.202605-r0.apk \
|
||||
-C /opt/ovmf \
|
||||
usr/share/OVMF/OVMF_CODE.fd \
|
||||
&& gzip -1 /mouse-disk.img
|
||||
|
||||
FROM scratch AS artifacts
|
||||
|
||||
COPY --from=kernel-builder /work/mouse-src/build/vmlinuz-virt /
|
||||
COPY --from=artifact-packer /mouse-disk.img.gz /
|
||||
COPY --from=artifact-packer /opt/ovmf/usr/share/OVMF/OVMF_CODE.fd /ovmf-code.fd
|
||||
Reference in New Issue
Block a user