Skip to content

Commit

Permalink
Attempt to paralleise the docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
butlerx committed Oct 2, 2023
1 parent 798dc5f commit d53df2e
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 24 deletions.
90 changes: 75 additions & 15 deletions .github/workflows/docker.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,33 @@ name: Docker Workflow
on:
workflow_call:
inputs:
platforms:
required: true
type: string
push:
type: boolean
default: false
secrets:
DOCKERHUB_USERNAME:
DOCKERHUB_TOKEN:
env:
REGISTRY_IMAGE: wettyoss/wetty
jobs:
docker:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm/v6
- linux/arm/v7
- linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
wettyoss/wetty
ghcr.io/butlerx/wetty
images: ${{ env.REGISTRY_IMAGE }}
flavor: |
latest=true
tags: |
Expand All @@ -44,20 +49,75 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: build
uses: docker/build-push-action@v5
with:
context: .
file: containers/wetty/Dockerfile
platforms: ${{ inputs.platforms }}
push: ${{ inputs.push }}
platforms: ${{ matrix.platform }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
outputs:
type=image,name=${{ env.REGISTRY_IMAGE
}},push-by-digest=true,name-canonical=true,push=true
cache-from: type=registry,ref=${{ steps.meta.outputs.tags }}
cache-to: type=inline

- 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
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v3
with:
name: digests
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: ${{ env.REGISTRY_IMAGE }}
flavor: |
latest=true
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create manifest list and push
working-directory: /tmp/digests
run:
docker buildx imagetools create ${{ inputs.push && '' || '--dry-run'
}} $(jq -cr '.tags | map("-t " + .) | join(" ")' <<<
"$DOCKER_METADATA_OUTPUT_JSON") \ $(printf '${{ env.REGISTRY_IMAGE
}}@sha256:%s ' *)

- name: Inspect image
run:
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{
steps.meta.outputs.version }}
8 changes: 0 additions & 8 deletions .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ jobs:
validate-docker:
name: Validate Docker Build
uses: ./.github/workflows/docker.workflow.yml
strategy:
matrix:
platform:
- linux/amd64
- linux/arm/v6
- linux/arm/v7
- linux/arm64
secrets: inherit
with:
platforms: ${{ matrix.platform }}
push: false
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ jobs:
uses: ./.github/workflows/docker.workflow.yml
secrets: inherit
with:
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: true

0 comments on commit d53df2e

Please sign in to comment.