-
Notifications
You must be signed in to change notification settings - Fork 109
feat: integrate zstd:chunked and chunkah for content-based layers #139
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| FROM quay.io/toolbx-images/alpine-toolbox:edge AS builder | ||
|
|
||
| # Copy the setup scripts and package list | ||
| COPY scripts/boxkit.sh / | ||
| COPY scripts/distrobox-shims.sh / | ||
| COPY scripts/chunkah-tag.sh / | ||
| COPY packages/boxkit.packages / | ||
|
|
||
| # Run the setup scripts and tag files for chunkah | ||
| RUN chmod +x boxkit.sh distrobox-shims.sh chunkah-tag.sh && \ | ||
| /boxkit.sh && \ | ||
| /chunkah-tag.sh && \ | ||
| rm /boxkit.sh /distrobox-shims.sh /chunkah-tag.sh /boxkit.packages | ||
|
|
||
| # For CI builds with buildah, use chunkah rechunking | ||
| # For local podman builds, use: podman build --target=builder -f Containerfiles/boxkit -t boxkit:local . | ||
|
|
||
| # https://github.com/coreos/chunkah | ||
| FROM quay.io/jlebon/chunkah AS chunkah | ||
|
||
|
|
||
| # Rechunk with content-based layers | ||
| ARG SOURCE_DATE_EPOCH | ||
| ENV SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH:-0} | ||
| RUN --mount=from=builder,src=/,target=/chunkah,ro \ | ||
| --mount=type=bind,target=/run/src,rw \ | ||
| chunkah build \ | ||
| --max-layers 64 \ | ||
| --label=com.github.containers.toolbox=true \ | ||
| --label=usage="This image is meant to be used with the toolbox or distrobox command" \ | ||
| --label=summary="A cloud-native terminal experience" \ | ||
| --label=maintainer=jorge.castro@gmail.com \ | ||
| > /run/src/out.ociarchive | ||
|
|
||
| # Deploy final chunked image | ||
| FROM oci-archive:out.ociarchive | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| FROM quay.io/fedora/fedora-toolbox:latest AS builder | ||
|
|
||
| # Copy the setup scripts and package list | ||
| COPY scripts/fedora-example.sh / | ||
| COPY scripts/distrobox-shims.sh / | ||
| COPY scripts/chunkah-tag.sh / | ||
| COPY packages/fedora-example.packages / | ||
|
|
||
| # Run the setup scripts and tag files for chunkah | ||
| RUN chmod +x fedora-example.sh distrobox-shims.sh chunkah-tag.sh && \ | ||
| /fedora-example.sh && \ | ||
| /chunkah-tag.sh && \ | ||
| rm /fedora-example.sh /distrobox-shims.sh /chunkah-tag.sh /fedora-example.packages | ||
|
|
||
| # For CI builds with buildah, use chunkah rechunking | ||
| # For local podman builds, use: podman build --target=builder -f Containerfiles/fedora-example -t fedora-example:local . | ||
|
|
||
| # https://github.com/coreos/chunkah | ||
| FROM quay.io/jlebon/chunkah AS chunkah | ||
|
||
|
|
||
| # Rechunk with content-based layers | ||
| ARG SOURCE_DATE_EPOCH | ||
| ENV SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH:-0} | ||
| RUN --mount=from=builder,src=/,target=/chunkah,ro \ | ||
| --mount=type=bind,target=/run/src,rw \ | ||
| chunkah build \ | ||
| --max-layers 64 \ | ||
| --label=com.github.containers.toolbox=true \ | ||
| --label=name=fedora-toolbox \ | ||
| --label=usage="This image is meant to be used with the toolbox or distrobox command" \ | ||
| --label=summary="An example ContainerFile to demonstrate multiple image builds." \ | ||
| --label=maintainer=faeizmahrus@outlook.com \ | ||
| > /run/src/out.ociarchive | ||
|
|
||
| # Deploy final chunked image | ||
| FROM oci-archive:out.ociarchive | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #!/usr/bin/env -S just --justfile | ||
|
|
||
| # boxkit - Justfile for local development and testing | ||
| # Container provisioning logic lives in scripts/ | ||
|
|
||
| # Build boxkit image locally (without chunkah - chunkah requires buildah) | ||
| build-boxkit: | ||
| podman build --target=builder -f Containerfiles/boxkit -t boxkit:local . | ||
|
|
||
| # Build fedora-example image locally (without chunkah - chunkah requires buildah) | ||
| build-fedora-example: | ||
| podman build --target=builder -f Containerfiles/fedora-example -t fedora-example:local . | ||
|
|
||
| # Build all images | ||
| build-all: build-boxkit build-fedora-example | ||
|
|
||
| # Run boxkit in distrobox | ||
| run-boxkit: | ||
| @distrobox create -i boxkit:local -n boxkit 2>/dev/null || true | ||
| distrobox enter boxkit | ||
|
|
||
| # Run fedora-example in distrobox | ||
| run-fedora-example: | ||
| @distrobox create -i fedora-example:local -n fedora-example 2>/dev/null || true | ||
| distrobox enter fedora-example | ||
|
|
||
| # Clean built images | ||
| clean: | ||
| podman rmi -f boxkit:local fedora-example:local 2>/dev/null || true | ||
| @echo "✓ Local images cleaned" | ||
|
|
||
| # Clean distrobox containers | ||
| clean-distrobox: | ||
| @distrobox rm -f boxkit fedora-example 2>/dev/null || true | ||
| @echo "✓ Distrobox containers removed" | ||
|
|
||
| # Full cleanup | ||
| clean-all: clean clean-distrobox |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,71 @@ | ||||||||||||||
| #!/bin/sh | ||||||||||||||
| # Tag files with package component names for chunkah content-based layering | ||||||||||||||
| # Supports: apk (Alpine), rpm (Fedora/RHEL), dpkg (Debian/Ubuntu), pacman (Arch) | ||||||||||||||
|
|
||||||||||||||
| set -euo pipefail | ||||||||||||||
|
||||||||||||||
| set -euo pipefail | |
| set -eu | |
| # Enable pipefail if supported by the current /bin/sh implementation | |
| if (set -o pipefail) 2>/dev/null; then | |
| set -o pipefail | |
| fi |
Copilot
AI
Mar 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unquoted command substitution here causes word-splitting/globbing and can break on paths containing whitespace; it can also hit ARG_MAX for packages with many files. Prefer reading the file list line-by-line (and use read -r) rather than expanding the whole list into arguments.
Copilot
AI
Mar 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as above: $(rpm -ql ...) is expanded unquoted into arguments, which is unsafe for whitespace and can exceed ARG_MAX for large packages. Prefer streaming the file list line-by-line (and use read -r).
Copilot
AI
Mar 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as above: $(dpkg -L ...) is expanded unquoted into arguments, which is unsafe for whitespace and can exceed ARG_MAX for packages with many files. Prefer streaming the file list line-by-line (and use read -r).
Copilot
AI
Mar 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as above: $(pacman -Ql ...) output is expanded unquoted into arguments, which is unsafe for whitespace and can exceed ARG_MAX. Prefer streaming the file list line-by-line (and use read -r).
| pacman -Qq | while read pkgname; do | |
| tag_files "$pkgname" $(pacman -Ql "$pkgname" 2>/dev/null | awk '{print $2}') | |
| pacman -Qq | while read -r pkgname; do | |
| pacman -Qlq "$pkgname" 2>/dev/null | while read -r filepath; do | |
| tag_files "$pkgname" "$filepath" | |
| done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
github.event.head_commit.timestampis not present forpull_request,schedule, orworkflow_dispatchevents, so this step will fail (and block PR builds). ComputeSOURCE_DATE_EPOCHfrom the checked-out commit instead (e.g., viagit show -s --format=%ct $GITHUB_SHAor similar), with a safe fallback when the timestamp cannot be determined.