Skip to content

Commit

Permalink
Split docker builds
Browse files Browse the repository at this point in the history
  • Loading branch information
jlantz committed Sep 26, 2024
1 parent 07e41dd commit 0a93cb4
Showing 1 changed file with 44 additions and 16 deletions.
60 changes: 44 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Docker Image
name: Build Multi-Arch Docker Images

on:
push:
Expand All @@ -10,13 +10,19 @@ on:
jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
target: [no-browser, chromedriver, playwright, full-browser]
platform: [linux/amd64, linux/arm64]
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

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

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
Expand All @@ -33,18 +39,40 @@ jobs:
echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
fi
- name: Build and push Docker images
uses: docker/build-push-action@v2
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name == 'push' }}
tags: |
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-chromedriver
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-playwright
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-full-browser
outputs: |
type=image,name=ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }},target=no-browser
type=image,name=ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-chromedriver,target=chromedriver
type=image,name=ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-playwright,target=playwright
type=image,name=ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-full-browser,target=full-browser
tags: ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-${{ matrix.target }}
platforms: ${{ matrix.platform }}
target: ${{ matrix.target }}
cache-from: type=gha
cache-to: type=gha,mode=max

merge-manifests:
needs: build
runs-on: ubuntu-latest
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set environment variables
run: |
if [ "${{ github.ref_name }}" == "main" ]; then
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
fi
- name: Create and push multi-arch manifests
run: |
for target in no-browser chromedriver playwright full-browser; do
docker buildx imagetools create -t ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-${target} \
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-${target}-linux-amd64 \
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-${target}-linux-arm64
done

0 comments on commit 0a93cb4

Please sign in to comment.