@@ -24,33 +24,27 @@ 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.24.5-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+ # COPY --from=init /go/bin/init /usr/share/claylinux/init
34+ RUN \
35+ --mount=type=cache,target=/root/.cache/go-build \
36+ go generate -v ./... && \
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.1 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
50- COPY --from=init /go/bin/init /usr/share/claylinux/init
51- COPY build-image.sh /usr/bin/build-image
44+ RUN apk add --no-cache binutils systemd-efistub
45+ COPY --from=imager-build /go/bin/imager /bin/imager
5246WORKDIR /out
53- ENTRYPOINT ["build-image " ]
47+ ENTRYPOINT ["/bin/imager " ]
5448
5549# =========================================================
5650FROM alpine-base AS bootable-alpine-rootfs
@@ -110,14 +104,14 @@ RUN if [ "$UCODE" != "none" ]; then apk add --no-cache "${UCODE}-ucode"; fi
110104# hadolint ignore=DL3006
111105FROM imager AS test
112106ARG FORMAT=efi
113- RUN --mount=from=test-rootfs,target=/system build-image --format "$FORMAT"
107+ RUN --mount=from=test-rootfs,target=/system /bin/imager --format "$FORMAT"
114108
115109# =========================================================
116110# Generate a qemu image running our custom OS image
117111FROM alpine-base AS emulator
118112RUN apk add --no-cache bash qemu-system-x86_64 ovmf
119113COPY emulator.sh /entrypoint
120- ENTRYPOINT ["/entrypoint" ]
121114COPY --from=test /out /images
122115ARG FORMAT
123116ENV FORMAT="$FORMAT"
117+ ENTRYPOINT ["/entrypoint" ]
0 commit comments