Skip to content
This repository was archived by the owner on Mar 12, 2026. It is now read-only.

Commit 055a44d

Browse files
authored
Merge pull request #5 from arxignis/build_speed_up
feat: Add Docker Bake configuration and update GitHub Actions workflo…
2 parents 81bd890 + e95fd69 commit 055a44d

4 files changed

Lines changed: 279 additions & 79 deletions

File tree

.github/workflows/pull.yaml

Lines changed: 126 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,147 @@
1-
name: nginx pull
1+
name: nginx preview deployment
22

33
on:
44
pull_request:
5-
branches:
6-
- main
5+
branches:
6+
- main
7+
env:
8+
REGISTRY_IMAGE: ghcr.io/arxignis/nginx
79
jobs:
8-
pull:
9-
name: nginx pull
10-
runs-on: ubicloud-standard-8-ubuntu-2404
10+
prepare:
11+
runs-on: ubicloud-standard-16-ubuntu-2404
12+
outputs:
13+
matrix: ${{ steps.platforms.outputs.matrix }}
1114
steps:
12-
- name: Login to Github Packages
13-
uses: docker/login-action@v3
14-
with:
15-
registry: ghcr.io
16-
username: ${{ github.actor }}
17-
password: ${{ secrets.GITHUB_TOKEN }}
18-
19-
- name: Set up QEMU
20-
id: qemu
21-
uses: docker/setup-qemu-action@v3
22-
with:
23-
image: tonistiigi/binfmt:latest
24-
platforms: all
25-
26-
- name: 🏗 Setup repo
15+
- name: Checkout
2716
uses: actions/checkout@v4
28-
with:
29-
token: ${{ secrets.GITHUB_TOKEN }}
30-
submodules: recursive
3117

32-
- name: Set up Docker Context for Buildx
33-
run: docker context create builders
18+
- name: Create matrix
19+
id: platforms
20+
run: |
21+
echo "matrix=$(docker buildx bake image-all --print | jq -cr '.target."image-all".platforms')" >>${GITHUB_OUTPUT}
3422
35-
- name: Set up Docker Buildx
36-
uses: docker/setup-buildx-action@v3
37-
with:
38-
version: latest
39-
endpoint: builders
23+
- name: Show matrix
24+
run: |
25+
echo ${{ steps.platforms.outputs.matrix }}
4026
4127
- name: Docker meta
42-
id: nginx
28+
id: meta
4329
uses: docker/metadata-action@v5
4430
with:
45-
images: ghcr.io/arxignis/nginx
31+
images: ${{ env.REGISTRY_IMAGE }}
4632
tags: |
4733
type=sha,format=short
4834
type=match,pattern=v(\d+\.\d+\.\d+),group=1
4935
type=match,pattern=v(\d+\.\d+),group=1
5036
type=match,pattern=v(\d+),group=1
5137
type=raw,value=latest
5238
39+
- name: Rename meta bake definition file
40+
run: |
41+
mv "${{ steps.meta.outputs.bake-file }}" "${{ runner.temp }}/bake-meta.json"
42+
43+
- name: Upload meta bake definition
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: bake-meta
47+
path: ${{ runner.temp }}/bake-meta.json
48+
if-no-files-found: error
49+
retention-days: 1
50+
51+
build:
52+
runs-on: ${{ matrix.platform == 'linux/arm64' && 'ubicloud-standard-16-arm-ubuntu-2404' || 'ubicloud-standard-16-ubuntu-2404' }}
53+
needs:
54+
- prepare
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
platform: ${{ fromJson(needs.prepare.outputs.matrix) }}
59+
steps:
60+
- name: Prepare
61+
run: |
62+
platform=${{ matrix.platform }}
63+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
64+
65+
- name: Download meta bake definition
66+
uses: actions/download-artifact@v4
67+
with:
68+
name: bake-meta
69+
path: ${{ runner.temp }}
70+
71+
- name: Login to Github Packages
72+
uses: docker/login-action@v3
73+
with:
74+
registry: ghcr.io
75+
username: ${{ github.actor }}
76+
password: ${{ secrets.GITHUB_TOKEN }}
77+
78+
- name: Set up QEMU
79+
uses: docker/setup-qemu-action@v3
80+
81+
- name: Set up Docker Buildx
82+
uses: docker/setup-buildx-action@v3
83+
5384
- name: Build
54-
uses: docker/build-push-action@v6
55-
id: build-image
85+
id: bake
86+
uses: docker/bake-action@v6
5687
with:
57-
context: .
58-
platforms: linux/arm64,linux/amd64
59-
push: false
60-
tags: ${{ steps.nginx.outputs.tags }}
61-
labels: ${{ steps.nginx.outputs.labels }}
62-
cache-from: type=gha
63-
cache-to: type=gha,mode=max
88+
files: |
89+
./docker-bake.hcl
90+
cwd://${{ runner.temp }}/bake-meta.json
91+
targets: image
92+
set: |
93+
*.tags=${{ env.REGISTRY_IMAGE }}
94+
*.platform=${{ matrix.platform }}
95+
*.output=type=image,push-by-digest=true,name-canonical=true,push=true
96+
97+
- name: Export digest
98+
run: |
99+
mkdir -p ${{ runner.temp }}/digests
100+
digest="${{ fromJSON(steps.bake.outputs.metadata).image['containerimage.digest'] }}"
101+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
102+
103+
# - name: Upload digest
104+
# uses: actions/upload-artifact@v4
105+
# with:
106+
# name: digests-${{ env.PLATFORM_PAIR }}
107+
# path: ${{ runner.temp }}/digests/*
108+
# if-no-files-found: error
109+
# retention-days: 1
110+
111+
# merge:
112+
# runs-on: ubicloud-standard-16-ubuntu-2404
113+
# needs:
114+
# - build
115+
# steps:
116+
# - name: Download meta bake definition
117+
# uses: actions/download-artifact@v4
118+
# with:
119+
# name: bake-meta
120+
# path: ${{ runner.temp }}
121+
122+
# - name: Download digests
123+
# uses: actions/download-artifact@v4
124+
# with:
125+
# path: ${{ runner.temp }}/digests
126+
# pattern: digests-*
127+
# merge-multiple: true
128+
129+
# - name: Login to Github Packages
130+
# uses: docker/login-action@v3
131+
# with:
132+
# registry: ghcr.io
133+
# username: ${{ github.actor }}
134+
# password: ${{ secrets.GITHUB_TOKEN }}
135+
136+
# - name: Set up Docker Buildx
137+
# uses: docker/setup-buildx-action@v3
138+
139+
# - name: Create manifest list and push
140+
# working-directory: ${{ runner.temp }}/digests
141+
# run: |
142+
# docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ env.REGISTRY_IMAGE }}")) | "-t " + .) | join(" ")' ${{ runner.temp }}/bake-meta.json) \
143+
# $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
144+
145+
# - name: Inspect image
146+
# run: |
147+
# docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' ${{ runner.temp }}/bake-meta.json)

