Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use built-in rpm-ostree rechunking for rechunking #275

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions .github/workflows/reusable-build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,24 +121,15 @@ jobs:

sudo $just build "${IMAGE_NAME}" "${DEFAULT_TAG}" "$ENABLE_DX" "$ENABLE_HWE" "$ENABLE_GDX"

- name: Run Rechunker
if: github.event_name != 'pull_request'
id: rechunk
uses: hhd-dev/rechunk@341e1298e827bc60cfe19d71539ca42d08c89cfe # v1.1.3
with:
rechunk: "ghcr.io/hhd-dev/rechunk:v1.1.3"
ref: "localhost/${{ env.IMAGE_NAME }}:${{ env.DEFAULT_TAG }}"
prev-ref: "${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DEFAULT_TAG }}"
skip_compression: true
version: ${{ env.CENTOS_VERSION }}

- name: Load Image
if: github.event_name != 'pull_request'
- name: Rechunk and Tag image
# if: github.event_name != 'pull_request'
id: load
run: |
IMAGE=$(sudo podman pull ${{ steps.rechunk.outputs.ref }})
sudo rm -rf ${{ steps.rechunk.outputs.location }}
sudo podman image tag $IMAGE ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DEFAULT_TAG }}
set -x
just=$(which just)

sudo $just rechunk "${IMAGE_NAME}" "${DEFAULT_TAG}"
sudo podman image tag "$IMAGE_NAME:${DEFAULT_TAG}" "${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DEFAULT_TAG }}"

IMAGE=${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DEFAULT_TAG }}
IMAGE_DIGEST=$(sudo podman image inspect --format '{{.Digest}}' $IMAGE)
Expand Down
22 changes: 22 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,28 @@ build $target_image=image_name $tag=default_tag $dx="0" $hwe="0" $gdx="0":
--tag "${target_image}:${tag}" \
.

rechunk $target_image=image_name $tag=default_tag:
#!/usr/bin/env bash
set -xeuo pipefail

OUTDIR=$(mktemp -d -p /var/tmp)
ROOTFSDIR=$(mktemp -d -p /var/tmp)
cleanup() {
sudo rm -rf $OUTDIR
sudo rm -rf $ROOTFSDIR
}
trap cleanup EXIT

podman export $(podman create "${target_image}:${tag}") | tar -xf - -C $ROOTFSDIR

# The built image itself has a new enough rpm-ostree version to be able to do this.
podman run --rm -it -v "$OUTDIR:/out:Z" -v "$ROOTFSDIR:/rootfs:Z" "${target_image}:${tag}" \
sh -c "mkdir /var/tmp && /usr/bin/rpm-ostree experimental compose build-chunked-oci --bootc --format-version=1 --rootfs=/rootfs --output /out/out.oci"

podman rmi -f "${target_image}:${tag}"
# Load image into storage and tag it properly
podman load -i $OUTDIR/out.oci | sed "s/Loaded image: //" | xargs -i podman tag '{}' "${target_image}:${tag}"

# Command: _rootful_load_image
# Description: This script checks if the current user is root or running under sudo. If not, it attempts to resolve the image tag using podman inspect.
# If the image is found, it loads it into rootful podman. If the image is not found, it pulls it from the repository.
Expand Down
1 change: 1 addition & 0 deletions build_scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ copy_systemfiles_for() {
shift
printf "::group:: ===%s-file-copying===\n" "$WHAT"
cp -avf "/var/tmp/system_files_overrides/$WHAT/." /
rm -f /.gitkeep
printf "::endgroup::\n"
}

Expand Down