Repository navigation
234 lines (232 loc) · 9.59 KB
/
Copy pathdocker-build.yml
File metadata and controls
234 lines (232 loc) · 9.59 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
name: Docker Build
# Verifies the release Docker images actually build, without pushing.
# A source-level type check (`make ci-lint`) cannot catch build failures that
# only surface inside the image — e.g. a declaration file that exists in the
# repo but was never COPYed into the Docker build stage.
#
# On pull requests each image is built only when files that affect it change,
# so unrelated PRs stay fast.
#
# On pushes to main every image is built regardless of what changed. The path
# filter is the wrong instrument there, because these builds can break with no
# repo change at all: the Dockerfile pins floating upstream tags
# (`node:${NODE_VERSION}-alpine`, `clickhouse-server:${CLICKHOUSE_VERSION}-alpine`)
# and the registry re-points them whenever upstream publishes a patch. That is
# exactly how the 26.8-alpine break reached a release: the tag moved from
# ClickHouse 26.8.6 to 26.8.7 mid-afternoon, upgrading apk-tools 3.0.6 -> 3.0.8
# underneath us. The PR check and the nightly had both already passed against
# the older digest, two commits then merged to main with no image build between
# them, and the failure only appeared in the release run hours later. Building
# unconditionally on main turns that into a red build on the next merge.
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
concurrency:
# Keyed on the event as well as the ref to separate a manual run on main from
# a merge: both carry `refs/heads/main`, so they would otherwise contend for
# one group. (A pull request run never collides with either — its ref is
# `refs/pull/<n>/merge`.)
#
# Pushes to main do not cancel in progress, so a merge cannot kill the build
# verifying the commit before it. This guarantees the tip of main gets built,
# not that every individual commit does: GitHub holds only one pending run per
# group, so a third merge arriving during a long build supersedes the queued
# one. That is fine for what this job is for — an upstream base-image move
# affects every commit equally, and a Dockerfile break in a superseded commit
# is still present at the tip. Per-commit attribution comes from the pull
# request run, not from here.
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
# OTel Collector image (Go build via OCB) — docker/otel-collector/Dockerfile.
otel-collector-image:
name: Build OTel Collector Image
runs-on: ubuntu-24.04
timeout-minutes: 25
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Get changed files
id: changed-files
if: github.event_name == 'pull_request'
uses: tj-actions/changed-files@v47.0.6
with:
files: |
docker/otel-collector/**
packages/otel-collector/**
- name: Setup Docker Buildx
if:
github.event_name != 'pull_request' ||
steps.changed-files.outputs.any_changed == 'true'
uses: docker/setup-buildx-action@v3
- name: Build (no push)
if:
github.event_name != 'pull_request' ||
steps.changed-files.outputs.any_changed == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/otel-collector/Dockerfile
target: prod
platforms: linux/amd64
push: false
cache-from: |
type=gha,scope=otel-collector-nightly-amd64
type=gha,scope=docker-build-pr-otel-collector
cache-to: type=gha,mode=max,scope=docker-build-pr-otel-collector
# App/prod image (API + App + common-utils Node build) — docker/hyperdx target prod.
# This is the image the nightly css.d.ts failure surfaced in; the same builder
# stage backs the all-in-one targets below.
app-image:
name: Build App Image
runs-on: ubuntu-24.04
timeout-minutes: 25
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Get changed files
id: changed-files
if: github.event_name == 'pull_request'
uses: tj-actions/changed-files@v47.0.6
with:
files: |
packages/api/**
packages/app/**
packages/common-utils/**
docker/hyperdx/**
package.json
yarn.lock
.yarn/**
.yarnrc.yml
.prettierrc
.prettierignore
tsconfig.base.json
nx.json
- name: Setup Docker Buildx
if:
github.event_name != 'pull_request' ||
steps.changed-files.outputs.any_changed == 'true'
uses: docker/setup-buildx-action@v3
- name: Build (no push)
if:
github.event_name != 'pull_request' ||
steps.changed-files.outputs.any_changed == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/hyperdx/Dockerfile
target: prod
platforms: linux/amd64
push: false
build-contexts: |
hyperdx=./docker/hyperdx
api=./packages/api
app=./packages/app
build-args: |
CODE_VERSION=pr-${{ github.event.pull_request.number || github.run_id }}
cache-from: |
type=gha,scope=app-nightly-amd64
type=gha,scope=docker-build-pr-app
cache-to: type=gha,mode=max,scope=docker-build-pr-app
# All-in-one image (adds ClickHouse, MongoDB, OTel Collector to the app build)
# — docker/hyperdx targets all-in-one-auth AND all-in-one-noauth (the Local
# image). The two are siblings off the shared all-in-one-base, each with its
# own final COPY of an entry script (entry.local.auth.sh / .noauth.sh), so
# building auth alone would NOT catch a break in the noauth-specific layer —
# which is what surfaced in the nightly. Both are built here; the base is
# built once and reused from buildx's local cache for the second target, so
# the noauth build only adds its one tiny COPY layer.
#
# This target's base does `COPY --from=prod /app /app`, so it already
# rebuilds the entire App/prod image. To avoid duplicating that ~8-minute
# Node build on every app change, the pull-request path filter below is
# scoped ONLY to the incremental bundling inputs (ClickHouse / OTel / the
# shared Dockerfile) — NOT api/app/common-utils/deps. Those are covered by
# the App Image job above, and they can't break the bundling layers, which
# only COPY the prod output. Pushes to main ignore the filter entirely.
all-in-one-image:
name: Build All-in-One Image
runs-on: ubuntu-24.04
timeout-minutes: 40
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Get changed files
id: changed-files
if: github.event_name == 'pull_request'
uses: tj-actions/changed-files@v47.0.6
with:
files: |
packages/otel-collector/**
docker/hyperdx/**
docker/clickhouse/**
docker/otel-collector/**
.vex/**
- name: Setup Docker Buildx
if:
github.event_name != 'pull_request' ||
steps.changed-files.outputs.any_changed == 'true'
uses: docker/setup-buildx-action@v3
- name: Build all-in-one-auth (no push)
if:
github.event_name != 'pull_request' ||
steps.changed-files.outputs.any_changed == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/hyperdx/Dockerfile
target: all-in-one-auth
platforms: linux/amd64
push: false
build-contexts: |
clickhouse=./docker/clickhouse
otel-collector=./docker/otel-collector
hyperdx=./docker/hyperdx
api=./packages/api
app=./packages/app
build-args: |
CODE_VERSION=pr-${{ github.event.pull_request.number || github.run_id }}
cache-from: |
type=gha,scope=all-in-one-nightly-amd64
type=gha,scope=docker-build-pr-all-in-one
cache-to: type=gha,mode=max,scope=docker-build-pr-all-in-one
# noauth is a sibling of auth off the shared all-in-one-base; the base is
# already in buildx's local cache from the step above, so this only builds
# the final noauth COPY layer.
- name: Build all-in-one-noauth / Local (no push)
if:
github.event_name != 'pull_request' ||
steps.changed-files.outputs.any_changed == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/hyperdx/Dockerfile
target: all-in-one-noauth
platforms: linux/amd64
push: false
load: true
tags: hyperdx-aio-smoke:pr
build-contexts: |
clickhouse=./docker/clickhouse
otel-collector=./docker/otel-collector
hyperdx=./docker/hyperdx
api=./packages/api
app=./packages/app
build-args: |
CODE_VERSION=pr-${{ github.event.pull_request.number || github.run_id }}
cache-from: |
type=gha,scope=all-in-one-nightly-amd64
type=gha,scope=docker-build-pr-all-in-one
# Boot the freshly built Local image and push one OTLP log end-to-end into
# ClickHouse. Proves the artefact we ship actually runs, not just builds.
- name: Smoke test the built image
if:
github.event_name != 'pull_request' ||
steps.changed-files.outputs.any_changed == 'true'
timeout-minutes: 10
run: scripts/ci/smoke-all-in-one.sh hyperdx-aio-smoke:pr