From 9ea4c4d05f0dbf1bac73c3d3a9759dd79de80e81 Mon Sep 17 00:00:00 2001 From: Mauro Morales Date: Fri, 17 Nov 2023 08:36:52 +0100 Subject: [PATCH] Move logic for opensuse Signed-off-by: Mauro Morales --- images/Dockerfile.alpine | 1 + images/Dockerfile.opensuse | 80 +++++++++++++++++++++++++++++++++++++- 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/images/Dockerfile.alpine b/images/Dockerfile.alpine index ccf86dbc99..0b0bb9415a 100644 --- a/images/Dockerfile.alpine +++ b/images/Dockerfile.alpine @@ -149,6 +149,7 @@ RUN rc-update add sshd boot && \ RUN ln -s /usr/sbin/grub-install /usr/sbin/grub2-install && \ ln -s /usr/bin/grub-editenv /usr/bin/grub2-editenv +# Originally done in Earthly COPY --from=framework / / RUN rm -rf /etc/ssh/ssh_host_* diff --git a/images/Dockerfile.opensuse b/images/Dockerfile.opensuse index c8279cfef7..9012a5ce16 100644 --- a/images/Dockerfile.opensuse +++ b/images/Dockerfile.opensuse @@ -1,9 +1,17 @@ ############################################################### #### ARGS #### ############################################################### +ARG FLAVOR +ARG FLAVOR_RELEASE ARG MODEL=generic ARG BASE_IMAGE -ARG FLAVOR_RELEASE +ARG VARIANT +ARG VERSION +ARG FRAMEWORK_VERSION=master +# Not to be confused with the concept of MODEL, this is either fips or generic +ARG SECURITY_PROFILE=generic +# TARGETARCH is used to determine the architecture of the image +# it is already set by Docker so it doesn't need to be defined here FROM $BASE_IMAGE AS base @@ -140,6 +148,8 @@ FROM rpicommon AS rpi-tumbleweed FROM rpi-${FLAVOR_RELEASE} AS rpi3 FROM rpi-${FLAVOR_RELEASE} AS rpi4 +FROM quay.io/kairos/framework:${FRAMEWORK_VERSION}_${SECURITY_PROFILE} AS framework + ############################################################### #### Post-Process Common to All #### ############################################################### @@ -149,3 +159,71 @@ FROM ${MODEL} AS all RUN zypper in --force-resolution -y \ kernel-default \ && zypper cc +# Originally done in Earthly +COPY --from=framework / / + +RUN rm -rf /etc/ssh/ssh_host_* + +COPY naming.sh /usr/local/bin/naming.sh + +RUN sed -i -n '/KAIROS_/!p' /etc/os-release + +# need to be defined after FROM for them to be replaced in the RUN bellow +ARG FLAVOR +ARG FLAVOR_RELEASE +ARG VARIANT +ARG OS_ID=kairos +ARG HOME_URL="https://github.com/kairos-io/kairos" +ARG BUG_REPORT_URL="https://github.com/kairos-io/kairos/issues" +ARG GITHUB_REPO="kairos-io/kairos" +# TODO: merge these +ARG VERSION +ARG FAMILY +ARG MODEL +ARG REGISTRY_AND_ORG="quay.io/kairos" +ARG K3S_VERSION +ARG TARGETARCH +ARG OS_NAME=kairos-${VARIANT}-${FLAVOR}-${FLAVOR_RELEASE} +ENV KAIROS_VERSION="${VERSION}${K3S_VERSION:+-k3s$K3S_VERSION}" +ENV OS_VERSION=${KAIROS_VERSION} +ENV OS_LABEL=${KAIROS_VERSION} +RUN OS_LABEL=$(naming.sh container_artifact_label) \ + OS_REPO=$(naming.sh container_artifact_repo) \ + ARTIFACT=$(naming.sh bootable_artifact_name) \ + envsubst >>/etc/os-release /IMAGE + +# TODO no benefit of keaping it? +# RUN rm /usr/local/bin/naming.sh + +RUN rm -rf /etc/machine-id + +# TODO dev kairos-agent? +# TODO dev immucore? +# TODO dev kcrypt? +# TODO latest k3s? + +FROM all AS core + +FROM all AS standard +ARG K3S_VERSION +RUN luet install -y system/provider-kairos +RUN luet install -y $(echo k8s/k3s-systemd@${K3S_VERSION}) utils/edgevpn utils/k9s utils/nerdctl container/kubectl utils/kube-vip +RUN luet database get-all-installed --output /etc/kairos/versions.yaml + +FROM ${VARIANT} AS final + +# TODO what about NOT building initrd for the UKI? +# TODO what about caches? +RUN kernel=$(ls /lib/modules | head -n1) && depmod -a "${kernel}" +# Regenerate initrd if necessary +RUN if [ -f "/usr/bin/dracut" ]; then \ + kernel=$(ls /lib/modules | head -n1) && \ + dracut -f "/boot/initrd-${kernel}" "${kernel}" && \ + ln -sf "initrd-${kernel}" /boot/initrd; \ + fi +# Proper config files with immucore and custom initrd should already be in there installed by framework +RUN if [ -f "/sbin/mkinitfs" ]; then \ + kernel=$(ls /lib/modules | head -n1) && \ + mkinitfs -o /boot/initrd "${kernel}"; \ + fi