.github/workflows/release.yaml

Lines changed: 120 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,70 @@ on:
44
push:
55
tags:
66
- "v*.*.*"
7+
env:
8+
REGISTRY_IMAGE: ghcr.io/arxignis/nginx
79
jobs:
8-
deploy:
9-
name: nginx release
10+
prepare:
1011
runs-on: ubicloud-standard-16-ubuntu-2404
12+
outputs:
13+
matrix: ${{ steps.platforms.outputs.matrix }}
1114
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Create matrix
19+
id: platforms
20+
run: |
21+
echo "matrix=$(docker buildx bake image-all --print | jq -cr '.target."image-all".platforms')" >>${GITHUB_OUTPUT}
22+
23+
- name: Show matrix
24+
run: |
25+
echo ${{ steps.platforms.outputs.matrix }}
26+
27+
- name: Docker meta
28+
id: nginx
29+
uses: docker/metadata-action@v5
30+
with:
31+
images: ${{ env.REGISTRY_IMAGE }}
32+
tags: |
33+
type=sha,format=short
34+
type=match,pattern=v(\d+\.\d+\.\d+),group=1
35+
type=match,pattern=v(\d+\.\d+),group=1
36+
type=match,pattern=v(\d+),group=1
37+
type=raw,value=latest
38+
39+
- name: Rename meta bake definition file
40+
run: |
41+
mv "${{ steps.meta.outputs.bake-file }}" "${{ runner.temp }}/bake-meta.json"
42+
43+
- name: Upload meta bake definition
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: bake-meta
47+
path: ${{ runner.temp }}/bake-meta.json
48+
if-no-files-found: error
49+
retention-days: 1
50+
51+
build:
52+
runs-on: ${{ matrix.platform == 'linux/arm64' && 'ubicloud-standard-16-arm-ubuntu-2404' || 'ubicloud-standard-16-ubuntu-2404' }}
53+
needs:
54+
- prepare
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
platform: ${{ fromJson(needs.prepare.outputs.matrix) }}
59+
steps:
60+
- name: Prepare
61+
run: |
62+
platform=${{ matrix.platform }}
63+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
64+
65+
- name: Download meta bake definition
66+
uses: actions/download-artifact@v4
67+
with:
68+
name: bake-meta
69+
path: ${{ runner.temp }}
70+
1271
- name: Login to Github Packages
1372
uses: docker/login-action@v3
1473
with:
@@ -17,47 +76,72 @@ jobs:
1776
password: ${{ secrets.GITHUB_TOKEN }}
1877

