Skip to content

Commit

Permalink
chore(ci): speedup builds with cache mount (ublue-os#1525)
Browse files Browse the repository at this point in the history
  • Loading branch information
m2Giles authored Jul 23, 2024
1 parent 78bd85c commit 07bae0f
Show file tree
Hide file tree
Showing 33 changed files with 73 additions and 70 deletions.
43 changes: 14 additions & 29 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ARG NVIDIA_TYPE="${NVIDIA_TYPE:-}"
ARG KERNEL="${KERNEL:-6.9.7-200.fc40.x86_64}"
ARG UBLUE_IMAGE_TAG="${UBLUE_IMAGE_TAG:-latest}"

# FROM's for copying
# FROM's for Mounting
ARG KMOD_SOURCE_COMMON="ghcr.io/ublue-os/akmods:${AKMODS_FLAVOR}-${FEDORA_MAJOR_VERSION}"
ARG ZFS_CACHE="ghcr.io/ublue-os/akmods-zfs:coreos-stable-${FEDORA_MAJOR_VERSION}"
ARG NVIDIA_CACHE="ghcr.io/ublue-os/akmods-nvidia:${AKMODS_FLAVOR}-${FEDORA_MAJOR_VERSION}"
Expand All @@ -19,6 +19,9 @@ FROM ${ZFS_CACHE} AS zfs_cache
FROM ${NVIDIA_CACHE} AS nvidia_cache
FROM ${KERNEL_CACHE} AS kernel_cache

FROM scratch AS ctx
COPY / /

## bluefin image section
FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} AS base

Expand All @@ -32,30 +35,19 @@ ARG NVIDIA_TYPE="${NVIDIA_TYPE:-}"
ARG KERNEL="${KERNEL:-6.9.7-200.fc40.x86_64}"
ARG UBLUE_IMAGE_TAG="${UBLUE_IMAGE_TAG:-latest}"

# COPY Build Files
COPY build_files/base build_files/shared /tmp/build/
COPY system_files/shared system_files/${BASE_IMAGE_NAME} /
COPY just /tmp/just
COPY packages.json /tmp/packages.json

# Copy ublue-update.toml to tmp first, to avoid being overwritten.
COPY /system_files/shared/usr/etc/ublue-update/ublue-update.toml /tmp/ublue-update.toml
# COPY ublue kmods, add needed negativo17 repo and then immediately disable due to incompatibility with RPMFusion
# COPY --from=akmods /rpms /tmp/akmods-rpms
# COPY --from=nvidia_cache /rpms /tmp/akmods-rpms
# COPY --from=kernel_cache /tmp/rpms /tmp/kernel-rpms

