Skip to content

Commit

Permalink
Remove the last instances of +version and the target itself
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitris Karakasilis <[email protected]>
  • Loading branch information
jimmykarily committed Dec 19, 2023
1 parent 320856e commit 23bcaa6
Showing 1 changed file with 24 additions and 108 deletions.
132 changes: 24 additions & 108 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -144,28 +144,12 @@ git-version:
SAVE ARTIFACT GIT_VERSION GIT_VERSION

# TODO:
# - Remove all invocations of this "+version" target and then delete it.
# [✓] Remove all invocations of this "+version" target and then delete it.
# - Remove all uses of naming.sh (everywhere in this repo) and then delete the file.
# - Check if the /VERSION files we produce is needed anymore, otherwise stop producing it.
# The single point of truth for what an artifact should be saved as, is the artifact itself.
# We write the artifact name in the /etc/os-release and that's were we should read it when we
# want to save an artifact.
version:
ARG K3S_VERSION
COPY +git-version/GIT_VERSION GIT_VERSION
ARG _GIT_VERSION=$(cat ./GIT_VERSION)

# Remove luet rebuild numbers like we do here:
# https://github.com/kairos-io/packages/blob/2fbc098d0499a0c34c587057ff8a9f00c2b7f575/packages/k8s/k3s/build.yaml#L11-L12
IF [ "$K3S_VERSION" != "" ]
ARG _FIXED_VERSION=$(echo $K3S_VERSION | sed 's/+[[:digit:]]*//')
ARG _K3S_VERSION="-k3sv${_FIXED_VERSION}+k3s1"
END

RUN --no-cache echo ${_GIT_VERSION}${_K3S_VERSION} > VERSION

ARG VERSION=$(cat VERSION)
SAVE ARTIFACT VERSION VERSION

hadolint:
ARG HADOLINT_VERSION
Expand Down Expand Up @@ -541,44 +525,16 @@ netboot:
SAVE ARTIFACT /build/$ISO_NAME-initrd initrd AS LOCAL build/$ISO_NAME-initrd
SAVE ARTIFACT /build/$ISO_NAME.ipxe ipxe AS LOCAL build/$ISO_NAME.ipxe

artifact-name:
ARG TARGETARCH
ARG --required FAMILY
ARG --required FLAVOR
ARG --required FLAVOR_RELEASE
ARG --required VARIANT
ARG --required MODEL
ARG --required BASE_IMAGE
ARG --required NAMING_FUNC
ARG --required NAMING_EXT
ARG --required KAIROS_VERSION
FROM ubuntu

COPY ./images/naming.sh /usr/bin/local/naming.sh
RUN echo $(/usr/bin/local/naming.sh ${NAMING_FUNC})${NAMING_EXT} > /ARTIFACT_NAME
SAVE ARTIFACT /ARTIFACT_NAME ARTIFACT_NAME

arm-image:
ARG OSBUILDER_IMAGE
ARG COMPRESS_IMG=true
ARG IMG_COMPRESSION=xz
FROM $OSBUILDER_IMAGE

COPY +version/VERSION ./
ARG KAIROS_VERSION=$(cat VERSION)
RUN echo "version ${KAIROS_VERSION}"
FROM +base-image
ARG IMAGE_NAME=$(source /etc/os-release; echo '$KAIROS_ARTIFACT').img

ARG TARGETARCH
ARG --required FAMILY
ARG --required FLAVOR
ARG --required FLAVOR_RELEASE
ARG --required VARIANT
ARG --required MODEL
ARG --required BASE_IMAGE
FROM $OSBUILDER_IMAGE

COPY --platform=linux/arm64 (+artifact-name/ARTIFACT_NAME --KAIROS_VERSION=${KAIROS_VERSION} --NAMING_FUNC=bootable_artifact_name --NAMING_EXT=".img") /ARTIFACT_NAME
ARG IMAGE_NAME=$(cat /ARTIFACT_NAME)
RUN rm /ARTIFACT_NAME
WORKDIR /build
# These sizes are in MB
ENV SIZE="15200"
Expand Down Expand Up @@ -617,25 +573,11 @@ arm-image:
prepare-arm-image:
ARG OSBUILDER_IMAGE
ARG COMPRESS_IMG=true
FROM $OSBUILDER_IMAGE

COPY +version/VERSION ./
RUN echo "version ${VERSION}"
ARG KAIROS_VERSION=$(cat VERSION)

