fix(CI): Unified mulitplatform namespace && dev container support #24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Publish Docker Image | |
on: | |
workflow_dispatch: | |
pull_request: ## testing only | |
push: | |
branches: | |
- eigenda | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+-*" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
strategy: | |
matrix: | |
platform: [linux/amd64, linux/arm64] | |
runs-on: ${{ matrix.platform == 'linux/amd64' && 'linux-2xl' || 'linux-xl-arm' }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
install: true | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache-${{ matrix.platform }} | |
key: buildx-${{ matrix.platform }}-${{ hashFiles('Dockerfile') }} | |
restore-keys: buildx-${{ matrix.platform }}- | |
- name: Login to GHCR | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/${{ github.repository_owner }}/nitro-eigenda | |
ghcr.io/${{ github.repository_owner }}/nitro-eigenda-dev | |
tags: | | |
${{ github.ref_name }}-${{ matrix.platform }} | |
latest-${{ matrix.platform }} | |
- name: Build and push nitro-node image (prod) | |
uses: docker/build-push-action@v5 | |
with: | |
platform: ${{ matrix.platform }} | |
target: nitro-node | |
context: . | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/nitro-eigenda:${{ github.ref_name }}-${{ matrix.platform }} | |
ghcr.io/${{ github.repository_owner }}/nitro-eigenda:latest-${{ matrix.platform }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Build and push nitro-node image (dev) | |
uses: docker/build-push-action@v5 | |
with: | |
platform: ${{ matrix.platform }} | |
target: nitro-node-dev | |
context: . | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/nitro-eigenda-dev:${{ github.ref_name }}-${{ matrix.platform }} | |
ghcr.io/${{ github.repository_owner }}/nitro-eigenda-dev:latest-${{ matrix.platform }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Move Cache | |
run: | | |
rm -rf /tmp/.buildx-cache-${{ matrix.platform }} | |
mv /tmp/.buildx-cache-${{ matrix.platform }}-new /tmp/.buildx-cache-${{ matrix.platform }} | |
merge-multiarch: | |
needs: build | |
runs-on: linux-2xl | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create and Push Multi-Platform Manifests | |
run: | | |
for IMAGE in nitro-eigenda nitro-eigenda-dev; do | |
docker buildx imagetools create \ | |
--tag ghcr.io/${{ github.repository_owner }}/${IMAGE}:${{ github.ref_name }} \ | |
--tag ghcr.io/${{ github.repository_owner }}/${IMAGE}:latest \ | |
ghcr.io/${{ github.repository_owner }}/${IMAGE}:${{ github.ref_name }}-linux-amd64 \ | |
ghcr.io/${{ github.repository_owner }}/${IMAGE}:${{ github.ref_name }}-linux-arm64 | |
done |