Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.bin
43 changes: 16 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,29 @@ RUN --mount=type=bind,target=. \
yamllint -v && yamllint -s -f colored .

# =========================================================
FROM golang:1.26.1-alpine AS init
FROM golang:1.26.1-alpine AS imager-build
SHELL ["/bin/ash", "-euxo", "pipefail", "-c"]
RUN apk add --no-cache binutils
WORKDIR /go/src
COPY imager/go.mod imager/go.sum ./
RUN go mod download
COPY imager .
RUN \
--mount=source=init,target=. \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 go build -o /go/bin/init -v --ldflags '-s -w -extldflags=-static'
go generate -v ./...; \
go test; \
go build -o /go/bin/imager -v --ldflags "-s -w" cmd/main.go

# =========================================================
FROM alpine:3.23.3 AS alpine-base

# =========================================================
FROM alpine-base AS imager
SHELL ["/bin/ash", "-euxo", "pipefail", "-c"]
RUN \
echo "@edge-community https://dl-cdn.alpinelinux.org/alpine/edge/community" >>/etc/apk/repositories && \
apk add --no-cache \
bash \
binutils \
coreutils \
cpio \
dosfstools \
findutils \
mtools \
pigz \
qemu-img \
sfdisk \
xorriso \
zstd \
xz \
systemd-efistub@edge-community
COPY --from=init /go/bin/init /usr/share/claylinux/init
COPY build-image.sh /usr/bin/build-image
# TODO: bundle systemd-efistub into the imager binary
RUN apk add --no-cache systemd-efistub
COPY --from=imager-build /go/bin/imager /usr/bin/imager
WORKDIR /out
ENTRYPOINT ["build-image"]
ENTRYPOINT ["/usr/bin/imager"]

# =========================================================
FROM alpine-base AS bootable-alpine-rootfs
Expand Down Expand Up @@ -109,14 +98,14 @@ if [ "$UCODE" != "none" ]; then apk add --no-cache "${UCODE}-ucode"; fi;
# hadolint ignore=DL3006
FROM imager AS test
ARG FORMAT=efi
RUN --mount=from=test-rootfs,target=/system build-image --format "$FORMAT"
RUN --mount=from=test-rootfs,target=/system imager --format "$FORMAT"

# =========================================================
# Generate a qemu image running our custom OS image
FROM alpine-base AS emulator
RUN apk add --no-cache bash qemu-system-x86_64 ovmf
RUN apk add --no-cache bash qemu-system-x86_64 ovmf binutils
COPY emulator.sh /entrypoint
ENTRYPOINT ["/entrypoint"]
COPY --from=test /out /images
ARG FORMAT
ENV FORMAT="$FORMAT"
ENTRYPOINT ["/entrypoint"]
Loading
Loading