Skip to content

Commit f02d83a

Browse files
committed
switch to bake
1 parent cdb36a8 commit f02d83a

File tree

3 files changed

+58
-30
lines changed

3 files changed

+58
-30
lines changed

.github/workflows/docker-build.yml

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: docker-build
22

33
on:
44
push:
5-
branches:
6-
- main
5+
pull_request:
76

87
jobs:
98
multi-arch-push:
@@ -12,19 +11,9 @@ jobs:
1211
-
1312
name: Checkout
1413
uses: actions/checkout@v4
15-
with:
16-
fetch-depth: 0
1714
-
1815
name: Set up Docker Buildx
1916
uses: docker/setup-buildx-action@v3
20-
-
21-
name: Cache Docker layers
22-
uses: actions/cache@v4
23-
with:
24-
path: /tmp/.buildx-cache
25-
key: ${{ runner.os }}-buildx-${{ github.sha }}
26-
restore-keys: |
27-
${{ runner.os }}-buildx-
2817
-
2918
name: Login to GitHub Registry
3019
uses: docker/login-action@v3
@@ -39,21 +28,24 @@ jobs:
3928
username: erisamoe
4029
password: ${{ secrets.DOCKERHUB_TOKEN }}
4130
-
42-
name: Get Latest Tag
43-
id: previoustag
44-
uses: WyriHaximus/github-action-get-previous-tag@04e8485ecb6487243907e330d522ff60f02283ce # [email protected]
45-
-
31+
if: github.ref == 'ref/heads/main'
4632
name: Build and push
47-
uses: docker/build-push-action@v5
33+
uses: docker/bake-action@v6
34+
env:
35+
MULTI_PLATFORM: true
4836
with:
49-
context: .
50-
file: ./Dockerfile
51-
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x,linux/ppc64le,linux/riscv64
5237
push: true
53-
tags: |
54-
erisamoe/cloudflared:latest
55-
erisamoe/cloudflared:${{ steps.previoustag.outputs.tag }}
56-
ghcr.io/erisa/cloudflared:latest
57-
ghcr.io/erisa/cloudflared:${{ steps.previoustag.outputs.tag }}
58-
cache-from: type=local,src=/tmp/.buildx-cache
59-
cache-to: type=local,dest=/tmp/.buildx-cache
38+
set: |
39+
*.cache-from=type=registry,ref=user/app:latest
40+
*.cache-to=type=inline
41+
-
42+
if: github.ref != 'ref/heads/main'
43+
name: Build test image
44+
uses: docker/bake-action@v6
45+
env:
46+
MULTI_PLATFORM: true
47+
with:
48+
push: false
49+
set: |
50+
*.cache-from=type=registry,ref=user/app:latest
51+
*.cache-to=type=inline

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Build container
2-
ARG GOVERSION=1.23.8
3-
ARG ALPINEVERSION=3.21
2+
ARG GOVERSION=1.23
3+
ARG ALPINEVERSION
44

55
FROM --platform=${BUILDPLATFORM} \
66
golang:$GOVERSION-alpine${ALPINEVERSION} AS build
@@ -11,7 +11,7 @@ RUN apk --no-cache add git build-base bash
1111
ENV GO111MODULE=on \
1212
CGO_ENABLED=0
1313

14-
ARG VERSION=2025.4.2
14+
ARG VERSION
1515
RUN git clone https://github.com/cloudflare/cloudflared --depth=1 --branch ${VERSION} .
1616
RUN bash -x .teamcity/install-cloudflare-go.sh
1717

docker-bake.hcl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
variable "CLOUDFLARED_VERSION" {
2+
default = "2025.4.2"
3+
}
4+
5+
variable "LATEST" {
6+
default = true
7+
}
8+
9+
variable "MULTI_PLATFORM" {
10+
default = false
11+
}
12+
13+
target "default" {
14+
target = "build"
15+
args = {
16+
VERSION = "${CLOUDFLARED_VERSION}"
17+
GOVERSION = "1.23.9"
18+
ALPINEVERSION = "3.21"
19+
}
20+
platforms = !MULTI_PLATFORM ? null : [
21+
"linux/amd64",
22+
"linux/386",
23+
"linux/arm64",
24+
"linux/arm/v7",
25+
"linux/arm/v6",
26+
"linux/s390x",
27+
"linux/ppc64le",
28+
"linux/riscv64"
29+
]
30+
tags = [
31+
"erisamoe/cloudflared:${CLOUDFLARED_VERSION}",
32+
"ghcr.io/erisa/cloudflared:${CLOUDFLARED_VERSION}",
33+
LATEST ? "erisamoe/cloudflared:latest" : "",
34+
LATEST ? "ghcr.io/erisa/cloudflared:latest" : "",
35+
]
36+
}

0 commit comments

Comments
 (0)