ARG TARGETARCH
ARG --required FAMILY
ARG --required FLAVOR
ARG --required FLAVOR_RELEASE
ARG --required VARIANT
ARG --required BASE_IMAGE
ARG --required MODEL

COPY --platform=linux/arm64 (+artifact-name/ARTIFACT_NAME --KAIROS_VERSION=${KAIROS_VERSION} --NAMING_FUNC=bootable_artifact_name --NAMING_EXT=".img") /ARTIFACT_NAME
ARG IMAGE_NAME=$(cat /ARTIFACT_NAME)
FROM $OSBUILDER_IMAGE
WORKDIR /build
# These sizes are in MB

# These sizes are in MB
ENV SIZE="15200"

IF [[ "$MODEL" = "nvidia-jetson-agx-orin" ]]
Expand Down Expand Up @@ -668,6 +610,17 @@ prepare-arm-image:

ipxe-iso:
ARG TARGETARCH

FROM +base-image

ARG ISO_NAME=$(source /etc/os-release; echo '$KAIROS_ARTIFACT')

# Variables used here:
# https://github.com/kairos-io/osbuilder/blob/66e9e7a9403a413e310f462136b70d715605ab09/tools-image/ipxe.tmpl#L5
COPY +git-version/GIT_VERSION GIT_VERSION
ARG VERSION=$(cat ./GIT_VERSION)
ARG RELEASE_URL=https://github.com/kairos-io/kairos/releases/download

FROM ubuntu
ARG ipxe_script
RUN apt update
Expand All @@ -676,27 +629,9 @@ ipxe-iso:
# jq docker
WORKDIR /build

COPY +version/VERSION ./
ARG KAIROS_VERSION=$(cat VERSION)
ARG TARGETARCH

# args for base-image target
ARG --required FAMILY
ARG --required FLAVOR
ARG --required FLAVOR_RELEASE
ARG --required BASE_IMAGE
ARG --required MODEL
ARG --required VARIANT

COPY ./images/naming.sh .
ARG ISO_NAME=$(./naming.sh bootable_artifact_name)

# Used here: https://github.com/kairos-io/osbuilder/blob/66e9e7a9403a413e310f462136b70d715605ab09/tools-image/ipxe.tmpl#L5
ARG RELEASE_URL

RUN git clone https://github.com/ipxe/ipxe
IF [ "$ipxe_script" = "" ]
COPY (+netboot/ipxe --VERSION=$KAIROS_VERSION --RELEASE_URL=$RELEASE_URL) /build/ipxe/script.ipxe
COPY (+netboot/ipxe --VERSION=$VERSION --RELEASE_URL=$RELEASE_URL) /build/ipxe/script.ipxe
ELSE
COPY $ipxe_script /build/ipxe/script.ipxe
END
Expand Down Expand Up @@ -753,19 +688,11 @@ trivy-scan:

# Use base-image so it can read original os-release file
FROM +base-image

ARG ISO_NAME=$(source /etc/os-release; echo '$KAIROS_ARTIFACT')

COPY +trivy/trivy /trivy
COPY +trivy/contrib /contrib
COPY +version/VERSION ./
ARG KAIROS_VERSION=$(cat VERSION)
ARG TARGETARCH
ARG --required FAMILY # The dockerfile to use
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
COPY ./images/naming.sh .
ARG ISO_NAME=$(./naming.sh bootable_artifact_name)

WORKDIR /build
RUN /trivy filesystem --skip-dirs /tmp --timeout 30m --format sarif -o report.sarif --no-progress /
Expand Down Expand Up @@ -835,24 +762,13 @@ run-qemu-datasource-tests:


run-qemu-netboot-test:
FROM +base-image
ARG ISO_NAME=$(source /etc/os-release; echo '$KAIROS_ARTIFACT')

FROM +go-deps-test
COPY . /test
WORKDIR /test

COPY +version/VERSION ./
ARG KAIROS_VERSION=$(cat VERSION)

ARG TARGETARCH # Earthly built-in (not passed)
ARG --required FAMILY # The dockerfile to use
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

COPY ./images/naming.sh .
ARG ISO_NAME=$(./naming.sh bootable_artifact_name)

# This is the IP at which qemu vm can see the host
ARG IP="10.0.2.2"

Expand Down

0 comments on commit 23bcaa6

Please sign in to comment.