Skip to content

Commit 57b228e

Browse files
feat: add GHCR container image publishing workflow
Add a GitHub Actions workflow that builds and pushes multi-arch (amd64/arm64) container images to GHCR on pushes to main and version tags. Includes build caching and SLSA provenance attestation. Update docker-compose.yml to pull from GHCR by default. Closes #6
1 parent d8ec579 commit 57b228e

2 files changed

Lines changed: 69 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Publish Container Image
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ["v*"]
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
jobs:
13+
build-and-push:
14+
name: Build & Push to GHCR
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
attestations: write
20+
id-token: write
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Set up QEMU
26+
uses: docker/setup-qemu-action@v3
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: Log in to GHCR
32+
uses: docker/login-action@v3
33+
with:
34+
registry: ${{ env.REGISTRY }}
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Extract metadata
39+
id: meta
40+
uses: docker/metadata-action@v5
41+
with:
42+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
43+
tags: |
44+
type=ref,event=branch
45+
type=semver,pattern={{version}}
46+
type=semver,pattern={{major}}.{{minor}}
47+
type=sha
48+
49+
- name: Build and push
50+
id: push
51+
uses: docker/build-push-action@v6
52+
with:
53+
context: .
54+
platforms: linux/amd64,linux/arm64
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max
60+
61+
- name: Generate artifact attestation
62+
uses: actions/attest-build-provenance@v2
63+
with:
64+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
65+
subject-digest: ${{ steps.push.outputs.digest }}
66+
push-to-registry: true

docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
services:
22
app:
3-
build: .
3+
image: ghcr.io/zentinelproxy/zentinel-control-plane:main
4+
# To build locally instead, comment out `image` and uncomment:
5+
# build: .
46
ports:
57
- "4000:4000"
68
environment:

0 commit comments

Comments
 (0)