@@ -17,40 +17,28 @@ RUN --mount=type=bind,target=. \
1717yamllint -v && yamllint -s -f colored .
1818
1919# =========================================================
20- FROM golang:1.25.5-alpine AS init
20+ FROM golang:1.25.5-alpine AS imager-build
21+ SHELL ["/bin/ash" , "-euxo" , "pipefail" , "-c" ]
2122WORKDIR /go/src
23+ COPY imager/go.mod imager/go.sum ./
24+ RUN go mod download
25+ COPY imager .
2226RUN \
23- --mount=source=init,target=. \
2427--mount=type=cache,target=/root/.cache/go-build \
25- CGO_ENABLED=0 go build -o /go/bin/init -v --ldflags '-s -w -extldflags=-static'
28+ go generate -v ./...; \
29+ go test; \
30+ go build -o /go/bin/imager -v --ldflags "-s -w" cmd/main.go
2631
2732# =========================================================
2833FROM alpine:3.23.0 AS alpine-base
2934
3035# =========================================================
3136FROM alpine-base AS imager
32- SHELL ["/bin/ash" , "-euxo" , "pipefail" , "-c" ]
33- RUN \
34- echo "@edge-community https://dl-cdn.alpinelinux.org/alpine/edge/community" >>/etc/apk/repositories && \
35- apk add --no-cache \
36- bash \
37- binutils \
38- coreutils \
39- cpio \
40- dosfstools \
41- findutils \
42- mtools \
43- pigz \
44- qemu-img \
45- sfdisk \
46- xorriso \
47- zstd \
48- xz \
49- systemd-efistub@edge-community
50- COPY --from=init /go/bin/init /usr/share/claylinux/init
51- COPY build-image.sh /usr/bin/build-image
37+ # TODO: bundle objcopy (or use a golang lib) and systemd-efistub into the imager binary
38+ RUN apk add --no-cache binutils systemd-efistub
39+ COPY --from=imager-build /go/bin/imager /bin/imager
5240WORKDIR /out
53- ENTRYPOINT ["build-image " ]
41+ ENTRYPOINT ["/bin/imager " ]
5442
5543# =========================================================
5644FROM alpine-base AS bootable-alpine-rootfs
@@ -109,14 +97,14 @@ if [ "$UCODE" != "none" ]; then apk add --no-cache "${UCODE}-ucode"; fi;
10997# hadolint ignore=DL3006
11098FROM imager AS test
11199ARG FORMAT=efi
112- RUN --mount=from=test-rootfs,target=/system build-image --format "$FORMAT"
100+ RUN --mount=from=test-rootfs,target=/system /bin/imager --format "$FORMAT"
113101
114102# =========================================================
115103# Generate a qemu image running our custom OS image
116104FROM alpine-base AS emulator
117105RUN apk add --no-cache bash qemu-system-x86_64 ovmf
118106COPY emulator.sh /entrypoint
119- ENTRYPOINT ["/entrypoint" ]
120107COPY --from=test /out /images
121108ARG FORMAT
122109ENV FORMAT="$FORMAT"
110+ ENTRYPOINT ["/entrypoint" ]
0 commit comments