@@ -24,33 +24,29 @@ RUN \
2424--mount=type=cache,target=/root/.cache/go-build \
2525CGO_ENABLED=0 go build -o /go/bin/init -v --ldflags '-s -w -extldflags=-static'
2626
27+ # =========================================================
28+ FROM golang:1.25.2-alpine AS imager-build
29+ WORKDIR /go/src
30+ COPY imager/go.mod imager/go.sum ./
31+ RUN go mod download
32+ COPY imager .
33+ RUN \
34+ --mount=type=cache,target=/root/.cache/go-build \
35+ go generate -v ./... && \
36+ go test && \
37+ CGO_ENABLED=0 go build -o /go/bin/imager -v --ldflags '-s -w -extldflags=-static' cmd/main.go
38+
2739# =========================================================
2840FROM alpine:3.22.2 AS alpine-base
2941
3042# =========================================================
3143FROM 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
44+ RUN apk add --no-cache binutils systemd-efistub
45+ # TODO: embed init
5046COPY --from=init /go/bin/init /usr/share/claylinux/init
51- COPY build-image.sh /usr /bin/build-image
47+ COPY --from=imager-build /go /bin/imager /bin/imager
5248WORKDIR /out
53- ENTRYPOINT ["build-image " ]
49+ ENTRYPOINT ["/bin/imager " ]
5450
5551# =========================================================
5652FROM alpine-base AS bootable-alpine-rootfs
@@ -110,14 +106,14 @@ RUN if [ "$UCODE" != "none" ]; then apk add --no-cache "${UCODE}-ucode"; fi
110106# hadolint ignore=DL3006
111107FROM imager AS test
112108ARG FORMAT=efi
113- RUN --mount=from=test-rootfs,target=/system build-image --format "$FORMAT"
109+ RUN --mount=from=test-rootfs,target=/system /bin/imager --format "$FORMAT"
114110
115111# =========================================================
116112# Generate a qemu image running our custom OS image
117113FROM alpine-base AS emulator
118114RUN apk add --no-cache bash qemu-system-x86_64 ovmf
119115COPY emulator.sh /entrypoint
120- ENTRYPOINT ["/entrypoint" ]
121116COPY --from=test /out /images
122117ARG FORMAT
123118ENV FORMAT="$FORMAT"
119+ ENTRYPOINT ["/entrypoint" ]
0 commit comments