Skip to content

Instantly share code, notes, and snippets.

@lzap
Last active June 12, 2024 14:36
Show Gist options
  • Save lzap/4845b2a68ad70180d3f81cb628d58c7e to your computer and use it in GitHub Desktop.
Save lzap/4845b2a68ad70180d3f81cb628d58c7e to your computer and use it in GitHub Desktop.
Fedora netbootc files POC
FROM quay.io/fedora/fedora-minimal:40 as builder
ARG name=Fedora
ARG version=40
ARG arch=aa64
RUN mkdir /b
WORKDIR /b
# Artifacts from kickstart repository.
RUN curl -RLO https://dl.fedoraproject.org/pub/fedora/linux/releases/${version}/Everything/$(uname -m)/os/.treeinfo
RUN curl -RLO https://dl.fedoraproject.org/pub/fedora/linux/releases/${version}/Everything/$(uname -m)/os/images/pxeboot/vmlinuz
RUN curl -RLO https://dl.fedoraproject.org/pub/fedora/linux/releases/${version}/Everything/$(uname -m)/os/images/pxeboot/initrd.img
RUN curl -RLO https://dl.fedoraproject.org/pub/fedora/linux/releases/${version}/Everything/$(uname -m)/os/images/install.img
# Artifacts from RPM repository.
RUN microdnf -y install shim-${arch} grub2-efi-${arch}
RUN cp -p /boot/efi/EFI/fedora/{shim,grub${arch}}.efi .
# Creation of a digest file and a version file.
RUN export LATEST=$(ls -t1|head -n1);\
mv .treeinfo VERSION ;\
echo -e "\n[packages]" >> VERSION ;\
rpm -q shim-${arch} grub2-efi-${arch} >> VERSION ;\
sha256sum * | tee SHA256SUM ;\
touch -r $LATEST VERSION SHA256SUM
FROM scratch
ARG name=Fedora
ARG version=40
ARG arch=aa64
LABEL org.pulpproject.netboot.version=1 \
org.pulpproject.netboot.os.name="${name}" \
org.pulpproject.netboot.os.version="${version}"
# The first layer MUST be the digest file and optional additional data.
COPY --from=builder --chmod=444 /b/SHA256SUM /b/VERSION /
# Each payloud SHOULD be in a separate layer.
COPY --from=builder --chmod=444 /b/vmlinuz /b/initrd.img /
COPY --from=builder --chmod=444 /b/install.img /
COPY --from=builder --chmod=444 /b/shim.efi /
COPY --from=builder --chmod=444 /b/grub${arch}.efi /
# Entrypoints: regular, alternate and legacy boot.
LABEL org.pulpproject.netboot.boot=shim.efi \
org.pulpproject.netboot.boota=grub${arch}.efi
FROM quay.io/fedora/fedora-minimal:40 as builder
ARG name=Fedora
ARG version=40
ARG arch=x64
RUN mkdir /b
WORKDIR /b
# Artifacts from kickstart repository.
RUN curl -RLO https://dl.fedoraproject.org/pub/fedora/linux/releases/${version}/Everything/$(uname -m)/os/.treeinfo
RUN curl -RLO https://dl.fedoraproject.org/pub/fedora/linux/releases/${version}/Everything/$(uname -m)/os/images/pxeboot/vmlinuz
RUN curl -RLO https://dl.fedoraproject.org/pub/fedora/linux/releases/${version}/Everything/$(uname -m)/os/images/pxeboot/initrd.img
RUN curl -RLO https://dl.fedoraproject.org/pub/fedora/linux/releases/${version}/Everything/$(uname -m)/os/images/install.img
# Artifacts from RPM repository.
RUN microdnf -y install shim-${arch} grub2-efi-${arch} syslinux-tftpboot
RUN cp -p /tftpboot/pxelinux.0 . && cp -p /boot/efi/EFI/fedora/{shim,grub${arch}}.efi .
# Creation of a digest file and a version file.
RUN export LATEST=$(ls -t1|head -n1);\
mv .treeinfo VERSION ;\
echo -e "\n[packages]" >> VERSION ;\
rpm -q shim-${arch} grub2-efi-${arch} syslinux-tftpboot >> VERSION ;\
sha256sum * | tee SHA256SUM ;\
touch -r $LATEST VERSION SHA256SUM
FROM scratch
ARG name=Fedora
ARG version=40
ARG arch=x64
LABEL org.pulpproject.netboot.version=1 \
org.pulpproject.netboot.os.name="${name}" \
org.pulpproject.netboot.os.version="${version}"
# The first layer MUST be the digest file and optional additional data.
COPY --from=builder --chmod=444 /b/SHA256SUM /b/VERSION /
# Each payloud SHOULD be in a separate layer.
COPY --from=builder --chmod=444 /b/vmlinuz /b/initrd.img /
COPY --from=builder --chmod=444 /b/install.img /
COPY --from=builder --chmod=444 /b/pxelinux.0 /
COPY --from=builder --chmod=444 /b/shim.efi /
COPY --from=builder --chmod=444 /b/grub${arch}.efi /
# Entrypoints: regular, alternate and legacy boot.
LABEL org.pulpproject.netboot.boot=shim.efi \
org.pulpproject.netboot.boota=grub${arch}.efi \
org.pulpproject.netboot.bootl=pxelinux.0
@lzap
Copy link
Author

