Skip to content

Commit

Permalink
Fix containers platforms and metadata
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
  • Loading branch information
s0undt3ch committed Nov 24, 2023
1 parent d347fce commit ea96ba8
Show file tree
Hide file tree
Showing 31 changed files with 2,464 additions and 362 deletions.
94 changes: 82 additions & 12 deletions .github/workflows/.container.template.j2
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ concurrency:

jobs:
matrix-generator:
name: "Mirror Matrix Generator"
name: Generate Matrix
runs-on: ubuntu-latest
outputs:
dockerinfo: ${{ steps.set-matrix.outputs.dockerinfo }}
Expand Down Expand Up @@ -64,10 +64,10 @@ jobs:
run: |
inv containers.matrix --from-workflow ${{ env.PATH_IN_REPO }}

mirror-image:
build:
runs-on: ubuntu-latest
needs: matrix-generator
name: "${{ matrix.dockerinfo.name }}${{ matrix.dockerinfo.platform && format(' ({0})', matrix.dockerinfo.platform) || ''}}"
name: "${{ matrix.dockerinfo.name }}:${{ matrix.dockerinfo.tag }}${{ matrix.dockerinfo.platform && format(' ({0})', matrix.dockerinfo.platform) || ''}}"
strategy:
fail-fast: false
max-parallel: 10
Expand Down Expand Up @@ -100,14 +100,18 @@ jobs:
run: |
t=$(shuf -i 5-30 -n 1); echo "Sleeping $t seconds"; sleep $t

- name: "Setup DockerFile"
run: |
echo " " >> ./${{matrix.dockerinfo.file}}
echo "LABEL org.opencontainers.image.source=\"https://github.com/${GITHUB_REPOSITORY}/\"" >> ${{matrix.dockerinfo.file}}
echo "LABEL org.opencontainers.image.url=\"https://github.com/${GITHUB_REPOSITORY}/\"" >> ${{matrix.dockerinfo.file}}
echo "LABEL org.opencontainers.image.documentation=\"https://github.com/${GITHUB_REPOSITORY}/\"" >> ${{matrix.dockerinfo.file}}
echo "LABEL org.opencontainers.image.vendor=\"Unofficial Docker Hub Mirror\"" >> ${{matrix.dockerinfo.file}}
cat ./${{matrix.dockerinfo.file}}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}/${{ matrix.dockerinfo.name }}
tags: |
type=raw,value=${{ matrix.dockerinfo.tag }}
flavor: |
latest=false
labels: |
org.opencontainers.image.source="https://github.com/${GITHUB_REPOSITORY}/"

- name: "Docker QEMU"
uses: docker/setup-qemu-action@v3
Expand All @@ -133,10 +137,76 @@ jobs:

- name: "Build & Publish"
uses: docker/build-push-action@v5
id: build
with:
file: ${{ matrix.dockerinfo.file }}
context: ${{ env.PATH_IN_REPO }}
platforms: ${{ matrix.dockerinfo.platform }}
push: ${{ github.repository == 'saltstack/salt-ci-containers' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) }}
outputs: type=image,name=${{ github.repository }}/${{ matrix.dockerinfo.name }},push-by-digest=true,name-canonical=true,push=${{
github.repository == 'saltstack/salt-ci-containers' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) }}

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"

- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests-${{ matrix.dockerinfo.name }}-${{ matrix.dockerinfo.tag }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
name: "Merge ${{ matrix.dockerinfo.name }}:${{ matrix.dockerinfo.tag }}${{ matrix.dockerinfo.platform && format(' ({0})', matrix.dockerinfo.platform) || ''}}"
strategy:
fail-fast: false
max-parallel: 10
matrix:
dockerinfo: ${{ fromJson(needs.matrix-generator.outputs.dockerinfo) }}
needs:
- matrix-generator
- build
steps:
- name: Download digests
uses: actions/download-artifact@v3
with:
name: digests-${{ matrix.dockerinfo.name }}-${{ matrix.dockerinfo.tag }}
path: /tmp/digests

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}/${{ matrix.dockerinfo.name }}
tags: |
ghcr.io/${{ github.repository }}/${{ matrix.dockerinfo.name }}
type=raw,value=${{ matrix.dockerinfo.tag }}
flavor: |
latest=false
labels: |
org.opencontainers.image.source="https://github.com/${GITHUB_REPOSITORY}/"

- name: "Log into GitHub Container Registry"
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ github.repository }}/${{ matrix.dockerinfo.name }}@sha256:%s ' *)

