26 lines
670 B
Docker
26 lines
670 B
Docker
|
from golang:1.21.4-alpine3.18 as build
|
||
|
|
||
|
workdir /src
|
||
|
copy go.mod go.sum .
|
||
|
run go mod download
|
||
|
|
||
|
copy . .
|
||
|
run go test ./...
|
||
|
run go build -o /go/bin/init -trimpath .
|
||
|
|
||
|
# ------------------------------------------------------------------------
|
||
|
from alpine:3.18.4
|
||
|
|
||
|
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
|
||
|
|
||
|
run apk add --no-cache -p . musl lvm2 lvm2-dmeventd udev cryptsetup e2fsprogs btrfs-progs lsblk
|
||
|
run rm -rf usr/share/apk var/cache/apk
|
||
|
|
||
|
copy --from=build /go/bin/init .
|
||
|
|
||
|
# check viability
|
||
|
run chroot /layer /init hello
|
||
|
|
||
|
entrypoint ["sh","-c","find |cpio -H newc -o |base64"]
|