@@ -17,40 +17,28 @@ RUN --mount=type=bind,target=. \
1717yamllint -v && yamllint -s -f colored .
1818
1919# =========================================================
20- FROM golang:1.25.3-alpine AS init
20+ FROM golang:1.25.3-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.22.2 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
@@ -110,14 +98,14 @@ RUN if [ "$UCODE" != "none" ]; then apk add --no-cache "${UCODE}-ucode"; fi
11098# hadolint ignore=DL3006
11199FROM imager AS test
112100ARG FORMAT=efi
113- RUN --mount=from=test-rootfs,target=/system build-image --format "$FORMAT"
101+ RUN --mount=from=test-rootfs,target=/system /bin/imager --format "$FORMAT"
114102
115103# =========================================================
116104# Generate a qemu image running our custom OS image
117105FROM alpine-base AS emulator
118106RUN apk add --no-cache bash qemu-system-x86_64 ovmf
119107COPY emulator.sh /entrypoint
120- ENTRYPOINT ["/entrypoint" ]
121108COPY --from=test /out /images
122109ARG FORMAT
123110ENV FORMAT="$FORMAT"
111+ ENTRYPOINT ["/entrypoint" ]
0 commit comments