- name: Inspect image
run: |
docker buildx imagetools inspect ${{ github.repository }}/${{ matrix.dockerinfo.name }}:${{ steps.meta.outputs.version }}
94 changes: 82 additions & 12 deletions .github/workflows/almalinux-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ concurrency:

jobs:
matrix-generator:
name: "Mirror Matrix Generator"
name: Generate Matrix
runs-on: ubuntu-latest
outputs:
dockerinfo: ${{ steps.set-matrix.outputs.dockerinfo }}
Expand Down Expand Up @@ -64,10 +64,10 @@ jobs:
run: |
inv containers.matrix --from-workflow ${{ env.PATH_IN_REPO }}
mirror-image:
build:
runs-on: ubuntu-latest
needs: matrix-generator
name: "${{ matrix.dockerinfo.name }}${{ matrix.dockerinfo.platform && format(' ({0})', matrix.dockerinfo.platform) || ''}}"
name: "${{ matrix.dockerinfo.name }}:${{ matrix.dockerinfo.tag }}${{ matrix.dockerinfo.platform && format(' ({0})', matrix.dockerinfo.platform) || ''}}"
strategy:
fail-fast: false
max-parallel: 10
Expand Down Expand Up @@ -100,14 +100,18 @@ jobs:
run: |
t=$(shuf -i 5-30 -n 1); echo "Sleeping $t seconds"; sleep $t
- name: "Setup DockerFile"
run: |
echo " " >> ./${{matrix.dockerinfo.file}}
echo "LABEL org.opencontainers.image.source=\"https://github.com/${GITHUB_REPOSITORY}/\"" >> ${{matrix.dockerinfo.file}}
echo "LABEL org.opencontainers.image.url=\"https://github.com/${GITHUB_REPOSITORY}/\"" >> ${{matrix.dockerinfo.file}}
echo "LABEL org.opencontainers.image.documentation=\"https://github.com/${GITHUB_REPOSITORY}/\"" >> ${{matrix.dockerinfo.file}}
echo "LABEL org.opencontainers.image.vendor=\"Unofficial Docker Hub Mirror\"" >> ${{matrix.dockerinfo.file}}
cat ./${{matrix.dockerinfo.file}}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}/${{ matrix.dockerinfo.name }}
tags: |
type=raw,value=${{ matrix.dockerinfo.tag }}
flavor: |
latest=false
labels: |
org.opencontainers.image.source="https://github.com/${GITHUB_REPOSITORY}/"
- name: "Docker QEMU"
uses: docker/setup-qemu-action@v3
Expand All @@ -133,10 +137,76 @@ jobs:

- name: "Build & Publish"
uses: docker/build-push-action@v5
id: build
with:
file: ${{ matrix.dockerinfo.file }}
context: ${{ env.PATH_IN_REPO }}
platforms: ${{ matrix.dockerinfo.platform }}
push: ${{ github.repository == 'saltstack/salt-ci-containers' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) }}
outputs: type=image,name=${{ github.repository }}/${{ matrix.dockerinfo.name }},push-by-digest=true,name-canonical=true,push=${{
github.repository == 'saltstack/salt-ci-containers' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) }}

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests-${{ matrix.dockerinfo.name }}-${{ matrix.dockerinfo.tag }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
name: "Merge ${{ matrix.dockerinfo.name }}:${{ matrix.dockerinfo.tag }}${{ matrix.dockerinfo.platform && format(' ({0})', matrix.dockerinfo.platform) || ''}}"
strategy:
fail-fast: false
max-parallel: 10
matrix:
dockerinfo: ${{ fromJson(needs.matrix-generator.outputs.dockerinfo) }}
needs:
- matrix-generator
- build
steps:
- name: Download digests
uses: actions/download-artifact@v3
with:
name: digests-${{ matrix.dockerinfo.name }}-${{ matrix.dockerinfo.tag }}
path: /tmp/digests

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}/${{ matrix.dockerinfo.name }}
tags: |
ghcr.io/${{ github.repository }}/${{ matrix.dockerinfo.name }}
type=raw,value=${{ matrix.dockerinfo.tag }}
flavor: |
latest=false
labels: |
org.opencontainers.image.source="https://github.com/${GITHUB_REPOSITORY}/"
- name: "Log into GitHub Container Registry"
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ github.repository }}/${{ matrix.dockerinfo.name }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ github.repository }}/${{ matrix.dockerinfo.name }}:${{ steps.meta.outputs.version }}
94 changes: 82 additions & 12 deletions .github/workflows/amazonlinux-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ concurrency:

