Files
immucore/Earthfile

101 lines
3.3 KiB
Plaintext
Raw Normal View History

2023-02-01 22:34:07 +01: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
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 22:34:07 +01:00
2023-02-02 15:12:33 +01:00
ARG GO_VERSION=1.18
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 15:12:33 +01: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:
FROM +golang-image
2023-02-02 15:12:33 +01: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
FROM golangci/golangci-lint:$GOLINT_VERSION
2023-02-02 15:12:33 +01:00
WORKDIR /build
COPY . .
RUN golangci-lint run
2023-02-01 22:34:07 +01:00
build-immucore:
FROM +golang-image
COPY +version/VERSION ./
ARG VERSION=$(cat VERSION)
2023-02-01 22:34:07 +01:00
WORKDIR /work
COPY . /work
2023-02-01 22:34:07 +01:00
RUN CGO_ENABLED=0 go build -o immucore -ldflags "-X main.Version=$VERSION"
SAVE ARTIFACT /work/immucore AS LOCAL build/immucore-$VERSION
2023-02-01 22:34:07 +01:00
build-dracut:
FROM $BASE_IMAGE
COPY +version/VERSION ./
ARG VERSION=$(cat VERSION)
2023-02-01 22:34:07 +01:00
COPY . /work
COPY +build-immucore/immucore /usr/bin/immucore
WORKDIR /work
RUN cp -r dracut/28immucore /usr/lib/dracut/modules.d
RUN cp dracut/dracut.conf /etc/dracut.conf.d/10-immucore.conf
RUN kernel=$(ls /lib/modules | head -n1) && \
dracut -f "/boot/initrd-${kernel}" "${kernel}" && \
ln -sf "initrd-${kernel}" /boot/initrd
ARG INITRD=$(readlink -f /boot/initrd)
SAVE ARTIFACT $INITRD Initrd AS LOCAL build/initrd-$VERSION
2023-02-01 22:34:07 +01:00
image:
FROM $BASE_IMAGE
COPY +version/VERSION ./
ARG VERSION=$(cat VERSION)
2023-02-01 22:34:07 +01:00
ARG INITRD=$(readlink -f /boot/initrd)
COPY +build-dracut/Initrd $INITRD
2023-02-01 22:34:07 +01:00
# For initrd use
COPY +build-immucore/immucore /usr/bin/immucore
RUN ln -s /usr/lib/systemd/systemd /init
SAVE IMAGE $FLAVOR-immucore:$VERSION
2023-02-01 22:34:07 +01:00
iso:
FROM $OSBUILDER_IMAGE
ARG ISO_NAME
COPY +version/VERSION ./
ARG VERSION=$(cat VERSION)
2023-02-01 22:34:07 +01:00
WORKDIR /build
RUN zypper in -y jq docker wget
RUN mkdir -p files-iso/boot/grub2
RUN wget https://raw.githubusercontent.com/c3os-io/c3os/master/overlay/files-iso/boot/grub2/grub.cfg -O files-iso/boot/grub2/grub.cfg
WITH DOCKER --allow-privileged --load $FLAVOR-immucore:$VERSION=+image
RUN /entrypoint.sh --name $ISO_NAME --debug build-iso --squash-no-compression --date=false --local --overlay-iso /build/files-iso --output /build/ docker:$FLAVOR-immucore:$VERSION
2023-02-01 22:34:07 +01:00
END
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