lzap commented Jun 12, 2024

$ skopeo inspect docker://quay.io/lzapletal/fedora-bootfiles@sha256:85f22b4747db52f56d8855f12e4f8355bdda5b31ce748e0a3fa4f27ba9103dd0
{
    "Name": "quay.io/lzapletal/fedora-bootfiles",
    "Digest": "sha256:85f22b4747db52f56d8855f12e4f8355bdda5b31ce748e0a3fa4f27ba9103dd0",
    "RepoTags": [
        "latest"
    ],
    "Created": "2024-06-12T13:56:01.998165123Z",
    "DockerVersion": "",
    "Labels": {
        "io.buildah.version": "1.35.3",
        "org.pulpproject.netboot.boot": "shim.efi",
        "org.pulpproject.netboot.boota": "grubaa64.efi",
        "org.pulpproject.netboot.os.name": "Fedora",
        "org.pulpproject.netboot.os.version": "40",
        "org.pulpproject.netboot.version": "1"
    },
    "Architecture": "arm64",
    "Os": "linux",
    "Layers": [
        "sha256:b2139002159d23cfe086c154858c76cfc32796139fcafdfc3303c0cee25afa56",
        "sha256:19b905ef2a436903aea9bb9e1991035d8d161155e963b1dbe0c25e7ee14d24fa",
        "sha256:259c53c88f62f066dbe98ae1458711392bb1d54bc654ab419810d84d88517c3a",
        "sha256:d7870fb4e438b824eab2b4e78a5e055fa57b0853ae35e8584755f1d7c5b23619",
        "sha256:b9aee0f1c99f9c82f369cb9f04919f4d94e1d519325016e4009ea2326c59eea8"
    ],
    "LayersData": [
        {
            "MIMEType": "application/vnd.oci.image.layer.v1.tar+gzip",
            "Digest": "sha256:b2139002159d23cfe086c154858c76cfc32796139fcafdfc3303c0cee25afa56",
            "Size": 1006,
            "Annotations": null
        },
        {
            "MIMEType": "application/vnd.oci.image.layer.v1.tar+gzip",
            "Digest": "sha256:19b905ef2a436903aea9bb9e1991035d8d161155e963b1dbe0c25e7ee14d24fa",
            "Size": 157380099,
            "Annotations": null
        },
        {
            "MIMEType": "application/vnd.oci.image.layer.v1.tar+gzip",
            "Digest": "sha256:259c53c88f62f066dbe98ae1458711392bb1d54bc654ab419810d84d88517c3a",
            "Size": 662651461,
            "Annotations": null
        },
        {
            "MIMEType": "application/vnd.oci.image.layer.v1.tar+gzip",
            "Digest": "sha256:d7870fb4e438b824eab2b4e78a5e055fa57b0853ae35e8584755f1d7c5b23619",
            "Size": 396364,
            "Annotations": null
        },
        {
            "MIMEType": "application/vnd.oci.image.layer.v1.tar+gzip",
            "Digest": "sha256:b9aee0f1c99f9c82f369cb9f04919f4d94e1d519325016e4009ea2326c59eea8",
            "Size": 1929771,
            "Annotations": null
        }
    ],
    "Env": [
        "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    ]
}
$ skopeo inspect --config docker://quay.io/lzapletal/fedora-bootfiles@sha256:85f22b4747db52f56d8855f12e4f8355bdda5b31ce748e0a3fa4f27ba9103dd0
{
    "created": "2024-06-12T13:56:01.998165123Z",
    "architecture": "arm64",
    "os": "linux",
    "config": {
        "Env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
        ],
        "Labels": {
            "io.buildah.version": "1.35.3",
            "org.pulpproject.netboot.boot": "shim.efi",
            "org.pulpproject.netboot.boota": "grubaa64.efi",
            "org.pulpproject.netboot.os.name": "Fedora",
            "org.pulpproject.netboot.os.version": "40",
            "org.pulpproject.netboot.version": "1"
        }
    },
    "rootfs": {
        "type": "layers",
        "diff_ids": [
            "sha256:eefd53b4b85d965b79ec3be3f7edb2be25fc4b8751875626da6554f8ab72cc2a",
            "sha256:ebca462afdc78e0c4bb8ee70206a2bacf568aadbb50ca68bc9047ebf1d5b3047",
            "sha256:f6d5501f675c642cbec24c9a077e55cb14d11867a49184343f6ba42a218d79f1",
            "sha256:5be558d018ca882e2545dd8afe44a2c0695d7a08d980c5c4c5b5d3c78e69a125",
            "sha256:88ff71939613543cbb7512306b5f279de1131038384892933a41565463fe3d30"
        ]
    },
    "history": [
        {
            "created": "2024-06-12T13:43:39.52589917Z",
            "created_by": "/bin/sh -c #(nop) ARG name",
            "empty_layer": true
        },
        {
            "created": "2024-06-12T13:43:39.562255383Z",
            "created_by": "/bin/sh -c #(nop) ARG name version",
            "comment": "FROM 9dd75eb8f2d0",
            "empty_layer": true
        },
        {
            "created": "2024-06-12T13:43:39.597527842Z",
            "created_by": "/bin/sh -c #(nop) ARG arch name version",
            "comment": "FROM effc69a647ec",
            "empty_layer": true
        },
        {
            "created": "2024-06-12T13:43:39.633658345Z",
            "created_by": "/bin/sh -c #(nop) LABEL org.pulpproject.netboot.version=1 \torg.pulpproject.netboot.os.name=\"${name}\" \torg.pulpproject.netboot.os.version=\"${version}\"",
            "comment": "FROM 3a0338b369dd",
            "empty_layer": true
        },
        {
            "created": "2024-06-12T13:55:57.432074704Z",
            "created_by": "/bin/sh -c #(nop) COPY multi:2559e5c689fe837de3c362fe283383f76a9eee7aab11159d43cc5c6a8f312cef in / ",
            "comment": "FROM 7fbeeca2b25c"
        },
        {
            "created": "2024-06-12T13:55:57.977958168Z",
            "created_by": "/bin/sh -c #(nop) COPY multi:fccc2371ff98677e3decc2c0a3f3fb24ac7380deb004f1073c03ae7f82b6149e in / ",
            "comment": "FROM d775d3018b4e"
        },
        {
            "created": "2024-06-12T13:55:59.874830533Z",
            "created_by": "/bin/sh -c #(nop) COPY file:191c75cdeaf716764163af1b65cbb21b38c4a4b9a3a6a5cdb5ca1a5a1c57b4ad in / ",
            "comment": "FROM a17bad55b543"
        },
        {
            "created": "2024-06-12T13:56:01.710600514Z",
            "created_by": "/bin/sh -c #(nop) COPY file:a8b873f696ec18bc95dff952c201cde6bea1ade39ee54e772135e6a9850c2847 in / ",
            "comment": "FROM e245e26ca9a4"
        },
        {
            "created": "2024-06-12T13:56:01.896389647Z",
            "created_by": "/bin/sh -c #(nop) COPY file:5ac9fbbacac4864f514bcd761d05e97e7f583fc65c1b9740aaacf67b5b6c76d8 in / ",
            "comment": "FROM 7bad078cbd26"
        },
        {
            "created": "2024-06-12T13:56:01.998283191Z",
            "created_by": "/bin/sh -c #(nop) LABEL org.pulpproject.netboot.boot=shim.efi \torg.pulpproject.netboot.boota=grub${arch}.efi",
            "comment": "FROM ebef12b3b7be",
            "empty_layer": true
        }
    ]
}

@lzap
Copy link
Author

lzap commented Jun 12, 2024

Need to be done:

  • Digital signature (cosign?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment