From 35ab77c309b7dd1af349e385638d6607b3d3c804 Mon Sep 17 00:00:00 2001 From: Kyler Date: Sat, 2 Nov 2024 18:58:22 -0600 Subject: [PATCH] Dynamic Build based on talos version --- Dockerfile | 4 ++-- entrypoint.sh | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7fbf358..bb1fe7e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -FROM alpine:edge +FROM alpine:3.20 -RUN apk add --no-cache zfs bash curl +RUN apk add --no-cache crane bash curl libuuid libblkid COPY entrypoint.sh /entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh index b495915..fa32bdd 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,13 +2,19 @@ set -e -# Set default values : "${PUSHOVER_NOTIFICATION:=false}" : "${ACTION:=scrub}" exit_bool=false -# Validate environment variables +if [ -z "$TALOS_VERSION" ]; then + echo "Error: TALOS_VERSION environment variable not set." + exit_bool=true +elif ! ZFS_IMAGE=$(crane export "ghcr.io/siderolabs/extensions:${TALOS_VERSION}" | tar x -O image-digests | grep zfs | awk '{print $1}'); then + echo "Error: Could not find a compatible ZFS extension for Talos $TALOS_VERSION." + exit_bool=true +fi + if [ "$PUSHOVER_NOTIFICATION" = true ]; then if [ -z "$PUSHOVER_USER_KEY" ]; then echo "Error: \"PUSHOVER_USER_KEY\" is missing while \"PUSHOVER_NOTIFICATION\" is \"true\"." @@ -31,6 +37,13 @@ if [ "$exit_bool" = true ]; then exit 1 fi +echo "Installing ZFS from $ZFS_IMAGE..." +if ! crane export "$ZFS_IMAGE" | tar --strip-components=1 -x -C / ;then + echo "Error: Failed to extract ZFS extension" + exit 1 +fi +echo + send_pushover_notification() { if [ "$PUSHOVER_NOTIFICATION" = true ]; then local message="$1"