From 95d9c132c2f8908d7b5e4fcf7362219286502bb4 Mon Sep 17 00:00:00 2001 From: joshua-stone Date: Thu, 9 Mar 2023 09:57:46 -0500 Subject: [PATCH] feat: download RPM metadata in build stage to lower bandwidth usage in final stage (#65) --- README.md | 17 ++++++++++++++--- build.Containerfile | 3 +++ install.Containerfile | 18 +++++++----------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 7454e8d..e1b69d0 100644 --- a/README.md +++ b/README.md @@ -131,8 +131,11 @@ A container build can be invoked by simply running: ``` $ podman build \ - --file Containerfile \ + --file build.Containerfile \ --tag build-test:latest +$ podman build \ + --file install.Containerfile \ + --tag install-test:latest ``` Or to specify the version of Fedora and/or Nvidia driver: @@ -140,10 +143,18 @@ Or to specify the version of Fedora and/or Nvidia driver: ``` $ podman build \ --build-arg IMAGE_NAME=silverblue \ - --build-arg SOURCE_IMAGE=silverblue \ --build-arg FEDORA_MAJOR_VERSION=37 \ --build-arg NVIDIA_MAJOR_VERSION=525 \ - --file Containerfile \ + --file build.Containerfile \ + --tag build-test:37-525 + +$ podman build \ + --build-arg IMAGE_NAME=silverblue \ + --build-arg FEDORA_MAJOR_VERSION=37 \ + --build-arg NVIDIA_MAJOR_VERSION=525 \ + --build-arg AKMODS_CACHE=build-test \ + --build-arg AKMODS_VERSION=37 \ + --file install.Containerfile \ --tag build-test:latest ``` diff --git a/build.Containerfile b/build.Containerfile index 9b1a722..7fef5af 100644 --- a/build.Containerfile +++ b/build.Containerfile @@ -17,6 +17,9 @@ ADD ublue-os-nvidia-addons.spec /tmp/ublue-os-nvidia-addons/ublue-os-nvidia-addo ADD https://nvidia.github.io/nvidia-docker/rhel9.0/nvidia-docker.repo \ /tmp/ublue-os-nvidia-addons/rpmbuild/SOURCES/nvidia-container-runtime.repo +ADD https://nvidia.github.io/nvidia-docker/rhel9.0/nvidia-docker.repo \ + /etc/yum.repos.d/nvidia-container-runtime.repo + ADD files/etc/nvidia-container-runtime/config-rootless.toml \ /tmp/ublue-os-nvidia-addons/rpmbuild/SOURCES/config-rootless.toml ADD https://raw.githubusercontent.com/NVIDIA/dgx-selinux/master/bin/RHEL9/nvidia-container.pp \ diff --git a/install.Containerfile b/install.Containerfile index 415e6eb..c8c743e 100644 --- a/install.Containerfile +++ b/install.Containerfile @@ -1,19 +1,15 @@ -ARG IMAGE_NAME="${IMAGE_NAME:-silverblue}" -ARG BASE_IMAGE="ghcr.io/ublue-os/${IMAGE_NAME}-main" -ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-37}" -ARG NVIDIA_MAJOR_VERSION="${NVIDIA_MAJOR_VERSION:-525}" -ARG AKMODS_VERSION="${AKMODS_VERSION:-37}" +ARG IMAGE_NAME=silverblue +ARG BASE_IMAGE=ghcr.io/ublue-os/${IMAGE_NAME}-main +ARG FEDORA_MAJOR_VERSION=37 FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} -ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION}" -ARG NVIDIA_MAJOR_VERSION="${NVIDIA_MAJOR_VERSION}" -ARG AKMODS_VERSION="${AKMODS_VERSION}" - -ARG BUILDER_IMAGE="ghcr.io/ublue-os/akmods-nvidia:${AKMODS_VERSION}-${NVIDIA_MAJOR_VERSION}" ARG IMAGE_NAME="${IMAGE_NAME}" +ARG AKMODS_CACHE="ghcr.io/ublue-os/akmods-nvidia" +ARG AKMODS_VERSION="37" +ARG NVIDIA_MAJOR_VERSION="525" -COPY --from=${BUILDER_IMAGE} / . +COPY --from=${AKMODS_CACHE}:${AKMODS_VERSION}-${NVIDIA_MAJOR_VERSION} / . COPY install.sh /tmp/install.sh COPY post-install.sh /tmp/post-install.sh