2024-06-05 16:45:35 +03:00
|
|
|
## 1. BUILD ARGS
|
|
|
|
# These allow changing the produced image by passing different build args to adjust
|
|
|
|
# the source from which your image is built.
|
|
|
|
# Build args can be provided on the commandline when building locally with:
|
|
|
|
# podman build -f Containerfile --build-arg FEDORA_VERSION=40 -t local-image
|
|
|
|
|
|
|
|
# SOURCE_IMAGE arg can be anything from ublue upstream which matches your desired version:
|
|
|
|
# See list here: https://github.com/orgs/ublue-os/packages?repo_name=main
|
|
|
|
# - "silverblue"
|
|
|
|
# - "kinoite"
|
|
|
|
# - "sericea"
|
|
|
|
# - "onyx"
|
|
|
|
# - "lazurite"
|
|
|
|
# - "vauxite"
|
|
|
|
# - "base"
|
|
|
|
#
|
|
|
|
# "aurora", "bazzite", "bluefin" or "ucore" may also be used but have different suffixes.
|
2024-06-05 23:29:48 +03:00
|
|
|
ARG SOURCE_IMAGE="silverblue"
|
2024-06-05 16:45:35 +03:00
|
|
|
|
|
|
|
## SOURCE_SUFFIX arg should include a hyphen and the appropriate suffix name
|
|
|
|
# These examples all work for silverblue/kinoite/sericea/onyx/lazurite/vauxite/base
|
|
|
|
# - "-main"
|
|
|
|
# - "-nvidia"
|
|
|
|
# - "-asus"
|
|
|
|
# - "-asus-nvidia"
|
|
|
|
# - "-surface"
|
|
|
|
# - "-surface-nvidia"
|
|
|
|
#
|
|
|
|
# aurora, bazzite and bluefin each have unique suffixes. Please check the specific image.
|
|
|
|
# ucore has the following possible suffixes
|
|
|
|
# - stable
|
|
|
|
# - stable-nvidia
|
|
|
|
# - stable-zfs
|
|
|
|
# - stable-nvidia-zfs
|
|
|
|
# - (and the above with testing rather than stable)
|
2024-06-05 21:44:22 +03:00
|
|
|
ARG SOURCE_SUFFIX="-main"
|
2024-06-05 16:45:35 +03:00
|
|
|
|
|
|
|
## SOURCE_TAG arg must be a version built for the specific image: eg, 39, 40, gts, latest
|
2024-06-05 17:43:12 +03:00
|
|
|
ARG SOURCE_TAG="40"
|
2024-06-05 16:45:35 +03:00
|
|
|
|
2024-06-05 23:29:48 +03:00
|
|
|
ARG FEDORA_VERSION=40
|
2024-06-05 16:45:35 +03:00
|
|
|
|
2024-06-05 23:29:48 +03:00
|
|
|
### 2. Build ZFS module
|
|
|
|
## Adated from https://github.com/coreos/layering-examples/blob/main/build-zfs-module/Containerfile
|
|
|
|
FROM ghcr.io/ublue-os/${SOURCE_IMAGE}${SOURCE_SUFFIX}:${SOURCE_TAG} as kernel-query
|
|
|
|
RUN rpm -qa kernel --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}' > /kernel-version.txt
|
|
|
|
|
|
|
|
# Using https://openzfs.github.io/openzfs-docs/Developer%20Resources/Custom%20Packages.html
|
|
|
|
FROM registry.fedoraproject.org/fedora:${FEDORA_VERSION} as builder
|
|
|
|
COPY --from=kernel-query /kernel-version.txt /kernel-version.txt
|
|
|
|
WORKDIR /etc/yum.repos.d
|
|
|
|
RUN curl -L -O https://src.fedoraproject.org/rpms/fedora-repos/raw/f${FEDORA_VERSION}/f/fedora-updates-archive.repo && \
|
|
|
|
sed -i 's/enabled=AUTO_VALUE/enabled=true/' fedora-updates-archive.repo
|
|
|
|
RUN dnf install -y jq dkms gcc make autoconf automake libtool rpm-build libtirpc-devel libblkid-devel \
|
|
|
|
libuuid-devel libudev-devel openssl-devel zlib-devel libaio-devel libattr-devel elfutils-libelf-devel \
|
|
|
|
kernel-$(cat /kernel-version.txt) kernel-modules-$(cat /kernel-version.txt) kernel-devel-$(cat /kernel-version.txt) \
|
2024-06-06 00:00:19 +03:00
|
|
|
python3 python3-devel python3-setuptools python3-cffi libffi-devel git ncompress libcurl-devel
|
2024-06-05 23:29:48 +03:00
|
|
|
WORKDIR /
|
|
|
|
# Uses project_id from: https://release-monitoring.org/project/11706/
|
|
|
|
RUN curl "https://release-monitoring.org/api/v2/versions/?project_id=11706" | jq --raw-output '.stable_versions[0]' >> /zfs_version.txt
|
|
|
|
RUN curl -L -O https://github.com/openzfs/zfs/releases/download/zfs-$(cat /zfs_version.txt)/zfs-$(cat /zfs_version.txt).tar.gz && \
|
|
|
|
tar xzf zfs-$(cat /zfs_version.txt).tar.gz && mv zfs-$(cat /zfs_version.txt) zfs
|
|
|
|
WORKDIR /zfs
|
|
|
|
RUN ./configure -with-linux=/usr/src/kernels/$(cat /kernel-version.txt)/ -with-linux-obj=/usr/src/kernels/$(cat /kernel-version.txt)/ \
|
|
|
|
&& make -j1 rpm-utils rpm-kmod
|
|
|
|
|
|
|
|
|
|
|
|
### 3. SOURCE IMAGE
|
2024-06-05 16:45:35 +03:00
|
|
|
## this is a standard Containerfile FROM using the build ARGs above to select the right upstream image
|
|
|
|
FROM ghcr.io/ublue-os/${SOURCE_IMAGE}${SOURCE_SUFFIX}:${SOURCE_TAG}
|
|
|
|
|
2024-06-05 23:29:48 +03:00
|
|
|
### 4 Add ZFS RPMS and matching kernel RPMs
|
|
|
|
#COPY --from=ghcr.io/0ranki/sb-zfs-kernel /rpms/ /tmp/rpms
|
|
|
|
COPY --from=builder /zfs/*.rpm /zfs/
|
2024-06-05 16:45:35 +03:00
|
|
|
|
2024-06-05 23:29:48 +03:00
|
|
|
### 5. MODIFICATIONS
|
2024-06-05 16:45:35 +03:00
|
|
|
## make modifications desired in your image and install packages by modifying the build.sh script
|
|
|
|
## the following RUN directive does all the things required to run "build.sh" as recommended.
|
|
|
|
|
|
|
|
COPY build.sh /tmp/build.sh
|
|
|
|
|
|
|
|
RUN mkdir -p /var/lib/alternatives && \
|
|
|
|
/tmp/build.sh && \
|
|
|
|
ostree container commit
|
|
|
|
## NOTES:
|
|
|
|
# - /var/lib/alternatives is required to prevent failure with some RPM installs
|
|
|
|
# - All RUN commands must end with ostree container commit
|
|
|
|
# see: https://coreos.github.io/rpm-ostree/container/#using-ostree-container-commit
|