Refactor build workflow for monolithic image
Updated GitHub Actions workflow to build and push a monolithic image, including changes to image tags and steps for handling the GitHub Container Registry.
This commit is contained in:
+22
-23
@@ -80,33 +80,40 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-${{ github.workflow }}-${{ hashFiles('Containerfile') }}-
|
||||
|
||||
- name: Build Image
|
||||
- name: Build Monolithic Image
|
||||
id: build_image
|
||||
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2
|
||||
with:
|
||||
containerfiles: |
|
||||
./Containerfile
|
||||
image: ${{ env.IMAGE_NAME }}
|
||||
tags: ${{ env.DEFAULT_TAG }}
|
||||
tags: monolith
|
||||
labels: ${{ steps.metadata.outputs.labels }}
|
||||
oci: true
|
||||
|
||||
# 1. Wir sichern das Image als gewöhnlichen, flachen Tarball auf die Festplatte
|
||||
- name: Export monolithic image to tarball
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# Wir pushen den Monolithen temporär unkomprimiert hoch, damit rpm-ostree darauf zugreifen kann
|
||||
- name: Push temporary monolith to GHCR
|
||||
run: |
|
||||
set -x
|
||||
podman save -o ./monolith.tar localhost/${{ env.IMAGE_NAME }}:${{ env.DEFAULT_TAG }}
|
||||
podman push localhost/${{ env.IMAGE_NAME }}:monolith ghcr.io/${{ github.repository }}:monolith
|
||||
|
||||
# 2. Rechunking liest den Tarball ein (Absolut standardisiert und fehlerfrei für rpm-ostree)
|
||||
# JETZT GARANTIERT FEHLERFREI: rpm-ostree liest standardisiert direkt aus der Registry
|
||||
- name: Apply native bootc rechunking
|
||||
id: rechunk
|
||||
run: |
|
||||
set -x
|
||||
mkdir -p ./chunkah-out
|
||||
|
||||
# Wir mounten den Tarball direkt in den Container.
|
||||
# --from=archive:... bricht bei rpm-ostree keinerlei interne Validierungen.
|
||||
# Wir reichen die Docker-Credentials des Runners in den Container, damit er an GHCR rankommt
|
||||
sudo podman run --rm --privileged \
|
||||
-v /home/runner/.docker/config.json:/root/.docker/config.json:ro \
|
||||
-v .:/workspace:z \
|
||||
-w /workspace \
|
||||
quay.io/fedora/fedora-bootc:44 \
|
||||
@@ -114,24 +121,13 @@ jobs:
|
||||
--bootc \
|
||||
--format-version=2 \
|
||||
--max-layers 128 \
|
||||
--from=archive:/workspace/monolith.tar \
|
||||
--from=docker:ghcr.io/${{ github.repository }}:monolith \
|
||||
--output=oci-archive:/workspace/chunkah-out/image.ociarchive
|
||||
|
||||
# Besitzrechte wieder an den normalen GHA-User übergeben
|
||||
# Besitzrechte korrigieren
|
||||
sudo chown -R runner:docker ./chunkah-out
|
||||
|
||||
# Temporären Tarball sofort löschen, um Platz auf der SSD zu sparen
|
||||
rm -f ./monolith.tar
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v3
|
||||
if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Push to GHCR via Skopeo (with ZSTD Compression)
|
||||
- name: Push final 128-Layer Image via Skopeo (with ZSTD Compression)
|
||||
if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
||||
run: |
|
||||
set -x
|
||||
@@ -139,7 +135,7 @@ jobs:
|
||||
export REGISTRY_AUTH_FILE=$HOME/.docker/config.json
|
||||
REGISTRY_PATH="${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}"
|
||||
|
||||
# Skopeo arbeitet direkt auf dem Archiv auf dem Host-Dateisystem
|
||||
# Pushe das optimierte 128-Layer Archiv als echtes ':stable'
|
||||
for tag in ${{ steps.metadata.outputs.tags }}; do
|
||||
skopeo copy \
|
||||
--dest-compress-format=zstd \
|
||||
@@ -152,6 +148,9 @@ jobs:
|
||||
FINAL_REGISTRY_DIGEST=$(skopeo inspect docker://$REGISTRY_PATH:${{ env.DEFAULT_TAG }} --format '{{.Digest}}')
|
||||
echo "REGISTRY_DIGEST=$FINAL_REGISTRY_DIGEST" >> $GITHUB_ENV
|
||||
|
||||
# Den temporären Monolithen von der Registry löschen, um Müll zu vermeiden
|
||||
skopeo delete docker://ghcr.io/${{ github.repository }}:monolith || true
|
||||
|
||||
- name: Install Cosign
|
||||
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
|
||||
if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
||||
|
||||
Reference in New Issue
Block a user