diff --git a/.dockerignore b/.dockerignore index fb78ae7..e7bf1da 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,3 +4,5 @@ dist/* go.work go.work.sum modd.*conf +test-initrd* +test-initrd/**/* diff --git a/Dockerfile b/Dockerfile index 9385f34..2abca56 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,9 @@ run go test ./... run go build -o /go/bin/init -trimpath . # ------------------------------------------------------------------------ -from alpine:3.18.4 +from alpine:3.18.4 as initrd + +run apk add --no-cache xz workdir /layer run wget -O- https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-minirootfs-3.18.4-x86_64.tar.gz |tar zxv @@ -22,4 +24,9 @@ copy --from=build /go/bin/init . # check viability run chroot /layer /init hello -entrypoint ["sh","-c","find |cpio -H newc -o |base64"] +run find |cpio -H newc -o >/initrd + +# ------------------------------------------------------------------------ +from alpine:3.18.4 +copy --from=initrd /initrd / +entrypoint ["base64","/initrd"] diff --git a/modd.test.conf b/modd.test.conf index d4fb958..9e7154c 100644 --- a/modd.test.conf +++ b/modd.test.conf @@ -3,7 +3,8 @@ modd.test.conf {} dist/initrd dist/cpiocat dist/testconf test-initrd/**/* { prep: dist/testconf test-initrd/config.yaml prep: cp -f dist/initrd test-initrd.cpio - prep: cd test-initrd && ../dist/cpiocat <../dist/initrd >../test-initrd.cpio * - prep: if cpio -t -F test-initrd.cpio 2>&1 |grep bytes.of.junk; then echo "bad cpio archive"; exit 1; fi + prep: cd test-initrd && cat ../dist/initrd | ../dist/cpiocat * |lz4 -l9v >../test-initrd.cpio.new + prep: mv test-initrd.cpio.new test-initrd.cpio + prep: if lz4cat test-initrd.cpio | cpio -t 2>&1 |grep bytes.of.junk; then echo "bad cpio archive"; exit 1; fi prep: kill $(