This commit is contained in:
Mikaël Cluseau
2024-06-28 21:54:17 +02:00
parent 57064a39b6
commit 5b033bf5ab
6 changed files with 252 additions and 40 deletions

View File

@ -1,16 +1,17 @@
from rust:1.77.1-alpine as rust
# ------------------------------------------------------------------------
from rust:1.79.0-alpine3.20 as rust
run apk add --no-cache musl-dev # pkgconfig cryptsetup-dev lvm2-dev clang-dev clang-static
workdir /src
copy Cargo.* .
copy src src
run --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,sharing=private,target=/src/target \
cargo build --release \
&& cp target/release/init /init-rs
run --mount=type=cache,id=novit-rs,target=/usr/local/cargo/registry \
--mount=type=cache,id=novit-rs-target,sharing=private,target=/src/target \
cargo build --release && cp target/release/init /
from golang:1.21.6-alpine3.19 as build
# ------------------------------------------------------------------------
from golang:1.22.4-alpine3.20 as build
workdir /src
@ -23,7 +24,7 @@ run \
&& go build -o /go/bin/init -trimpath .
# ------------------------------------------------------------------------
from alpine:3.19.0 as initrd
from alpine:3.20.0 as initrd
run apk add --no-cache xz
@ -35,14 +36,14 @@ run apk add --no-cache -p . musl lvm2 lvm2-extra lvm2-dmeventd udev cryptsetup e
run rm -rf usr/share/apk var/cache/apk
#copy --from=build /go/bin/init .
copy --from=rust /init-rs init
copy --from=rust /init .
# check viability
run chroot /layer /init hello
run chroot . /init hello
run find |cpio -H newc -o >/initrd
# ------------------------------------------------------------------------
from alpine:3.19.0
from alpine:3.20.0
copy --from=initrd /initrd /
entrypoint ["base64","/initrd"]