Repository navigation
172 lines (152 loc) · 5.91 KB
/
Copy pathdocker-publish.yml
File metadata and controls
172 lines (152 loc) · 5.91 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
# Build the two deployment images and push them to Docker Hub (issue #48).
#
# timeplus/tpk-app app-only image (pure-Python tpk; no timeplusd) -> App mode
# timeplus/tpk all-in-one image (timeplusd + tpk) -> all-in-one mode
#
# Tags produced: `latest` (main only), the git short SHA, and — on a vX.Y.Z tag —
# the semver `X.Y.Z` and `X.Y`. Every pushed tag is a multi-arch manifest list
# (linux/amd64 + linux/arm64, issue #72) so the images run natively on Apple
# Silicon and on ARM (Graviton) Kubernetes nodes. The arm64 leg is built under
# QEMU; pull requests build linux/amd64 only as a smoke test.
#
# Required repository secrets:
# DOCKERHUB_USERNAME / DOCKERHUB_TOKEN Docker Hub creds with push access to
# the `timeplus` org (a Hub access token).
# Optional (only if the timeplusd base image needs auth to pull):
# TIMEPLUSD_REGISTRY_USERNAME / TIMEPLUSD_REGISTRY_PASSWORD for docker.timeplus.com
#
# Pull requests build the app image (amd64 only) as a smoke test but never push.
name: Docker
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
workflow_dispatch:
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
# Multi-arch for anything we publish; PRs stay single-arch to keep CI fast.
PLATFORMS: ${{ github.event_name == 'pull_request' && 'linux/amd64' || 'linux/amd64,linux/arm64' }}
jobs:
app:
name: app image (timeplus/tpk-app)
runs-on: ubuntu-latest
# A hung buildx (seen once: an arm64 QEMU crash that never returned) must
# fail fast, not sit until GitHub's 6h default and end up 'cancelled'.
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: timeplus/tpk-app
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,format=short
# The version tpk reports at runtime (#85): the release tag without its
# "v", or dev-<sha> for branch / PR builds.
- name: tpk version
id: tpkver
run: |
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
else
echo "version=dev-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
fi
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: deploy/docker/Dockerfile
target: app
platforms: ${{ env.PLATFORMS }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
TPK_VERSION=${{ steps.tpkver.outputs.version }}
TPK_COMMIT=${{ github.sha }}
cache-from: type=gha,scope=app
cache-to: type=gha,mode=max,scope=app
allinone:
name: all-in-one image (timeplus/tpk)
# Bundles timeplusd from the (possibly private) Timeplus registry, so only
# build when we intend to publish — push, tag, or manual — where the
# registry secrets are available. PRs skip it.
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
# A hung buildx (seen once: an arm64 QEMU crash that never returned) must
# fail fast, not sit until GitHub's 6h default and end up 'cancelled'.
timeout-minutes: 30
env:
TP_REGISTRY_USER: ${{ secrets.TIMEPLUSD_REGISTRY_USERNAME }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to Timeplus registry (base image)
if: env.TP_REGISTRY_USER != ''
uses: docker/login-action@v3
with:
registry: docker.timeplus.com
username: ${{ secrets.TIMEPLUSD_REGISTRY_USERNAME }}
password: ${{ secrets.TIMEPLUSD_REGISTRY_PASSWORD }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: timeplus/tpk
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,format=short
# The version tpk reports at runtime (#85): the release tag without its
# "v", or dev-<sha> for branch / PR builds.
- name: tpk version
id: tpkver
run: |
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
else
echo "version=dev-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
fi
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: deploy/docker/Dockerfile
target: allinone
platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
TPK_VERSION=${{ steps.tpkver.outputs.version }}
TPK_COMMIT=${{ github.sha }}
cache-from: type=gha,scope=allinone
cache-to: type=gha,mode=max,scope=allinone