Skip to content

Building Test Images #30

Building Test Images

Building Test Images #30

Workflow file for this run

name: test-images
run-name: Building Test Images
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
images:
# - image: test-node
# dockerfile: backend-node.dockerfile
# target: rollups-node-we
# - image: test-node-cloud
# dockerfile: backend-node.dockerfile
# target: rollups-node-we-cloud
- image: test-devnet
dockerfile: devnet.dockerfile
target: rollups-devnet-we
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${{ matrix.images.image }}-${platform//\//-}" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Node Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/prototyp3-dev/${{ matrix.images.image }}
# tags: |
# type=sha,format=long,prefix=
labels: |
org.opencontainers.image.title=prototyp3-dev-${{ matrix.images.image }}
org.opencontainers.image.description=${{ matrix.images.image }}
org.opencontainers.image.source=${{ github.repository }}
org.opencontainers.image.licenses=Apache-2.0
org.opencontainers.image.url=${{ github.repository }}
- name: Node Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
platforms: ${{ matrix.platform }}
tags: ghcr.io/prototyp3-dev/${{ matrix.images.image }}
labels: ${{ steps.meta.outputs.labels }}
target: ${{ matrix.images.target }}
file: backend-node/${{ matrix.images.dockerfile }}
context: backend-node
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/${{ matrix.images.image }}/digests
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/${{ matrix.images.image }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/${{ matrix.images.image }}/digests/*
if-no-files-found: error
retention-days: 1
merge:
runs-on: ubuntu-latest
needs:
- build
strategy:
fail-fast: false
matrix:
images:
# - image: test-node
# - image: test-node-cloud
- image: test-devnet
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/${{ matrix.images.image }}/digests
merge-multiple: true
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Node Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/prototyp3-dev/${{ matrix.images.image }}
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=ref,event=branch,enable=${{ github.ref != format('refs/heads/{0}', 'main') }}
type=sha
labels: |
org.opencontainers.image.title=prototyp3-dev-${{ matrix.images.image }}
org.opencontainers.image.description=${{ matrix.images.image }}
org.opencontainers.image.source=${{ github.repository }}
org.opencontainers.image.licenses=Apache-2.0
org.opencontainers.image.url=${{ github.repository }}
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/${{ matrix.images.image }}/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'ghcr.io/prototyp3-dev/${{ matrix.images.image }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ghcr.io/prototyp3-dev/${{ matrix.images.image }}:${{ steps.meta.outputs.version }}