Skip to content

Commit

Permalink
🤖 Add raw image target to earthly (#1675)
Browse files Browse the repository at this point in the history
  • Loading branch information
Itxaka authored Aug 3, 2023
1 parent 00efe75 commit 7b7863d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions .earthlyignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build/*iso
# this is created by the strat_vm_qemu.sh script
disk.img
*.raw
19 changes: 19 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,25 @@ ipxe-iso:
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

# Uses the same config as in the docs: https://kairos.io/docs/advanced/build/#build-a-cloud-image
# This is the default for cloud images which only come with the recovery partition and the workflow
# is to boot from them and do a reset to get the latest system installed
# This allows us to build a raw disk image locally to test the cloud workflow easily
raw-image:
ARG TARGETARCH
COPY +version/VERSION ./
RUN echo "version ${VERSION}"
ARG VERSION=$(cat VERSION)
ARG IMG_NAME=${OS_ID}-${VARIANT}-${FLAVOR}-${TARGETARCH}-${MODEL}-${VERSION}.raw
ARG OSBUILDER_IMAGE
FROM $OSBUILDER_IMAGE
WORKDIR /build
COPY tests/assets/raw_image.yaml /raw_image.yaml
COPY --keep-own +image-rootfs/rootfs /rootfs
RUN /raw-images.sh /rootfs /$IMG_NAME /raw_image.yaml
RUN truncate -s "+$((32000*1024*1024))" /$IMG_NAME
SAVE ARTIFACT /$IMG_NAME $IMG_NAME AS LOCAL build/$IMG_NAME

# Generic targets
# usage e.g. ./earthly.sh +datasource-iso --CLOUD_CONFIG=tests/assets/qrcode.yaml
datasource-iso:
Expand Down
33 changes: 33 additions & 0 deletions tests/assets/raw_image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#cloud-config
# same config as in the docs: https://kairos.io/docs/advanced/build/#build-a-cloud-image
# This is the default for cloud images which only come with the recovery partition and the workflow
# is to boot from them and do a reset to get the latest system installed

users:
- name: "kairos"
passwd: "kairos"
name: "Default deployment"
stages:
boot:
- name: "Repart image"
layout:
device:
label: COS_RECOVERY
add_partitions:
- fsLabel: COS_STATE
size: 16240 # At least 16gb
pLabel: state
- name: "Repart image"
layout:
device:
label: COS_RECOVERY
add_partitions:
- fsLabel: COS_PERSISTENT
pLabel: persistent
size: 0 # all space
- if: '[ -f "/run/cos/recovery_mode" ] && [ ! -e /usr/local/.deployed ]'
name: "Deploy kairos"
commands:
- kairos-agent --debug reset --unattended
- touch /usr/local/.deployed
- reboot

0 comments on commit 7b7863d

Please sign in to comment.