jobs:
matrix-generator:
name: "Mirror Matrix Generator"
name: Generate Matrix
runs-on: ubuntu-latest
outputs:
dockerinfo: ${{ steps.set-matrix.outputs.dockerinfo }}
Expand Down Expand Up @@ -64,10 +64,10 @@ jobs:
run: |
inv containers.matrix --from-workflow ${{ env.PATH_IN_REPO }}
mirror-image:
build:
runs-on: ubuntu-latest
needs: matrix-generator
name: "${{ matrix.dockerinfo.name }}${{ matrix.dockerinfo.platform && format(' ({0})', matrix.dockerinfo.platform) || ''}}"
name: "${{ matrix.dockerinfo.name }}:${{ matrix.dockerinfo.tag }}${{ matrix.dockerinfo.platform && format(' ({0})', matrix.dockerinfo.platform) || ''}}"
strategy:
fail-fast: false
max-parallel: 10
Expand Down Expand Up @@ -100,14 +100,18 @@ jobs:
run: |
t=$(shuf -i 5-30 -n 1); echo "Sleeping $t seconds"; sleep $t
- name: "Setup DockerFile"
run: |
echo " " >> ./${{matrix.dockerinfo.file}}
echo "LABEL org.opencontainers.image.source=\"https://github.com/${GITHUB_REPOSITORY}/\"" >> ${{matrix.dockerinfo.file}}
echo "LABEL org.opencontainers.image.url=\"https://github.com/${GITHUB_REPOSITORY}/\"" >> ${{matrix.dockerinfo.file}}
echo "LABEL org.opencontainers.image.documentation=\"https://github.com/${GITHUB_REPOSITORY}/\"" >> ${{matrix.dockerinfo.file}}
echo "LABEL org.opencontainers.image.vendor=\"Unofficial Docker Hub Mirror\"" >> ${{matrix.dockerinfo.file}}
cat ./${{matrix.dockerinfo.file}}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}/${{ matrix.dockerinfo.name }}
tags: |
type=raw,value=${{ matrix.dockerinfo.tag }}
flavor: |
latest=false
labels: |
org.opencontainers.image.source="https://github.com/${GITHUB_REPOSITORY}/"
- name: "Docker QEMU"
uses: docker/setup-qemu-action@v3
Expand All @@ -133,10 +137,76 @@ jobs:

- name: "Build & Publish"
uses: docker/build-push-action@v5
id: build
with:
file: ${{ matrix.dockerinfo.file }}
context: ${{ env.PATH_IN_REPO }}
platforms: ${{ matrix.dockerinfo.platform }}
push: ${{ github.repository == 'saltstack/salt-ci-containers' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) }}
outputs: type=image,name=${{ github.repository }}/${{ matrix.dockerinfo.name }},push-by-digest=true,name-canonical=true,push=${{
github.repository == 'saltstack/salt-ci-containers' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) }}

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests-${{ matrix.dockerinfo.name }}-${{ matrix.dockerinfo.tag }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
name: "Merge ${{ matrix.dockerinfo.name }}:${{ matrix.dockerinfo.tag }}${{ matrix.dockerinfo.platform && format(' ({0})', matrix.dockerinfo.platform) || ''}}"
strategy:
fail-fast: false
max-parallel: 10
matrix:
dockerinfo: ${{ fromJson(needs.matrix-generator.outputs.dockerinfo) }}
needs:
- matrix-generator
- build
steps:
- name: Download digests
uses: actions/download-artifact@v3
with:
name: digests-${{ matrix.dockerinfo.name }}-${{ matrix.dockerinfo.tag }}
path: /tmp/digests

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}/${{ matrix.dockerinfo.name }}
tags: |
ghcr.io/${{ github.repository }}/${{ matrix.dockerinfo.name }}
type=raw,value=${{ matrix.dockerinfo.tag }}
flavor: |
latest=false
labels: |
org.opencontainers.image.source="https://github.com/${GITHUB_REPOSITORY}/"
- name: "Log into GitHub Container Registry"
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ github.repository }}/${{ matrix.dockerinfo.name }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ github.repository }}/${{ matrix.dockerinfo.name }}:${{ steps.meta.outputs.version }}
Loading

0 comments on commit ea96ba8

Please sign in to comment.