Skip to content

Commit 66b68a3

Browse files
committed
docke dryrun in parallel
1 parent c8e0df7 commit 66b68a3

2 files changed

Lines changed: 93 additions & 23 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Reusable workflow that performs the container build steps for a single platform.
2+
# Used by `pull-docker-dryrun.yml` to run builds in parallel per-platform.
3+
on:
4+
workflow_call:
5+
inputs:
6+
platform:
7+
description: 'The target platform(s) to build for (e.g. linux/amd64)'
8+
required: true
9+
type: string
10+
dockerfile:
11+
description: 'Path to the Dockerfile to use (e.g. Dockerfile or Dockerfile.rootless)'
12+
required: false
13+
type: string
14+
cache_from:
15+
description: 'The cache-from value to pass to docker/build-push-action'
16+
required: false
17+
type: string
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
steps:
24+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
25+
- uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
26+
- uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
27+
- name: Build container image
28+
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
29+
with:
30+
context: .
31+
platforms: ${{ inputs.platform }}
32+
push: false
33+
file: ${{ inputs.dockerfile }}
34+
cache-from: ${{ inputs.cache_from }}

.github/workflows/pull-docker-dryrun.yml

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,70 @@ concurrency:
77
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
88
cancel-in-progress: true
99

10+
permissions:
11+
contents: read
12+
13+
env:
14+
CACHE_ROOTFUL: "type=registry,ref=ghcr.io/go-gitea/gitea:buildcache-rootful"
15+
CACHE_ROOTLESS: "type=registry,ref=ghcr.io/go-gitea/gitea:buildcache-rootless"
16+
1017
jobs:
1118
files-changed:
1219
uses: ./.github/workflows/files-changed.yml
1320
permissions:
1421
contents: read
1522

16-
container:
23+
# dryrun build is slow, so run them parallelly per-platform
24+
container-amd64-rootful:
1725
if: needs.files-changed.outputs.docker == 'true'
1826
needs: files-changed
19-
runs-on: ubuntu-latest
20-
permissions:
21-
contents: read
22-
steps:
23-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24-
- uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
25-
- uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
26-
- name: Build regular container image
27-
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
28-
with:
29-
context: .
30-
platforms: linux/amd64,linux/arm64,linux/riscv64
31-
push: false
32-
cache-from: type=registry,ref=ghcr.io/go-gitea/gitea:buildcache-rootful
33-
- name: Build rootless container image
34-
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
35-
with:
36-
context: .
37-
push: false
38-
platforms: linux/amd64,linux/arm64,linux/riscv64
39-
file: Dockerfile.rootless
40-
cache-from: type=registry,ref=ghcr.io/go-gitea/gitea:buildcache-rootless
27+
uses: ./.github/workflows/part-docker-dryrun.yml
28+
with:
29+
platform: linux/amd64
30+
dockerfile: Dockerfile
31+
cache_from: ${{ env.CACHE_ROOTFUL }}
32+
33+
container-amd64-rootless:
34+
if: needs.files-changed.outputs.docker == 'true'
35+
needs: files-changed
36+
uses: ./.github/workflows/part-docker-dryrun.yml
37+
with:
38+
platform: linux/amd64
39+
dockerfile: Dockerfile.rootless
40+
cache_from: ${{ env.CACHE_ROOTLESS }}
41+
42+
container-arm64-rootful:
43+
if: needs.files-changed.outputs.docker == 'true'
44+
needs: files-changed
45+
uses: ./.github/workflows/part-docker-dryrun.yml
46+
with:
47+
platform: linux/arm64
48+
dockerfile: Dockerfile
49+
cache_from: ${{ env.CACHE_ROOTFUL }}
50+
51+
container-arm64-rootless:
52+
if: needs.files-changed.outputs.docker == 'true'
53+
needs: files-changed
54+
uses: ./.github/workflows/part-docker-dryrun.yml
55+
with:
56+
platform: linux/arm64
57+
dockerfile: Dockerfile.rootless
58+
cache_from: ${{ env.CACHE_ROOTLESS }}
59+
60+
container-riscv64-rootful:
61+
if: needs.files-changed.outputs.docker == 'true'
62+
needs: files-changed
63+
uses: ./.github/workflows/part-docker-dryrun.yml
64+
with:
65+
platform: linux/riscv64
66+
dockerfile: Dockerfile
67+
cache_from: ${{ env.CACHE_ROOTFUL }}
68+
69+
container-riscv64-rootless:
70+
if: needs.files-changed.outputs.docker == 'true'
71+
needs: files-changed
72+
uses: ./.github/workflows/part-docker-dryrun.yml
73+
with:
74+
platform: linux/riscv64
75+
dockerfile: Dockerfile.rootless
76+
cache_from: ${{ env.CACHE_ROOTLESS }}

0 commit comments

Comments
 (0)