Skip to content

Commit 84b9163

Browse files
committed
Use parallel jobs for multi-arch build
1 parent 2c0fb3a commit 84b9163

File tree

4 files changed

+79
-67
lines changed

4 files changed

+79
-67
lines changed

.github/actions/action.yml

+28-20
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
1-
name: Build
2-
description: Build varnish image
1+
name: push
2+
description: combine multi-arch image and push
33
inputs:
44
version:
55
description: version
66
required: true
7-
tags:
8-
description: image tags
9-
required: true
10-
platform:
11-
description: docker platform
7+
latest:
8+
description: if tag latest
129
required: false
13-
default: linux/amd64
1410
runs:
1511
using: "composite"
1612
steps:
17-
- name: Build image
18-
env:
19-
VARNISH_VER: ${{ inputs.version }}
20-
TAGS: ${{ inputs.tags }}
21-
PLATFORM: ${{ inputs.platform }}
22-
run: |
23-
set -e
24-
make buildx-build-amd64
25-
make test
26-
make buildx-build
27-
. $GITHUB_ACTION_PATH/release.sh
28-
shell: bash
13+
- name: Build image
14+
env:
15+
VERSION: ${{ inputs.version }}
16+
LATEST: ${{ inputs.latest }}
17+
run: |
18+
if [[ "${GITHUB_REF}" == refs/heads/master || "${GITHUB_REF}" == refs/tags/* ]]; then
19+
minor_ver="${VERSION%.*}"
20+
major_ver="${minor_ver%.*}"
21+
22+
tags=("${minor_ver}" "${major_ver}")
23+
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
24+
stability_tag=("${GITHUB_REF##*/}")
25+
tags=("${minor_ver}-${stability_tag}" "${major_ver}-${stability_tag}")
26+
else
27+
if [[ -n "${LATEST}" ]]; then
28+
tags+=("latest")
29+
fi
30+
fi
31+
32+
for tag in "${tags[@]}"; do
33+
make buildx-imagetools-create TAG=${tag}
34+
done
35+
fi
36+
shell: bash

.github/actions/release.sh

-17
This file was deleted.

.github/workflows/workflow.yml

+42-12
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,51 @@ on:
1010

1111
env:
1212
BASE_IMAGE_STABILITY_TAG: 2.16.3
13+
VARNISH60: '6.0.13'
1314
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
1415
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
1516

16-
1717
jobs:
18-
varnish-60:
18+
varnish60-build:
19+
strategy:
20+
matrix:
21+
platform:
22+
- linux/amd64
23+
- linux/arm64
24+
include:
25+
- platform: linux/amd64
26+
runner: ubuntu-24.04
27+
arch: amd64
28+
- platform: linux/arm64
29+
runner: ubuntu-24.04-arm
30+
arch: arm64
31+
runs-on: ${{ matrix.runner }}
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: docker/login-action@v3
35+
with:
36+
username: ${{ secrets.DOCKER_USERNAME }}
37+
password: ${{ secrets.DOCKER_PASSWORD }}
38+
- uses: docker/setup-buildx-action@v3
39+
- name: build and push
40+
env:
41+
VARNISH_VER: ${{ env.VARNISH60 }}
42+
ARCH: ${{ matrix.arch }}
43+
PLATFORM: ${{ matrix.platform }}
44+
run: |
45+
make buildx-build
46+
make buildx-push
47+
varnish60-push:
1948
runs-on: ubuntu-latest
49+
needs:
50+
- varnish60-build
2051
steps:
21-
- uses: actions/checkout@v4
22-
- uses: docker/setup-qemu-action@v3
23-
with:
24-
platforms: amd64,arm64
25-
- uses: docker/setup-buildx-action@v3
26-
- uses: ./.github/actions
27-
with:
28-
version: '6.0.13'
29-
tags: 6.0,6,latest
30-
platform: linux/amd64,linux/arm64
52+
- uses: actions/checkout@v4
53+
- uses: docker/login-action@v3
54+
with:
55+
username: ${{ secrets.DOCKER_USERNAME }}
56+
password: ${{ secrets.DOCKER_PASSWORD }}
57+
- uses: ./.github/actions
58+
with:
59+
version: ${{ env.VARNISH60 }}
60+
latest: true

Makefile

+9-18
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
-include env.mk
22

33
VARNISH_VER ?= 6.0.13
4-
VARNISH_VER_MINOR = $(shell v='$(VARNISH_VER)'; echo "$${v%.*}")
4+
VARNISH_VER_MINOR = $(shell echo "${VARNISH_VER}" | grep -oE '^[0-9]+\.[0-9]+')
55

66
ALPINE_VER ?= 3.20
77

8-
PLATFORM ?= linux/amd64
8+
PLATFORM ?= linux/arm64
99

1010
ifeq ($(BASE_IMAGE_STABILITY_TAG),)
1111
BASE_IMAGE_TAG := $(ALPINE_VER)
@@ -18,13 +18,7 @@ TAG ?= $(VARNISH_VER_MINOR)
1818
REPO = wodby/varnish
1919
NAME = varnish-$(VARNISH_VER_MINOR)
2020

21-
ifneq ($(STABILITY_TAG),)
22-
ifneq ($(TAG),latest)
23-
override TAG := $(TAG)-$(STABILITY_TAG)
24-
endif
25-
endif
26-
27-
.PHONY: build buildx-build buildx-push buildx-build-amd64 test test-clean push shell run start stop logs clean release
21+
.PHONY: build buildx-build buildx-push test test-clean push shell run start stop logs clean release
2822

2923
default: build
3024

@@ -33,15 +27,6 @@ build:
3327
--build-arg BASE_IMAGE_TAG=$(BASE_IMAGE_TAG) \
3428
--build-arg VARNISH_VER=$(VARNISH_VER) ./
3529

36-
# --load doesn't work with multiple platforms https://github.com/docker/buildx/issues/59
37-
# we need to save cache to run tests first.
38-
buildx-build-amd64:
39-
docker buildx build --platform linux/amd64 -t $(REPO):$(TAG) \
40-
--build-arg BASE_IMAGE_TAG=$(BASE_IMAGE_TAG) \
41-
--build-arg VARNISH_VER=$(VARNISH_VER) \
42-
--load \
43-
./
44-
4530
buildx-build:
4631
docker buildx build --platform $(PLATFORM) -t $(REPO):$(TAG) \
4732
--build-arg BASE_IMAGE_TAG=$(BASE_IMAGE_TAG) \
@@ -54,6 +39,12 @@ buildx-push:
5439
--build-arg VARNISH_VER=$(VARNISH_VER) \
5540
./
5641

42+
buildx-imagetools-create:
43+
docker buildx imagetools create -t $(REPO):$(TAG) \
44+
$(REPO):$(VARNISH_VER_MINOR)-amd64 \
45+
$(REPO):$(VARNISH_VER_MINOR)-arm64
46+
.PHONY: buildx-imagetools-create
47+
5748
test:
5849
cd ./tests/basic && IMAGE=$(REPO):$(TAG) ./run.sh
5950
cd ./tests/drupal && IMAGE=$(REPO):$(TAG) ./run.sh

0 commit comments

Comments
 (0)