Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Introduce new artifact naming convention #466

Merged
merged 4 commits into from
Jul 27, 2023
Merged
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
41 changes: 28 additions & 13 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ VERSION 0.6
IMPORT github.com/kairos-io/kairos

FROM alpine
ARG VARIANT=kairos # core, lite, framework
ARG OS_ID=kairos
ARG VARIANT=standard
ARG FLAVOR=opensuse-leap

## Versioning
Expand All @@ -17,9 +18,8 @@ RUN echo "version ${VERSION}"
ARG K3S_VERSION_TAG=$(echo $K3S_VERSION | sed s/+/-/)
ARG TAG=${VERSION}-k3s${K3S_VERSION_TAG}
ARG BASE_REPO=quay.io/kairos
ARG IMAGE=${BASE_REPO}/${VARIANT}-${FLAVOR}:$TAG
ARG IMAGE=${BASE_REPO}/${OS_ID}-${FLAVOR}:$TAG
ARG BASE_IMAGE=quay.io/kairos/core-${FLAVOR}:${CORE_VERSION}
ARG ISO_NAME=${VARIANT}-${FLAVOR}-${VERSION}-k3s${K3S_VERSION}
# renovate: datasource=docker depName=quay.io/kairos/osbuilder-tools versioning=semver-coerced
ARG OSBUILDER_VERSION=v0.7.8
ARG OSBUILDER_IMAGE=quay.io/kairos/osbuilder-tools:$OSBUILDER_VERSION
Expand All @@ -29,7 +29,8 @@ ARG LUET_VERSION=0.33.0
# renovate: datasource=docker depName=golang
ARG GO_VERSION=1.20

ARG OS_ID=kairos
ARG MODEL=generic
ARG TARGETARCH
ARG CGO_ENABLED=0

RELEASEVERSION:
Expand Down Expand Up @@ -64,7 +65,7 @@ all-arm:
ARG SECURITY_SCANS=true
BUILD --platform=linux/arm64 +docker
IF [ "$SECURITY_SCANS" = "true" ]
BUILD --platform=linux/arm64 +image-sbom
BUILD --platform=linux/arm64 +image-sbom --MODEL=rpi64
END
BUILD +arm-image --MODEL=rpi64
DO +RELEASEVERSION
Expand Down Expand Up @@ -139,7 +140,7 @@ docker:

ARG OS_ID
ARG OS_NAME=${OS_ID}-${FLAVOR}
ARG OS_REPO=quay.io/kairos/${VARIANT}-${FLAVOR}
ARG OS_REPO=quay.io/kairos/${OS_ID}-${FLAVOR}
ARG OS_LABEL=latest

DO kairos+OSRELEASE --BUG_REPORT_URL="https://github.com/kairos-io/kairos/issues/new/choose" --HOME_URL="https://github.com/kairos-io/provider-kairos" --OS_ID=${OS_ID} --OS_LABEL=${OS_LABEL} --OS_NAME=${OS_NAME} --OS_REPO=${OS_REPO} --OS_VERSION=${OS_VERSION}-k3s${K3S_VERSION} --GITHUB_REPO="kairos-io/provider-kairos" --VARIANT=${VARIANT} --FLAVOR=${FLAVOR}
Expand Down Expand Up @@ -201,9 +202,14 @@ kairos:

iso:
ARG OSBUILDER_IMAGE
ARG ISO_NAME=${OS_ID}
ARG IMG=docker:$IMAGE
ARG overlay=overlay/files-iso
IF [ "$TARGETARCH" = "arm64" ]
ARG DISTRO=$(echo $FLAVOR | sed 's/-arm-.*//')
ARG ISO_NAME=${OS_ID}-${VARIANT}-${DISTRO}-${TARGETARCH}-${MODEL}-${VERSION}
ELSE
ARG ISO_NAME=${OS_ID}-${VARIANT}-${FLAVOR}-${TARGETARCH}-${MODEL}-${VERSION}
END
FROM $OSBUILDER_IMAGE
RUN zypper in -y jq docker
WORKDIR /build
Expand Down Expand Up @@ -239,7 +245,10 @@ arm-image:
ARG COMPRESS_IMG=true
FROM $OSBUILDER_IMAGE
ARG MODEL=rpi64
ARG IMAGE_NAME=${VARIANT}-${FLAVOR}-${VERSION}-k3s${K3S_VERSION}.img
ARG DISTRO=$(echo $FLAVOR | sed 's/-arm-.*//')
# TARGETARCH is not used here because OSBUILDER_IMAGE is not available in arm64. When this changes, then the caller
# of this target can simply pass the desired TARGETARCH.
ARG IMAGE_NAME=${OS_ID}-${VARIANT}-${DISTRO}-arm64-${MODEL}-${VERSION}-k3s${K3S_VERSION}.img
WORKDIR /build

ENV SIZE="15200"
Expand Down Expand Up @@ -282,10 +291,17 @@ image-sbom:
ARG TAG
ARG FLAVOR
ARG VARIANT
ARG MODEL
IF [ "$TARGETARCH" = "arm64" ]
ARG DISTRO=$(echo $FLAVOR | sed 's/-arm-.*//')
ARG ISO_NAME=${OS_ID}-${VARIANT}-${DISTRO}-${TARGETARCH}-${MODEL}-${VERSION}
ELSE
ARG ISO_NAME=${OS_ID}-${VARIANT}-${FLAVOR}-${TARGETARCH}-${MODEL}-${VERSION}
END
COPY +syft/syft /usr/bin/syft
RUN syft / -o json=sbom.syft.json -o spdx-json=sbom.spdx.json
SAVE ARTIFACT /build/sbom.syft.json sbom.syft.json AS LOCAL build/${VARIANT}-${FLAVOR}-${TAG}-sbom.syft.json
SAVE ARTIFACT /build/sbom.spdx.json sbom.spdx.json AS LOCAL build/${VARIANT}-${FLAVOR}-${TAG}-sbom.spdx.json
SAVE ARTIFACT /build/sbom.syft.json sbom.syft.json AS LOCAL build/${ISO_NAME}-sbom.syft.json
SAVE ARTIFACT /build/sbom.spdx.json sbom.spdx.json AS LOCAL build/${ISO_NAME}-sbom.spdx.json

ipxe-iso:
FROM ubuntu
Expand All @@ -295,16 +311,15 @@ ipxe-iso:
mtools syslinux isolinux gcc-arm-none-eabi git make gcc liblzma-dev mkisofs xorriso
# jq docker
WORKDIR /build
ARG ISO_NAME=${OS_ID}
RUN git clone https://github.com/ipxe/ipxe
IF [ "$ipxe_script" = "" ]
COPY +netboot/ipxe /build/ipxe/script.ipxe
ELSE
COPY $ipxe_script /build/ipxe/script.ipxe
END
RUN cd ipxe/src && make EMBED=/build/ipxe/script.ipxe
SAVE ARTIFACT /build/ipxe/src/bin/ipxe.iso iso AS LOCAL build/${ISO_NAME}-ipxe.iso.ipxe
SAVE ARTIFACT /build/ipxe/src/bin/ipxe.usb usb AS LOCAL build/${ISO_NAME}-ipxe-usb.img.ipxe
SAVE ARTIFACT /build/ipxe/src/bin/ipxe.iso iso AS LOCAL build/${ISO_NAME}-ipxe.iso
SAVE ARTIFACT /build/ipxe/src/bin/ipxe.usb usb AS LOCAL build/${ISO_NAME}-ipxe-usb.img

## Security targets
trivy:
Expand Down