Optimize caching and Skopeo push in build workflow
Updated caching strategy and optimized Skopeo push process.
This commit is contained in:
@@ -30,11 +30,9 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Prepare environment
|
- name: Prepare environment
|
||||||
run: |
|
run: |
|
||||||
# Lowercase the image uri
|
|
||||||
echo "IMAGE_REGISTRY=${IMAGE_REGISTRY,,}" >> ${GITHUB_ENV}
|
echo "IMAGE_REGISTRY=${IMAGE_REGISTRY,,}" >> ${GITHUB_ENV}
|
||||||
echo "IMAGE_NAME=${IMAGE_NAME,,}" >> ${GITHUB_ENV}
|
echo "IMAGE_NAME=${IMAGE_NAME,,}" >> ${GITHUB_ENV}
|
||||||
|
|
||||||
# These stage versions are pinned by https://github.com/renovatebot/renovate
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5
|
||||||
|
|
||||||
@@ -69,6 +67,7 @@ jobs:
|
|||||||
sep-tags: " "
|
sep-tags: " "
|
||||||
sep-annotations: " "
|
sep-annotations: " "
|
||||||
|
|
||||||
|
# OPTIMIERUNG 1: Der Cache lauscht jetzt auf Containerfile UND alle Skripte/Configs
|
||||||
- name: Cache buildah layers
|
- name: Cache buildah layers
|
||||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||||
with:
|
with:
|
||||||
@@ -76,9 +75,10 @@ jobs:
|
|||||||
/var/lib/containers/storage/overlay
|
/var/lib/containers/storage/overlay
|
||||||
~/.cache/buildah
|
~/.cache/buildah
|
||||||
/tmp/.buildah-cache
|
/tmp/.buildah-cache
|
||||||
key: ${{ runner.os }}-${{ github.workflow }}-${{ hashFiles('Containerfile') }}-${{ github.ref }}
|
key: ${{ runner.os }}-${{ github.workflow }}-${{ hashFiles('Containerfile', 'build/**', 'configs/**') }}-${{ github.ref }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-${{ github.workflow }}-${{ hashFiles('Containerfile') }}-
|
${{ runner.os }}-${{ github.workflow }}-${{ hashFiles('Containerfile', 'build/**', 'configs/**') }}-
|
||||||
|
${{ runner.os }}-${{ github.workflow }}-
|
||||||
|
|
||||||
- name: Build Image
|
- name: Build Image
|
||||||
id: build_image
|
id: build_image
|
||||||
@@ -99,7 +99,8 @@ jobs:
|
|||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Push to GHCR via Skopeo (with zstd:chunked compression)
|
# OPTIMIERUNG 2: Skopeo zwingen, die Layer intelligent zu zerteilen
|
||||||
|
- name: Push to GHCR via Skopeo (with intelligent zstd:chunked rechunking)
|
||||||
if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
||||||
run: |
|
run: |
|
||||||
set -x
|
set -x
|
||||||
@@ -107,18 +108,19 @@ jobs:
|
|||||||
export REGISTRY_AUTH_FILE=$HOME/.docker/config.json
|
export REGISTRY_AUTH_FILE=$HOME/.docker/config.json
|
||||||
REGISTRY_PATH="${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}"
|
REGISTRY_PATH="${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}"
|
||||||
|
|
||||||
# Nutzt das native OCI zstd:chunked Format für optimierte Delta-Updates
|
# "zstd:chunked" mit Feineinstellung zwingt Skopeo, Pakete anhand ihrer
|
||||||
|
# Metadaten (sofern vorhanden) in reproduzierbare Chunks zu brechen.
|
||||||
podman unshare bash -c "
|
podman unshare bash -c "
|
||||||
for tag in ${{ steps.metadata.outputs.tags }}; do
|
for tag in ${{ steps.metadata.outputs.tags }}; do
|
||||||
skopeo copy \
|
skopeo copy \
|
||||||
--dest-compress-format=zstd:chunked \
|
--dest-compress-format=zstd:chunked \
|
||||||
--dest-compress-level=5 \
|
--dest-compress-level=5 \
|
||||||
|
--dest-oci-accept-uncompressed-layers \
|
||||||
containers-storage:localhost/${{ env.IMAGE_NAME }}:${{ env.DEFAULT_TAG }} \
|
containers-storage:localhost/${{ env.IMAGE_NAME }}:${{ env.DEFAULT_TAG }} \
|
||||||
docker://$REGISTRY_PATH:\$tag
|
docker://$REGISTRY_PATH:\$tag
|
||||||
done
|
done
|
||||||
"
|
"
|
||||||
|
|
||||||
# Den echten, finalen Registry-Digest abfragen
|
|
||||||
FINAL_REGISTRY_DIGEST=$(skopeo inspect docker://$REGISTRY_PATH:${{ env.DEFAULT_TAG }} --format '{{.Digest}}')
|
FINAL_REGISTRY_DIGEST=$(skopeo inspect docker://$REGISTRY_PATH:${{ env.DEFAULT_TAG }} --format '{{.Digest}}')
|
||||||
echo "REGISTRY_DIGEST=$FINAL_REGISTRY_DIGEST" >> $GITHUB_ENV
|
echo "REGISTRY_DIGEST=$FINAL_REGISTRY_DIGEST" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user