# Build, cleanup, commit.
RUN --mount=type=bind,from=akmods,source=/rpms,target=/tmp/akmods \
RUN --mount=type=cache,dst=/var/cache/rpm-ostree \
--mount=type=bind,from=ctx,source=/,target=/ctx \
--mount=type=bind,from=akmods,source=/rpms,target=/tmp/akmods \
--mount=type=bind,from=nvidia_cache,source=/rpms,target=/tmp/akmods-rpms \
--mount=type=bind,from=kernel_cache,source=/tmp/rpms,target=/tmp/kernel-rpms \
--mount=type=bind,from=zfs_cache,source=/rpms,target=/tmp/akmods-zfs \
rpm-ostree cliwrap install-to-root / && \
mkdir -p /var/lib/alternatives && \
bash -c ". /tmp/build/build-base.sh" && \
/ctx/build_files/build-base.sh && \
mv /var/lib/alternatives /staged-alternatives && \
rm -rf /tmp/* || true && \
rm -rf /var/* || true && \
/ctx/build_files/clean-stage.sh && \
ostree container commit && \
mkdir -p /var/lib && mv /staged-alternatives /var/lib/alternatives && \
mkdir -p /var/tmp && \
Expand All @@ -74,22 +66,15 @@ ARG NVIDIA_TYPE="${NVIDIA_TYPE:-}"
ARG KERNEL="${KERNEL:-6.9.7-200.fc40.x86_64}"
ARG UBLUE_IMAGE_TAG="${UBLUE_IMAGE_TAG:-latest}"

# dx specific files come from the dx directory in this repo
COPY build_files/dx build_files/shared /tmp/build/
COPY system_files/dx /
COPY packages.json /tmp/packages.json

# Copy akmods from ublue
# COPY --from=akmods /rpms /tmp/akmods-rpms

# Build, Clean-up, Commit
RUN --mount=type=bind,from=akmods,source=/rpms,target=/tmp/akmods \
RUN --mount=type=cache,dst=/var/cache/rpm-ostree \
--mount=type=bind,from=ctx,source=/,target=/ctx \
--mount=type=bind,from=akmods,source=/rpms,target=/tmp/akmods \
mkdir -p /var/lib/alternatives && \
bash -c ". /tmp/build/build-dx.sh" && \
/ctx/build_files/build-dx.sh && \
fc-cache --system-only --really-force --verbose && \
mv /var/lib/alternatives /staged-alternatives && \
rm -rf /tmp/* || true && \
rm -rf /var/* || true && \
/ctx/build_files/clean-stage.sh \
ostree container commit && \
mkdir -p /var/lib && mv /staged-alternatives /var/lib/alternatives && \
mkdir -p /var/tmp && \
Expand Down
File renamed without changes.
23 changes: 0 additions & 23 deletions build_files/base/build-base.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions build_files/build-base.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/bash
# shellcheck disable=SC1091

set -ouex pipefail

cp -r /ctx/just /tmp/just
cp /ctx/packages.json /tmp/packages.json
cp /ctx/system_files/shared/usr/etc/ublue-update/ublue-update.toml /tmp/ublue-update.toml

rsync -rvK /ctx/system_files/shared/ /
rsync -rvK /ctx/system_files/"${BASE_IMAGE_NAME}"/ /

/ctx/build_files/firmware.sh
/ctx/build_files/cache_kernel.sh
/ctx/build_files/copr-repos.sh
/ctx/build_files/install-akmods.sh
/ctx/build_files/packages.sh
/ctx/build_files/nvidia.sh
/ctx/build_files/image-info.sh
/ctx/build_files/fetch-install.sh
/ctx/build_files/brew.sh
/ctx/build_files/fetch-quadlets.sh
/ctx/build_files/font-install.sh
/ctx/build_files/systemd.sh
/ctx/build_files/bluefin-changes.sh
/ctx/build_files/aurora-changes.sh
/ctx/build_files/branding.sh
/ctx/build_files/initramfs.sh
/ctx/build_files/bootc.sh
/ctx/build_files/cleanup.sh
21 changes: 21 additions & 0 deletions build_files/build-dx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/bash
# shellcheck disable=SC1091

set -ouex pipefail

# Apply IP Forwarding before installing Docker to prevent messing with LXC networking
sysctl -p

cp /ctx/packages.json /tmp/packages.json
rsync -rvK /ctx/system_files/dx/ /

/ctx/build_files/copr-repos-dx.sh
/ctx/build_files/install-akmods-dx.sh
/ctx/build_files/packages-dx.sh
/ctx/build_files/image-info.sh
/ctx/build_files/fetch-install-dx.sh
/ctx/build_files/fonts-dx.sh
/ctx/build_files/workarounds.sh
/ctx/build_files/systemd-dx.sh
/ctx/build_files/branding-dx.sh
/ctx/build_files/cleanup-dx.sh
File renamed without changes.
8 changes: 8 additions & 0 deletions build_files/clean-stage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/bash

set -eoux pipefail
shopt -s extglob

rm -rf /tmp/* || true
rm -rf /var/!(cache)
rm -rf /var/cache/!(rpm-ostree)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 0 additions & 18 deletions build_files/dx/build-dx.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 07bae0f

Please sign in to comment.