Skip to content

Commit

Permalink
✨ Introduce new artifact naming convention (#466)
Browse files Browse the repository at this point in the history
relates to kairos-io/kairos#1109

`earthly +all`

```
kairos-standard-opensuse-leap-amd64-generic-v2.3.1-dirty-k3s-initrd
kairos-standard-opensuse-leap-amd64-generic-v2.3.1-dirty-k3s.ipxe
kairos-standard-opensuse-leap-amd64-generic-v2.3.1-dirty-k3s-ipxe.iso
kairos-standard-opensuse-leap-amd64-generic-v2.3.1-dirty-k3s-ipxe-usb.img
kairos-standard-opensuse-leap-amd64-generic-v2.3.1-dirty-k3s.iso
kairos-standard-opensuse-leap-amd64-generic-v2.3.1-dirty-k3s.iso.sha256
kairos-standard-opensuse-leap-amd64-generic-v2.3.1-dirty-k3s-kernel
kairos-standard-opensuse-leap-amd64-generic-v2.3.1-dirty-k3s-sbom.spdx.json
kairos-standard-opensuse-leap-amd64-generic-v2.3.1-dirty-k3s-sbom.syft.json
kairos-standard-opensuse-leap-amd64-generic-v2.3.1-dirty-k3s.squashfs
```

`earthly +all-arm-generic --FLAVOR=opensuse-leap-arm-generic`

```
kairos-standard-opensuse-leap-arm64-generic-v2.3.1-1-g6a62b88-dirty.iso
kairos-standard-opensuse-leap-arm64-generic-v2.3.1-1-g6a62b88-dirty.iso.sha256
kairos-standard-opensuse-leap-arm64-generic-v2.3.1-1-g6a62b88-dirty-sbom.spdx.json
kairos-standard-opensuse-leap-arm64-generic-v2.3.1-1-g6a62b88-dirty-sbom.syft.json
```

`earthly -P +all-arm --FLAVOR=opensuse-leap-arm-rpi`

```
kairos-standard-opensuse-leap-arm64-rpi64-v2.3.1-3-g4b23855-dirty-k3s.img.xz
kairos-standard-opensuse-leap-arm64-rpi64-v2.3.1-3-g4b23855-dirty-k3s.img.sha256
kairos-standard-opensuse-leap-arm64-rpi64-v2.3.1-3-g4b23855-dirty-sbom.spdx.json
kairos-standard-opensuse-leap-arm64-rpi64-v2.3.1-3-g4b23855-dirty-sbom.syft.json
```

---------

Signed-off-by: Mauro Morales <[email protected]>
  • Loading branch information
mauromorales authored Jul 27, 2023
1 parent 360f1f1 commit 54532e7
Showing 1 changed file with 28 additions and 13 deletions.
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

0 comments on commit 54532e7

Please sign in to comment.