Skip to content

Commit 96551ae

Browse files
committed
ci: add caddy image build workflow
Signed-off-by: Matthew Penner <[email protected]>
1 parent 3b5baa1 commit 96551ae

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

.github/workflows/caddy.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Caddy
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- caddy.Containerfile
9+
10+
jobs:
11+
build-image:
12+
name: Build Image
13+
runs-on: ubuntu-22.04
14+
permissions:
15+
attestations: write
16+
contents: read
17+
id-token: write
18+
packages: write
19+
steps:
20+
- name: Code checkout
21+
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
22+
with:
23+
sparse-checkout: |
24+
caddy.Containerfile
25+
26+
- name: Setup QEMU
27+
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
28+
29+
- name: Setup Docker Buildx
30+
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
31+
32+
- name: Login to GitHub Container Registry
33+
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
34+
with:
35+
registry: ghcr.io
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Build and Push image
40+
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
41+
id: push
42+
env:
43+
# ref; https://docs.docker.com/build/ci/github-actions/reproducible-builds/
44+
SOURCE_DATE_EPOCH: 0
45+
with:
46+
context: .
47+
file: ./caddy.Containerfile
48+
platforms: linux/amd64,linux/arm64
49+
push: true
50+
sbom: true
51+
tags: ghcr.io/caddyserver/gateway:caddy-2.8.0
52+
build-args: |
53+
CADDY_VERSION=2.8.0
54+
CADDY_BUILDER_HASH=sha256:93a0320af6e247362974f8606f1659b977b8c4421282682844a197b26b4be924
55+
CADDY_HASH=sha256:ccdad842a0f34a8db14fa0671113f9567d65ba3798220539467d235131a3ed63
56+
57+
- name: Attest
58+
uses: actions/attest-build-provenance@173725a1209d09b31f9d30a3890cf2757ebbff0d # v1.1.2
59+
id: attest
60+
with:
61+
subject-name: ghcr.io/caddyserver/gateway
62+
subject-digest: ${{ steps.push.outputs.digest }}
63+
push-to-registry: true

caddy.Containerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This Containerfile is used to build Caddy with the additional modules required by Caddy Gateway
2+
# to function properly.
3+
4+
ARG CADDY_VERSION=2.8.0
5+
6+
ARG CADDY_BUILDER_HASH=sha256:93a0320af6e247362974f8606f1659b977b8c4421282682844a197b26b4be924
7+
ARG CADDY_HASH=sha256:ccdad842a0f34a8db14fa0671113f9567d65ba3798220539467d235131a3ed63
8+
9+
FROM docker.io/library/caddy:${CADDY_VERSION}-builder@${CADDY_BUILDER_HASH} AS builder
10+
11+
RUN xcaddy build \
12+
--with github.com/mholt/caddy-l4@6a8be7c4b8acb0c531b6151c94a9cd80894acce1
13+
14+
FROM docker.io/library/caddy:${CADDY_VERSION}@${CADDY_HASH}
15+
16+
COPY --from=builder /usr/bin/caddy /usr/bin/caddy

0 commit comments

Comments
 (0)