-
Notifications
You must be signed in to change notification settings - Fork 8
/
build_and_push.rb
executable file
·383 lines (341 loc) · 12.3 KB
/
build_and_push.rb
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
#!/usr/bin/env ruby
# frozen_string_literal: true
BUILD_ONLY = false
GIT_TAG = "master"
COMMON_CHAIN_NAME = "phala"
COMMON_TAG = "23111001"
NODE_GIT_TAG = GIT_TAG
NODE_DOCKER_TAG = COMMON_TAG
NODE_DOCKER_REPO = "#{COMMON_CHAIN_NAME}-node"
PHERRY_GIT_TAG = GIT_TAG
PHERRY_DOCKER_TAG = COMMON_TAG
PHERRY_DOCKER_REPO = "#{COMMON_CHAIN_NAME}-pherry"
HEADERS_CACHE_GIT_TAG = GIT_TAG
HEADERS_CACHE_DOCKER_TAG = COMMON_TAG
HEADERS_CACHE_DOCKER_REPO = "#{COMMON_CHAIN_NAME}-headers-cache"
REPLAY_GIT_TAG = GIT_TAG
REPLAY_DOCKER_TAG = COMMON_TAG
REPLAY_DOCKER_REPO = "#{COMMON_CHAIN_NAME}-replay"
PRB_GIT_TAG = GIT_TAG
PRB_DOCKER_TAG = COMMON_TAG
PRB_DOCKER_REPO = "#{COMMON_CHAIN_NAME}-prb"
PROUTER_GIT_TAG = GIT_TAG
PROUTER_DOCKER_TAG = COMMON_TAG
PROUTER_DOCKER_REPO = "#{COMMON_CHAIN_NAME}-prouter"
PRUNTIME_GIT_TAG = GIT_TAG
PRUNTIME_DOCKER_TAG = COMMON_TAG
PRUNTIME_EPID_DOCKER_REPO = "#{COMMON_CHAIN_NAME}-pruntime-v2"
PRUNTIME_EPID_WITH_HANDOVER_DOCKER_REPO = "#{COMMON_CHAIN_NAME}-pruntime-v2-with-handover"
PRUNTIME_DCAP_DOCKER_REPO = "#{COMMON_CHAIN_NAME}-pruntime-v2-dcap"
PRUNTIME_DCAP_WITH_HANDOVER_DOCKER_REPO = "#{COMMON_CHAIN_NAME}-pruntime-v2-dcap-with-handover"
SGX_DETECT_DOCKER_REPO = "phala-sgx_detect"
DCAP_TEST_DOCKER_REPO = "phala-dcap_test"
REGISTRIES = [
"jasl123",
# "phalanetwork",
# "swr.cn-east-3.myhuaweicloud.com/phala",
# "docker.pkg.github.com/phala-network/phala-docker"
]
require "open3"
def run(cmd)
Open3.popen2e(cmd) do |_stdin, stdout_err, wait_thr|
while (line = stdout_err.gets)
puts line
end
exit_status = wait_thr.value
unless exit_status.success?
abort "error"
end
end
end
# # Build SGX-Detect
# REGISTRIES.each do |registry|
# [
# "docker build -f sgx_detect.Dockerfile -t #{registry}/#{SGX_DETECT_DOCKER_REPO} ."
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# unless BUILD_ONLY
# # Push SGX-Detect
# REGISTRIES.each do |registry|
# [
# "docker push #{registry}/#{SGX_DETECT_DOCKER_REPO}"
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# end
# # Build DCAP test
# REGISTRIES.each do |registry|
# [
# "docker build -f dcap_test.Dockerfile -t #{registry}/#{DCAP_TEST_DOCKER_REPO} ."
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# unless BUILD_ONLY
# # Push DCAP test
# REGISTRIES.each do |registry|
# [
# "docker push #{registry}/#{DCAP_TEST_DOCKER_REPO}"
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# end
# # Build prebuilt pRuntime
# REGISTRIES.each do |registry|
# [
# "docker build -f prebuilt_pruntime.Dockerfile -t #{registry}/#{PRUNTIME_DOCKER_REPO}:#{PRUNTIME_DOCKER_TAG} .",
# "docker build -f prebuilt_pruntime.Dockerfile -t #{registry}/#{PRUNTIME_DOCKER_REPO} ."
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# unless BUILD_ONLY
# # Push prebuilt pRuntime
# REGISTRIES.each do |registry|
# [
# "docker push #{registry}/#{PRUNTIME_DOCKER_REPO}:#{PRUNTIME_DOCKER_TAG}",
# "docker push #{registry}/#{PRUNTIME_DOCKER_REPO}"
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# end
# Build pRuntime variants
SGX_SIGNER_KEY = "Enclave_private.prod.decrypted.pem"
IAS_SPID = ENV.fetch("IAS_SPID")
IAS_API_KEY = ENV.fetch("IAS_API_KEY")
IAS_LINKABLE = ENV.fetch("IAS_LINKABLE")
IAS_ENV = "PROD"
PRUNTIME_VERSION = ENV.fetch("PRUNTIME_VERSION", PRUNTIME_DOCKER_TAG)
REAL_PRUNTIME_DATA_DIR = "/opt/pruntime/data/#{PRUNTIME_VERSION}"
# Build pRuntime EPID variant
REGISTRIES.each do |registry|
[
"docker build --build-arg PHALA_GIT_TAG=#{PRUNTIME_GIT_TAG} --build-arg SGX_SIGNER_KEY=/root/.priv/#{SGX_SIGNER_KEY} --build-arg RA_TYPE=epid --build-arg IAS_SPID=#{IAS_SPID} --build-arg IAS_LINKABLE=#{IAS_LINKABLE} --build-arg IAS_API_KEY=#{IAS_API_KEY} --build-arg IAS_ENV=#{IAS_ENV} --build-arg PRUNTIME_VERSION=#{PRUNTIME_VERSION} --build-arg REAL_PRUNTIME_DATA_DIR=#{REAL_PRUNTIME_DATA_DIR} -f pruntime.Dockerfile -t #{registry}/#{PRUNTIME_EPID_DOCKER_REPO}:#{PRUNTIME_DOCKER_TAG} .",
"docker build --build-arg PHALA_GIT_TAG=#{PRUNTIME_GIT_TAG} --build-arg SGX_SIGNER_KEY=/root/.priv/#{SGX_SIGNER_KEY} --build-arg RA_TYPE=epid --build-arg IAS_SPID=#{IAS_SPID} --build-arg IAS_LINKABLE=#{IAS_LINKABLE} --build-arg IAS_API_KEY=#{IAS_API_KEY} --build-arg IAS_ENV=#{IAS_ENV} --build-arg PRUNTIME_VERSION=#{PRUNTIME_VERSION} --build-arg REAL_PRUNTIME_DATA_DIR=#{REAL_PRUNTIME_DATA_DIR} -f pruntime.Dockerfile -t #{registry}/#{PRUNTIME_EPID_DOCKER_REPO} ."
].each do |cmd|
puts cmd
run cmd
end
end
unless BUILD_ONLY
# Push pRuntime EPID variant
REGISTRIES.each do |registry|
[
"docker push #{registry}/#{PRUNTIME_EPID_DOCKER_REPO}:#{PRUNTIME_DOCKER_TAG}",
"docker push #{registry}/#{PRUNTIME_EPID_DOCKER_REPO}"
].each do |cmd|
puts cmd
run cmd
end
end
end
# Build pRuntime EPID variant with handover launcher
REGISTRIES.each do |registry|
[
"docker build --build-arg PRUNTIME_BASE_IMAGE=#{registry}/#{PRUNTIME_EPID_DOCKER_REPO}:#{PRUNTIME_DOCKER_TAG} --build-arg PRUNTIME_VERSION=#{PRUNTIME_VERSION} --build-arg REAL_PRUNTIME_DATA_DIR=#{REAL_PRUNTIME_DATA_DIR} -f pruntime-with-handover.Dockerfile -t #{registry}/#{PRUNTIME_EPID_WITH_HANDOVER_DOCKER_REPO}:#{PRUNTIME_DOCKER_TAG} .",
"docker build --build-arg PRUNTIME_BASE_IMAGE=#{registry}/#{PRUNTIME_EPID_DOCKER_REPO}:#{PRUNTIME_DOCKER_TAG} --build-arg PRUNTIME_VERSION=#{PRUNTIME_VERSION} --build-arg REAL_PRUNTIME_DATA_DIR=#{REAL_PRUNTIME_DATA_DIR} -f pruntime-with-handover.Dockerfile -t #{registry}/#{PRUNTIME_EPID_WITH_HANDOVER_DOCKER_REPO} ."
].each do |cmd|
puts cmd
run cmd
end
end
unless BUILD_ONLY
# Push pRuntime EPID variant with handover launcher
REGISTRIES.each do |registry|
[
"docker push #{registry}/#{PRUNTIME_EPID_WITH_HANDOVER_DOCKER_REPO}:#{PRUNTIME_DOCKER_TAG}",
"docker push #{registry}/#{PRUNTIME_EPID_WITH_HANDOVER_DOCKER_REPO}"
].each do |cmd|
puts cmd
run cmd
end
end
end
# Build pRuntime DCAP variant
REGISTRIES.each do |registry|
[
"docker build --build-arg PHALA_GIT_TAG=#{PRUNTIME_GIT_TAG} --build-arg SGX_SIGNER_KEY=/root/.priv/#{SGX_SIGNER_KEY} --build-arg RA_TYPE=dcap --build-arg PRUNTIME_VERSION=#{PRUNTIME_VERSION} --build-arg REAL_PRUNTIME_DATA_DIR=#{REAL_PRUNTIME_DATA_DIR} -f pruntime.Dockerfile -t #{registry}/#{PRUNTIME_DCAP_DOCKER_REPO}:#{PRUNTIME_DOCKER_TAG} .",
"docker build --build-arg PHALA_GIT_TAG=#{PRUNTIME_GIT_TAG} --build-arg SGX_SIGNER_KEY=/root/.priv/#{SGX_SIGNER_KEY} --build-arg RA_TYPE=dcap --build-arg PRUNTIME_VERSION=#{PRUNTIME_VERSION} --build-arg REAL_PRUNTIME_DATA_DIR=#{REAL_PRUNTIME_DATA_DIR} -f pruntime.Dockerfile -t #{registry}/#{PRUNTIME_DCAP_DOCKER_REPO} ."
].each do |cmd|
puts cmd
run cmd
end
end
unless BUILD_ONLY
# Push pRuntime DCAP variant
REGISTRIES.each do |registry|
[
"docker push #{registry}/#{PRUNTIME_DCAP_DOCKER_REPO}:#{PRUNTIME_DOCKER_TAG}",
"docker push #{registry}/#{PRUNTIME_DCAP_DOCKER_REPO}"
].each do |cmd|
puts cmd
run cmd
end
end
end
# Note: handover for DCAP variant isn't support yet
# # Build pRuntime DCAP variant with handover launcher
# REGISTRIES.each do |registry|
# [
# "docker build --build-arg PRUNTIME_BASE_IMAGE=#{registry}/#{PRUNTIME_DCAP_DOCKER_REPO}:#{PRUNTIME_DOCKER_TAG} --build-arg PRUNTIME_VERSION=#{PRUNTIME_VERSION} --build-arg REAL_PRUNTIME_DATA_DIR=#{REAL_PRUNTIME_DATA_DIR} -f pruntime-with-handover.Dockerfile -t #{registry}/#{PRUNTIME_DCAP_WITH_HANDOVER_DOCKER_REPO}:#{PRUNTIME_DOCKER_TAG} .",
# "docker build --build-arg PRUNTIME_BASE_IMAGE=#{registry}/#{PRUNTIME_DCAP_DOCKER_REPO}:#{PRUNTIME_DOCKER_TAG} --build-arg PRUNTIME_VERSION=#{PRUNTIME_VERSION} --build-arg REAL_PRUNTIME_DATA_DIR=#{REAL_PRUNTIME_DATA_DIR} -f pruntime-with-handover.Dockerfile -t #{registry}/#{PRUNTIME_DCAP_WITH_HANDOVER_DOCKER_REPO} ."
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# unless BUILD_ONLY
# # Push pRuntime DCAP variant with handover launcher
# REGISTRIES.each do |registry|
# [
# "docker push #{registry}/#{PRUNTIME_DCAP_WITH_HANDOVER_DOCKER_REPO}:#{PRUNTIME_DOCKER_TAG}",
# "docker push #{registry}/#{PRUNTIME_DCAP_WITH_HANDOVER_DOCKER_REPO}"
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# end
# # Build PRouter
# REGISTRIES.each do |registry|
# [
# "docker build --build-arg PHALA_GIT_TAG=#{PROUTER_GIT_TAG} -f prouter.Dockerfile -t #{registry}/#{PROUTER_DOCKER_REPO}:#{PROUTER_DOCKER_TAG} .",
# "docker build --build-arg PHALA_GIT_TAG=#{PROUTER_GIT_TAG} -f prouter.Dockerfile -t #{registry}/#{PROUTER_DOCKER_REPO} ."
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# unless BUILD_ONLY
# # Push PRouter
# REGISTRIES.each do |registry|
# [
# "docker push #{registry}/#{PROUTER_DOCKER_REPO}:#{PROUTER_DOCKER_TAG}",
# "docker push #{registry}/#{PROUTER_DOCKER_REPO}"
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# end
# # Build Phala-Node
# REGISTRIES.each do |registry|
# [
# "docker build --build-arg PHALA_GIT_TAG=#{NODE_GIT_TAG} -f node.Dockerfile -t #{registry}/#{NODE_DOCKER_REPO}:#{NODE_DOCKER_TAG} .",
# "docker build --build-arg PHALA_GIT_TAG=#{NODE_GIT_TAG} -f node.Dockerfile -t #{registry}/#{NODE_DOCKER_REPO} ."
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# unless BUILD_ONLY
# # Push Phala-Node
# REGISTRIES.each do |registry|
# [
# "docker push #{registry}/#{NODE_DOCKER_REPO}:#{NODE_DOCKER_TAG}",
# "docker push #{registry}/#{NODE_DOCKER_REPO}"
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# end
# # Build Phala-Pherry
# REGISTRIES.each do |registry|
# [
# "docker build --build-arg PHALA_GIT_TAG=#{PHERRY_GIT_TAG} -f pherry.Dockerfile -t #{registry}/#{PHERRY_DOCKER_REPO}:#{PHERRY_DOCKER_TAG} .",
# "docker build --build-arg PHALA_GIT_TAG=#{PHERRY_GIT_TAG} -f pherry.Dockerfile -t #{registry}/#{PHERRY_DOCKER_REPO} ."
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# unless BUILD_ONLY
# # Push Phala-Pherry
# REGISTRIES.each do |registry|
# [
# "docker push #{registry}/#{PHERRY_DOCKER_REPO}:#{PHERRY_DOCKER_TAG}",
# "docker push #{registry}/#{PHERRY_DOCKER_REPO}"
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# end
# # Build Phala-Headers-cache
# REGISTRIES.each do |registry|
# [
# "docker build --build-arg PHALA_GIT_TAG=#{HEADERS_CACHE_GIT_TAG} -f headers-cache.Dockerfile -t #{registry}/#{HEADERS_CACHE_DOCKER_REPO}:#{HEADERS_CACHE_DOCKER_TAG} .",
# "docker build --build-arg PHALA_GIT_TAG=#{HEADERS_CACHE_GIT_TAG} -f headers-cache.Dockerfile -t #{registry}/#{HEADERS_CACHE_DOCKER_REPO} ."
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# unless BUILD_ONLY
# # Push Phala-Headers-cache
# REGISTRIES.each do |registry|
# [
# "docker push #{registry}/#{HEADERS_CACHE_DOCKER_REPO}:#{HEADERS_CACHE_DOCKER_TAG}",
# "docker push #{registry}/#{HEADERS_CACHE_DOCKER_REPO}"
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# end
# # Build Phala-GK-Replay
# REGISTRIES.each do |registry|
# [
# "docker build --build-arg PHALA_GIT_TAG=#{REPLAY_GIT_TAG} -f replay.Dockerfile -t #{registry}/#{REPLAY_DOCKER_REPO}:#{REPLAY_DOCKER_TAG} .",
# "docker build --build-arg PHALA_GIT_TAG=#{REPLAY_GIT_TAG} -f replay.Dockerfile -t #{registry}/#{REPLAY_DOCKER_REPO} ."
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# unless BUILD_ONLY
# # Push Phala-GK-Replay
# REGISTRIES.each do |registry|
# [
# "docker push #{registry}/#{REPLAY_DOCKER_REPO}:#{REPLAY_DOCKER_TAG}",
# "docker push #{registry}/#{REPLAY_DOCKER_REPO}"
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# end
# # Build PRB
# REGISTRIES.each do |registry|
# [
# "docker build --build-arg PHALA_GIT_TAG=#{PRB_GIT_TAG} -f prb.Dockerfile -t #{registry}/#{PRB_DOCKER_REPO}:#{PRB_DOCKER_TAG} .",
# "docker build --build-arg PHALA_GIT_TAG=#{PRB_GIT_TAG} -f prb.Dockerfile -t #{registry}/#{PRB_DOCKER_REPO} ."
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# unless BUILD_ONLY
# # Push PRB
# REGISTRIES.each do |registry|
# [
# "docker push #{registry}/#{PRB_DOCKER_REPO}:#{PRB_DOCKER_TAG}",
# "docker push #{registry}/#{PRB_DOCKER_REPO}"
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# end