1978
- name: Set up QEMU
20-
id: qemu
2179
uses: docker/setup-qemu-action@v3
80+
81+
- name: Set up Docker Buildx
82+
uses: docker/setup-buildx-action@v3
83+
84+
- name: Build
85+
id: bake
86+
uses: docker/bake-action@v6
2287
with:
23-
image: tonistiigi/binfmt:latest
24-
platforms: all
88+
files: |
89+
./docker-bake.hcl
90+
cwd://${{ runner.temp }}/bake-meta.json
91+
targets: image
92+
set: |
93+
*.tags=${{ env.REGISTRY_IMAGE }}
94+
*.platform=${{ matrix.platform }}
95+
*.output=type=image,push-by-digest=true,name-canonical=true,push=true
2596
26-
- name: 🏗 Setup repo
27-
uses: actions/checkout@v4
97+
- name: Export digest
98+
run: |
99+
mkdir -p ${{ runner.temp }}/digests
100+
digest="${{ fromJSON(steps.bake.outputs.metadata).image['containerimage.digest'] }}"
101+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
102+
103+
- name: Upload digest
104+
uses: actions/upload-artifact@v4
28105
with:
29-
token: ${{ secrets.GITHUB_TOKEN }}
30-
submodules: recursive
106+
name: digests-${{ env.PLATFORM_PAIR }}
107+
path: ${{ runner.temp }}/digests/*
108+
if-no-files-found: error
109+
retention-days: 1
31110

32-
- name: Set up Docker Context for Buildx
33-
run: docker context create builders
111+
merge:
112+
runs-on: ubicloud-standard-16-ubuntu-2404
113+
needs:
114+
- build
115+
steps:
116+
- name: Download meta bake definition
117+
uses: actions/download-artifact@v4
118+
with:
119+
name: bake-meta
120+
path: ${{ runner.temp }}
34121

35-
- name: Set up Docker Buildx
36-
uses: docker/setup-buildx-action@v3
122+
- name: Download digests
123+
uses: actions/download-artifact@v4
37124
with:
38-
version: latest
39-
endpoint: builders
125+
path: ${{ runner.temp }}/digests
126+
pattern: digests-*
127+
merge-multiple: true
40128

41-
- name: Docker meta
42-
id: nginx
43-
uses: docker/metadata-action@v5
129+
- name: Login to Github Packages
130+
uses: docker/login-action@v3
44131
with:
45-
images: ghcr.io/arxignis/nginx
46-
tags: |
47-
type=sha,format=short
48-
type=match,pattern=v(\d+\.\d+\.\d+),group=1
49-
type=match,pattern=v(\d+\.\d+),group=1
50-
type=match,pattern=v(\d+),group=1
51-
type=raw,value=latest
132+
registry: ghcr.io
133+
username: ${{ github.actor }}
134+
password: ${{ secrets.GITHUB_TOKEN }}
52135

53-
- name: Build
54-
uses: docker/build-push-action@v6
55-
id: build-image
56-
with:
57-
context: .
58-
platforms: linux/arm64,linux/amd64
59-
push: true
60-
tags: ${{ steps.nginx.outputs.tags }}
61-
labels: ${{ steps.nginx.outputs.labels }}
62-
cache-from: type=gha
63-
cache-to: type=gha,mode=max
136+
- name: Set up Docker Buildx
137+
uses: docker/setup-buildx-action@v3
138+
139+
- name: Create manifest list and push
140+
working-directory: ${{ runner.temp }}/digests
141+
run: |
142+
docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ env.REGISTRY_IMAGE }}")) | "-t " + .) | join(" ")' ${{ runner.temp }}/bake-meta.json) \
143+
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
144+
145+
- name: Inspect image
146+
run: |
147+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' ${{ runner.temp }}/bake-meta.json)

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,9 @@ CMD ["/usr/local/openresty/nginx/sbin/nginx", "-g", "daemon off;"]
292292
STOPSIGNAL SIGQUIT
293293

294294
FROM openresty-builder AS runtime
295-
ENV ARXIGNIS_VERSION="1.2-0"
295+
ENV ARXIGNIS_VERSION="1.2-1"
296+
297+
WORKDIR /etc/nginx
296298

297299
RUN apk --no-cache add git \
298300
&& luarocks install lua-resty-arxignis ${ARXIGNIS_VERSION}

0 commit comments

Comments
 (0)