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
|
2023-02-03 17:57:56 +01: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 22:34:07 +01:00
|
|
|
|
2023-02-02 15:12:33 +01:00
|
|
|
ARG GO_VERSION=1.18
|
2023-02-03 17:57:56 +01:00
|
|
|
ARG GOLINT_VERSION=v1.47.3
|
|
|
|
|
|
|
|
version:
|
|
|
|
FROM alpine
|
|
|
|
RUN apk add git
|
|
|
|
COPY . ./
|
2023-02-16 15:43:33 +01:00
|
|
|
RUN --no-cache echo $(git describe --tags | sed 's/\(.*\)-.*/\1/') > VERSION
|
|
|
|
RUN --no-cache echo $(git describe --always --dirty) > COMMIT
|
2023-02-03 17:57:56 +01:00
|
|
|
ARG VERSION=$(cat VERSION)
|
2023-02-16 15:43:33 +01:00
|
|
|
ARG COMMIT=$(cat COMMMIT)
|
|
|
|
SAVE ARTIFACT COMMIT COMMIT
|
2023-02-03 17:57:56 +01:00
|
|
|
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:
|
2023-02-03 17:57:56 +01:00
|
|
|
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
|
2023-02-03 17:57:56 +01:00
|
|
|
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:
|
2023-02-03 17:57:56 +01:00
|
|
|
FROM +golang-image
|
2023-02-01 22:34:07 +01:00
|
|
|
WORKDIR /work
|
2023-02-06 11:29:28 +01:00
|
|
|
COPY go.mod go.sum /work
|
|
|
|
COPY main.go /work
|
|
|
|
COPY --dir internal /work
|
|
|
|
COPY --dir pkg /work
|
2023-02-06 22:06:31 +01:00
|
|
|
COPY +version/VERSION ./
|
2023-02-16 15:43:33 +01:00
|
|
|
COPY +version/COMMIT ./
|
2023-02-06 22:06:31 +01:00
|
|
|
ARG VERSION=$(cat VERSION)
|
2023-02-16 15:43:33 +01:00
|
|
|
ARG COMMIT=$(cat COMMIT)
|
|
|
|
ARG LDFLAGS="-s -w -X github.com/kairos-io/immucore/internal/version.version=$VERSION -X github.com/kairos-io/immucore/internal/version.gitCommit=$COMMIT"
|
2023-02-06 22:06:31 +01:00
|
|
|
RUN echo ${LDFLAGS}
|
|
|
|
RUN CGO_ENABLED=0 go build -o immucore -ldflags "${LDFLAGS}"
|
2023-02-16 15:30:54 +01: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
|
2023-03-02 16:46:25 +01:00
|
|
|
SAVE ARTIFACT 50-kairos-initrd.conf 50-kairos-initrd.conf
|