-
Notifications
You must be signed in to change notification settings - Fork 1
175 lines (155 loc) · 5.95 KB
/
Copy pathdocker.yml
File metadata and controls
175 lines (155 loc) · 5.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Docker
# Build the larkstack-console image and publish it to GHCR + Docker Hub.
#
# Multi-arch WITHOUT QEMU: each platform is built natively on its own runner
# (amd64 on ubuntu-24.04, arm64 on ubuntu-24.04-arm — free for public repos),
# pushed to both registries by digest, then a merge job stitches the per-arch
# images into one multi-arch manifest with `docker buildx imagetools create`.
#
# Versioning is git-tag driven (CalVer). Tag a release commit as
# `vYYYY.MM.PATCH` (e.g. `v2026.06.1`); the `v` is stripped for the image tag,
# which is taken verbatim so zero-padded (`2026.06.1`) and unpadded (`2026.6.1`)
# both keep their form. Each tag push publishes:
# <version> immutable, e.g. 2026.06.1
# <year.month> rolling latest patch for the month, e.g. 2026.06
# latest rolling newest release
# sha-<short> the exact commit, for traceability
# A manual run (workflow_dispatch) publishes `edge` + `sha-<short>`, or the
# version you pass in the `version` input.
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
version:
description: "Optional image version to publish (e.g. 2026.06.1). Leave blank for an `edge` build."
required: false
type: string
concurrency:
# Don't cancel an in-flight release build; serialize per ref instead.
group: docker-${{ github.ref }}
cancel-in-progress: false
env:
GHCR_IMAGE: ghcr.io/arcboxlabs/larkstack
DOCKERHUB_IMAGE: docker.io/arcboxlabs/larkstack
jobs:
build:
name: Build (${{ matrix.platform }})
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write # push to GHCR by digest
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
runner: ubuntu-24.04
- platform: linux/arm64
runner: ubuntu-24.04-arm
steps:
- name: Normalize platform pair
run: echo "PLATFORM_PAIR=${PLATFORM//\//-}" >> "$GITHUB_ENV"
env:
PLATFORM: ${{ matrix.platform }}
- uses: actions/checkout@v6
- name: Image labels (OCI metadata)
id: meta
uses: docker/metadata-action@v6
with:
images: |
${{ env.GHCR_IMAGE }}
${{ env.DOCKERHUB_IMAGE }}
- uses: docker/setup-buildx-action@v4
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build & push by digest
id: build
uses: docker/build-push-action@v7
with:
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
# Push the single-arch image (untagged, addressed by digest) to BOTH
# registries. The quoted multi-name keeps the comma inside the value.
outputs: type=image,"name=${{ env.GHCR_IMAGE }},${{ env.DOCKERHUB_IMAGE }}",push-by-digest=true,name-canonical=true,push=true
# Per-platform cache scope so amd64 and arm64 don't evict each other.
cache-from: type=gha,scope=${{ env.PLATFORM_PAIR }}
cache-to: type=gha,mode=max,scope=${{ env.PLATFORM_PAIR }}
# No attestations: keeps one digest per platform for a clean merge.
provenance: false
- name: Export digest
run: |
mkdir -p "${{ runner.temp }}/digests"
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v7
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
merge:
name: Merge manifest & push tags
runs-on: ubuntu-latest
needs: build
permissions:
contents: read
packages: write
steps:
- name: Download digests
uses: actions/download-artifact@v8
with:
path: ${{ runner.temp }}/digests
pattern: digests-*
merge-multiple: true
- uses: docker/setup-buildx-action@v4
- name: Compute image tags
id: meta
uses: docker/metadata-action@v6
with:
images: |
${{ env.GHCR_IMAGE }}
${{ env.DOCKERHUB_IMAGE }}
# We assign `latest` explicitly (only on tag pushes), so disable auto.
flavor: latest=false
tags: |
type=match,pattern=\d+\.\d+\.\d+,group=0
type=match,pattern=\d+\.\d+,group=0
type=raw,value=latest,enable=${{ github.ref_type == 'tag' }}
type=raw,value=${{ inputs.version }},enable=${{ inputs.version != '' }}
type=sha,format=short
type=raw,value=edge,enable=${{ github.ref == 'refs/heads/main' }}
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create manifest list & push
working-directory: ${{ runner.temp }}/digests
run: |
for image in "$GHCR_IMAGE" "$DOCKERHUB_IMAGE"; do
docker buildx imagetools create \
$(jq -cr --arg img "$image" \
'.tags | map(select(startswith($img + ":")) | "-t " + .) | join(" ")' \
<<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf "${image}@sha256:%s " *)
done
- name: Inspect
run: docker buildx imagetools inspect "${GHCR_IMAGE}:${{ steps.meta.outputs.version }}"