From aaee221cb5fcb4f6da7c4daf15a0a0cd1d277b3f Mon Sep 17 00:00:00 2001 From: Dimitris Karakasilis Date: Thu, 12 Oct 2023 13:18:06 +0300 Subject: [PATCH] WIP Signed-off-by: Mauro Morales --- Earthfile | 53 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/Earthfile b/Earthfile index 717fe6fe7..473ead55b 100644 --- a/Earthfile +++ b/Earthfile @@ -87,7 +87,7 @@ all-arm: BUILD --platform=linux/arm64 +trivy-scan --MODEL=$MODEL BUILD --platform=linux/arm64 +grype-scan --MODEL=$MODEL END - + IF [[ "$FLAVOR" = "ubuntu-20-lts-arm-nvidia-jetson-agx-orin" ]] BUILD +prepare-arm-image --MODEL=$MODEL --FLAVOR=${FLAVOR} ELSE @@ -142,9 +142,16 @@ CONTAINER_IMAGE_VERSION: ARG --required VARIANT ARG --required FLAVOR + # TODO: there is no artifact anymore, use FLAVOR and fix the call to the naming.sh script + ARG --required ARTIFACT + + COPY naming.sh ./ + # quay.io doesn't accept "+" in the repo name ARG _VERSION=$(echo $VERSION | sed 's/+/-/') + RUN echo ${BASE_URL}/${ARTIFACT}:$(./naming.sh $VARIANT $FLAVOR $TARGETARCH $MODEL $_VERSION) > IMAGE + IF [ "$IMAGE" = "" ] # TODO: This IF block should be deleted as soon as our repository names # follow our conventions. @@ -166,6 +173,7 @@ OSRELEASE: COMMAND ARG VARIANT ARG FLAVOR + ARG FLAVOR_RELEASE # TODO: Use this in the template ARG GITHUB_REPO ARG BUG_REPORT_URL ARG BASE_URL @@ -173,7 +181,9 @@ OSRELEASE: ARG OS_NAME ARG OS_VERSION + # TODO: Call container_artifact_name from naming.sh? ARG OS_REPO=${BASE_URL}/${VARIANT}-${FLAVOR} + # TODO: Call common_artifact_name from naming.sh? ARG OS_NAME=kairos-${VARIANT}-${FLAVOR} COPY +version/VERSION ./ @@ -288,13 +298,15 @@ framework: FROM golang:alpine ARG FLAVOR + ARG FLAVOR_RELEASE + WORKDIR /build COPY ./profile-build /build COPY framework-profile.yaml /build COPY +luet/luet /usr/bin/luet - RUN go run main.go ${FLAVOR} framework-profile.yaml /framework + RUN go run main.go ${FLAVOR}-${FLAVOR_RELEASE} framework-profile.yaml /framework RUN mkdir -p /framework/etc/kairos/ RUN luet database --system-target /framework get-all-installed --output /framework/etc/kairos/versions.yaml @@ -321,7 +333,9 @@ framework: build-framework-image: FROM alpine - ARG FLAVOR + + ARG --required FLAVOR + ARG --required FLAVOR_RELEASE COPY +version/VERSION ./ ARG VERSION=$(cat VERSION) @@ -333,16 +347,17 @@ build-framework-image: FROM scratch - COPY (+framework/framework --FLAVOR=$FLAVOR) / + COPY (+framework/framework --FLAVOR=$FLAVOR --FLAVOR_RELEASE=$FLAVOR_RELEASE) / SAVE IMAGE --push $IMAGE_REPOSITORY_ORG/framework:${VERSION}_${FLAVOR} base-image: ARG --required FAMILY # The dockerfile to use - ARG --required FLAVOR # The build strategy E.g. "ubuntu-20" - ARG --required BASE_IMAGE # BASE_IMAGE is the image to apply the strategy (aka FLAVOR) on. E.g. ubuntu:20.04 - ARG --required MODEL + ARG --required FLAVOR # The distribution E.g. "ubuntu" + ARG --required FLAVOR_RELEASE # The distribution release/version E.g. "20.04" ARG --required VARIANT + ARG --required MODEL + ARG --required BASE_IMAGE # BASE_IMAGE is the image to apply the strategy (aka FLAVOR) on. E.g. ubuntu:20.04 ARG TARGETARCH # Earthly built-in (not passed) ARG KAIROS_VERSION @@ -352,15 +367,17 @@ base-image: # if you want to disable the HWE kernel, set HWE to "-non-hwe" ARG HWE + # TODO: Pass the VARIANT here and let Dockerfiles handle it FROM DOCKERFILE \ --build-arg BASE_IMAGE=$BASE_IMAGE \ --build-arg MODEL=$MODEL \ --build-arg FLAVOR=$FLAVOR \ + --build-arg FLAVOR_RELEASE=$FLAVOR_RELEASE \ --build-arg HWE=$HWE \ -f images/Dockerfile.$FAMILY images/ # Includes overlay/files - COPY (+framework/framework --FLAVOR=$FLAVOR) / + COPY (+framework/framework --FLAVOR=$FLAVOR --FLAVOR_RELEASE=$FLAVOR_RELEASE) / # Avoid to accidentally push keys generated by package managers RUN rm -rf /etc/ssh/ssh_host_* @@ -779,7 +796,7 @@ prepare-arm-image: ARG IMAGE_NAME=${FLAVOR}.img WORKDIR /build # These sizes are in MB - + ENV SIZE="15200" IF [[ "$FLAVOR" = "ubuntu-20-lts-arm-nvidia-jetson-agx-orin" ]] @@ -975,7 +992,7 @@ run-qemu-datasource-tests: IF [ ! -e /test/build/datasource.iso ] COPY ( +datasource-iso/iso.iso --CLOUD_CONFIG=$CLOUD_CONFIG) datasource.iso ENV DATASOURCE=/test/datasource.iso - ELSE + ELSE ENV DATASOURCE=/test/build/datasource.iso END ENV CLOUD_INIT=/tests/tests/$CLOUD_CONFIG @@ -1088,7 +1105,7 @@ push-build-artifacts: RUN cd build && tar cvf ../build.tar ./ RUN luet util pack $BUNDLE_IMAGE build.tar image.tar WITH DOCKER - RUN docker load -i image.tar && docker push $BUNDLE_IMAGE + RUN docker load -i image.tar && docker push $BUNDLE_IMAGE END # bundles tests needs to run in sequence: @@ -1106,7 +1123,7 @@ prepare-bundles-tests: ARG VERSION=$(cat VERSION) RUN echo "version ${VERSION}" WITH DOCKER --load $IMG=(+examples-bundle --BUNDLE_IMAGE=$BUNDLE_IMAGE --VERSION=$VERSION) - RUN docker push $BUNDLE_IMAGE + RUN docker push $BUNDLE_IMAGE END BUILD +examples-bundle-config --BUNDLE_IMAGE=$BUNDLE_IMAGE @@ -1125,7 +1142,7 @@ examples-bundle: FROM DOCKERFILE --build-arg VERSION=$VERSION -f examples/bundle/Dockerfile . SAVE IMAGE $BUNDLE_IMAGE -## ./earthly.sh +examples-bundle-config --BUNDLE_IMAGE=ttl.sh/testfoobar:8h +## ./earthly.sh +examples-bundle-config --BUNDLE_IMAGE=ttl.sh/testfoobar:8h ## cat bundles-config.yaml examples-bundle-config: ARG BUNDLE_IMAGE @@ -1151,7 +1168,7 @@ docs: COPY . . WORKDIR ./docs - + RUN npm install postcss-cli RUN npm run prepare @@ -1159,14 +1176,14 @@ docs: SAVE ARTIFACT public /public AS LOCAL docs/public ## ./earthly.sh --push +temp-image --FLAVOR=ubuntu -## all same flags than the `docker` target plus +## all same flags than the `docker` target plus ## - the EXPIRATION time, defaults to 24h ## - the NAME of the image in ttl.sh, defaults to the branch name + short sha ## the push flag is optional -## +## ## you will have access to an image in ttl.sh e.g. ttl.sh/add-earthly-target-to-build-temp-images-339dfc7:24h temp-image: - FROM alpine + FROM alpine RUN apk add git COPY . ./ @@ -1202,7 +1219,7 @@ generate-schema: ARG RELEASE_VERSION=$(cat VERSION) RUN mkdir "docs/static/$RELEASE_VERSION" ARG SCHEMA_FILE="docs/static/$RELEASE_VERSION/cloud-config.json" - RUN kairos-agent print-schema > $SCHEMA_FILE + RUN kairos-agent print-schema > $SCHEMA_FILE SAVE ARTIFACT ./docs/static/* AS LOCAL docs/static/ last-commit-packages: