2023-02-01 21:34:07 +00:00
|
|
|
VERSION 0.6
|
|
|
|
# Note the base image needs to have dracut.
|
|
|
|
# TODO: This needs to come from pre-built kernels in c3os repos, immucore included.
|
|
|
|
# Framework images should use our initrd
|
2023-02-03 16:57:56 +00:00
|
|
|
ARG FLAVOR=core-opensuse-leap
|
|
|
|
ARG BASE_IMAGE=quay.io/kairos/$FLAVOR
|
|
|
|
ARG OSBUILDER_IMAGE=quay.io/kairos/osbuilder-tools
|
|
|
|
ARG ISO_NAME=$FLAVOR-immucore
|
2023-02-01 21:34:07 +00:00
|
|
|
|
2023-02-02 14:12:33 +00:00
|
|
|
ARG GO_VERSION=1.18
|
2023-02-03 16:57:56 +00:00
|
|
|
ARG GOLINT_VERSION=v1.47.3
|
|
|
|
|
|
|
|
version:
|
|
|
|
FROM alpine
|
|
|
|
RUN apk add git
|
|
|
|
COPY . ./
|
|
|
|
RUN --no-cache echo $(git describe --always --tags --dirty) > VERSION
|
|
|
|
ARG VERSION=$(cat VERSION)
|
|
|
|
SAVE ARTIFACT VERSION VERSION
|
|
|
|
|
|
|
|
golang-image:
|
|
|
|
ARG GO_VERSION
|
|
|
|
FROM golang:$GO_VERSION
|
|
|
|
WORKDIR /build
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
RUN go mod download
|
2023-02-02 14:12:33 +00:00
|
|
|
|
|
|
|
go-deps:
|
|
|
|
ARG GO_VERSION
|
|
|
|
FROM golang:$GO_VERSION
|
|
|
|
WORKDIR /build
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
RUN go mod download
|
|
|
|
RUN apt-get update
|
|
|
|
SAVE ARTIFACT go.mod AS LOCAL go.mod
|
|
|
|
SAVE ARTIFACT go.sum AS LOCAL go.sum
|
|
|
|
|
|
|
|
test:
|
2023-02-03 16:57:56 +00:00
|
|
|
FROM +golang-image
|
2023-02-02 14:12:33 +00:00
|
|
|
WORKDIR /build
|
|
|
|
RUN go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo
|
|
|
|
COPY . .
|
|
|
|
RUN ginkgo run --race --fail-fast --slow-spec-threshold 30s --covermode=atomic --coverprofile=coverage.out -p -r ./...
|
|
|
|
SAVE ARTIFACT coverage.out AS LOCAL coverage.out
|
|
|
|
|
|
|
|
lint:
|
|
|
|
ARG GOLINT_VERSION
|
2023-02-03 16:57:56 +00:00
|
|
|
FROM golangci/golangci-lint:$GOLINT_VERSION
|
2023-02-02 14:12:33 +00:00
|
|
|
WORKDIR /build
|
|
|
|
COPY . .
|
|
|
|
RUN golangci-lint run
|
|
|
|
|
2023-02-01 21:34:07 +00:00
|
|
|
build-immucore:
|
2023-02-03 16:57:56 +00:00
|
|
|
FROM +golang-image
|
2023-02-01 21:34:07 +00:00
|
|
|
WORKDIR /work
|
2023-02-06 10:29:28 +00:00
|
|
|
COPY go.mod go.sum /work
|
|
|
|
COPY main.go /work
|
|
|
|
COPY --dir internal /work
|
|
|
|
COPY --dir pkg /work
|
2023-02-06 21:06:31 +00:00
|
|
|
COPY +version/VERSION ./
|
|
|
|
ARG VERSION=$(cat VERSION)
|
2023-02-15 21:30:08 +00:00
|
|
|
ARG LDFLAGS="-s -w -X github.com/kairos-io/immucore/internal/version.version=$VERSION"
|
2023-02-06 21:06:31 +00:00
|
|
|
RUN echo ${LDFLAGS}
|
|
|
|
RUN CGO_ENABLED=0 go build -o immucore -ldflags "${LDFLAGS}"
|
2023-02-16 14:30:54 +00:00
|
|
|
SAVE ARTIFACT /work/immucore immucore AS LOCAL build/immucore-$VERSION
|
|
|
|
|
|
|
|
dracut-artifacts:
|
|
|
|
FROM $BASE_IMAGE
|
|
|
|
WORKDIR /build
|
|
|
|
COPY --dir dracut/28immucore .
|
|
|
|
COPY dracut/02-kairos-setup-initramfs.conf .
|
|
|
|
COPY dracut/10-immucore.conf .
|
|
|
|
COPY dracut/50-kairos-initrd.conf .
|
|
|
|
SAVE ARTIFACT 28immucore 28immucore
|
|
|
|
SAVE ARTIFACT 02-kairos-setup-initramfs.conf 02-kairos-setup-initramfs.conf
|
|
|
|
SAVE ARTIFACT 10-immucore.conf 10-immucore.conf
|
|
|
|
SAVE ARTIFACT 50-kairos-initrd.conf 50-kairos-initrd.conf
|
2023-02-01 21:34:07 +00:00
|
|
|
|
|
|
|
build-dracut:
|
|
|
|
FROM $BASE_IMAGE
|
2023-02-03 16:57:56 +00:00
|
|
|
COPY +version/VERSION ./
|
|
|
|
ARG VERSION=$(cat VERSION)
|
2023-02-06 10:29:28 +00:00
|
|
|
ARG REMOVE_COS_MODULE
|
2023-02-01 21:34:07 +00:00
|
|
|
COPY +build-immucore/immucore /usr/bin/immucore
|
2023-02-06 10:29:28 +00:00
|
|
|
COPY --dir dracut/28immucore /usr/lib/dracut/modules.d/
|
2023-02-13 13:34:51 +00:00
|
|
|
COPY dracut/*.conf /etc/dracut.conf.d/
|
|
|
|
RUN ls -ltra /etc/dracut.conf.d/
|
|
|
|
# (START) Remove cos-immutable-rootfs module
|
2023-02-09 07:56:26 +00:00
|
|
|
RUN rm -Rf /usr/lib/dracut/modules.d/30cos-immutable-rootfs/
|
|
|
|
RUN rm /etc/dracut.conf.d/02-cos-immutable-rootfs.conf
|
2023-02-13 13:34:51 +00:00
|
|
|
RUN rm /etc/dracut.conf.d/02-cos-setup-initramfs.conf
|
|
|
|
RUN rm /etc/dracut.conf.d/50-cos-initrd.conf
|
|
|
|
# (END) Remove cos-immutable-rootfs module
|
2023-02-01 21:34:07 +00:00
|
|
|
RUN kernel=$(ls /lib/modules | head -n1) && \
|
2023-02-09 14:16:53 +00:00
|
|
|
dracut -f "/boot/initrd-${kernel}" "${kernel}" && \
|
2023-02-01 21:34:07 +00:00
|
|
|
ln -sf "initrd-${kernel}" /boot/initrd
|
|
|
|
ARG INITRD=$(readlink -f /boot/initrd)
|
2023-02-03 17:14:15 +00:00
|
|
|
SAVE ARTIFACT $INITRD Initrd AS LOCAL build/initrd-$VERSION
|
2023-02-01 21:34:07 +00:00
|
|
|
|
2023-02-06 10:29:28 +00:00
|
|
|
elemental:
|
|
|
|
FROM $OSBUILDER_IMAGE
|
|
|
|
SAVE ARTIFACT --keep-own /usr/bin/elemental elemental
|
|
|
|
|
2023-02-01 21:34:07 +00:00
|
|
|
image:
|
|
|
|
FROM $BASE_IMAGE
|
2023-02-03 17:14:15 +00:00
|
|
|
COPY +version/VERSION ./
|
|
|
|
ARG VERSION=$(cat VERSION)
|
2023-02-01 21:34:07 +00:00
|
|
|
ARG INITRD=$(readlink -f /boot/initrd)
|
2023-02-03 17:14:15 +00:00
|
|
|
COPY +build-dracut/Initrd $INITRD
|
2023-02-01 21:34:07 +00:00
|
|
|
# For initrd use
|
|
|
|
COPY +build-immucore/immucore /usr/bin/immucore
|
2023-02-06 10:29:28 +00:00
|
|
|
COPY +elemental/elemental /usr/bin/elemental
|
2023-02-01 21:34:07 +00:00
|
|
|
RUN ln -s /usr/lib/systemd/systemd /init
|
2023-02-03 17:14:15 +00:00
|
|
|
SAVE IMAGE $FLAVOR-immucore:$VERSION
|
2023-02-01 21:34:07 +00:00
|
|
|
|
2023-02-04 08:06:23 +00:00
|
|
|
image-rootfs:
|
|
|
|
FROM +image
|
|
|
|
SAVE ARTIFACT --keep-own /. rootfs
|
|
|
|
|
|
|
|
grub-files:
|
|
|
|
FROM alpine
|
|
|
|
RUN apk add wget
|
|
|
|
RUN wget https://raw.githubusercontent.com/c3os-io/c3os/master/overlay/files-iso/boot/grub2/grub.cfg -O grub.cfg
|
|
|
|
SAVE ARTIFACT --keep-own grub.cfg grub.cfg
|
|
|
|
|
2023-02-03 16:57:56 +00:00
|
|
|
iso:
|
|
|
|
FROM $OSBUILDER_IMAGE
|
|
|
|
ARG ISO_NAME
|
|
|
|
COPY +version/VERSION ./
|
|
|
|
ARG VERSION=$(cat VERSION)
|
2023-02-01 21:34:07 +00:00
|
|
|
WORKDIR /build
|
2023-02-04 08:06:23 +00:00
|
|
|
COPY --keep-own +grub-files/grub.cfg /build/files-iso/boot/grub2/grub.cfg
|
|
|
|
COPY --keep-own +image-rootfs/rootfs /build/rootfs
|
|
|
|
RUN /entrypoint.sh --name $ISO_NAME --debug build-iso --squash-no-compression --date=false --local --overlay-iso /build/files-iso --output /build/ dir:/build/rootfs
|
2023-02-03 16:57:56 +00:00
|
|
|
SAVE ARTIFACT /build/$ISO_NAME.iso iso AS LOCAL build/$ISO_NAME-$VERSION.iso
|
|
|
|
SAVE ARTIFACT /build/$ISO_NAME.iso.sha256 sha256 AS LOCAL build/$ISO_NAME-$VERSION.iso.sha256
|