-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy path.onedev-buildspec.yml
More file actions
243 lines (231 loc) · 6.56 KB
/
.onedev-buildspec.yml
File metadata and controls
243 lines (231 loc) · 6.56 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
235
236
237
238
239
240
241
242
243
version: 40
imports:
- projectPath: OpenMandriva/Software
revision: mirroring
jobs:
- name: Build minimal image (Docker)
jobExecutor: docker-with-mount-cap
steps:
- !UseTemplateStep
name: Build
templateName: Build
paramMatrix:
- name: version
secret: false
valuesProvider: !PassthroughValues
paramName: version
- name: target
secret: false
valuesProvider: !ScriptingValues
scriptName: docker-arch-to-omv-build-target
- name: extra-args
secret: false
valuesProvider: !SpecifiedValues
values:
- - -P rootfs -W @param:extra-args@
condition: SUCCESSFUL
optional: false
- !UseTemplateStep
name: Push to registry
templateName: Push image (Docker)
paramMatrix:
- name: docker-arch
secret: false
valuesProvider: !PassthroughValues
paramName: docker-arch
- name: dockerfile-path
secret: false
valuesProvider: !SpecifiedValues
values:
- - helpers/Dockerfile
- name: image-url
secret: false
valuesProvider: !SpecifiedValues
values:
- - openmandriva/minimal:@param:version@
condition: SUCCESSFUL
optional: false
paramSpecs:
- !ChoiceParam
name: version
allowMultiple: false
allowEmpty: false
choiceProvider: !SpecifiedChoices
choices:
- value: cooker
color: '#0d87e9'
- value: rolling
color: '#0d87e9'
- value: rock
color: '#0d87e9'
defaultValueProvider: !SpecifiedDefaultValue
value: cooker
- !ChoiceParam
name: docker-arch
allowMultiple: false
allowEmpty: false
choiceProvider: !SpecifiedChoices
choices:
- value: amd64
color: '#0d87e9'
- value: arm64
color: '#0d87e9'
- !TextParam
name: extra-args
allowEmpty: true
multiline: false
retryCondition: never
maxRetries: 3
retryDelay: 30
timeout: 14400
- name: Build builder image (Docker)
jobExecutor: docker-with-mount-cap
steps:
- !UseTemplateStep
name: Checkout repository
templateName: Checkout
condition: SUCCESSFUL
optional: false
- !UseTemplateStep
name: Push to registry
templateName: Push image (Docker)
paramMatrix:
- name: docker-arch
secret: false
valuesProvider: !PassthroughValues
paramName: docker-arch
- name: dockerfile-path
secret: false
valuesProvider: !SpecifiedValues
values:
- - helpers/Dockerfile_builder
- name: image-url
secret: false
valuesProvider: !SpecifiedValues
values:
- - openmandriva/builder:latest
condition: SUCCESSFUL
optional: false
paramSpecs:
- !ChoiceParam
name: docker-arch
allowMultiple: false
allowEmpty: false
choiceProvider: !SpecifiedChoices
choices:
- value: amd64
color: '#0d87e9'
- value: arm64
color: '#0d87e9'
retryCondition: never
maxRetries: 3
retryDelay: 30
timeout: 14400
stepTemplates:
- name: Checkout
steps:
- !CheckoutStep
name: Checkout repository
cloneCredential: !DefaultCredential {}
withLfs: false
withSubmodules: false
cloneDepth: 1
condition: SUCCESSFUL
optional: false
- name: Build
steps:
- !UseTemplateStep
name: Checkout repository
templateName: Checkout
condition: SUCCESSFUL
optional: false
- !CommandStep
name: Run build script in container
runInContainer: true
image: openmandriva/minimal:cooker
interpreter: !DefaultInterpreter
commands: "set -ex\n\necho insecure >> ~/.curlrc\n\ndnf --assumeyes --no-docs --setopt=install_weak_deps=False --refresh upgrade\ndnf --assumeyes --no-docs --setopt=install_weak_deps=False install timezone systemd git\n\n./build @param:extra-args@ -v @param:version@ @param:target@\n\nfolder=$(find . -maxdepth 1 -type d -name \"OpenMandriva-Lx-*\")\nif [ -n \"$folder\" ]; then\n\tmv \"$folder\" \"output\"\nfi\n"
useTTY: true
condition: SUCCESSFUL
optional: false
paramSpecs:
- !TextParam
name: version
allowEmpty: false
multiline: false
- !TextParam
name: target
allowEmpty: false
multiline: false
- !TextParam
name: extra-args
allowEmpty: true
multiline: false
- name: Push image (Docker)
steps:
- !CommandStep
name: Push to registry
runInContainer: true
image: quay.io/podman/stable
interpreter: !DefaultInterpreter
commands: |
set -e
dnf install --assumeyes skopeo
current_arch=@param:docker-arch@
image_url="@param:image-url@"
mkdir -p output
echo "🛠 Building image: $image_url_arch"
podman build \
--arch $current_arch \
--os linux \
-f "@param:dockerfile-path@" \
-t "$image_url.$current_arch" \
output
# Local registry
registry_url="@server@/$image_url"
echo "📤 Pushing image to: $registry_url.$current_arch"
podman login "@server@" -u "@job_token@" -p "@secret:local_registry_token@"
podman push "$image_url.$current_arch" "$registry_url.$current_arch"
manifest_args=""
architectures=("arm64" "amd64")
echo "🛠 Creating manifest for: $image_url"
podman manifest create "$image_url"
for arch in "${architectures[@@]}"; do
image="docker://$registry_url.$arch"
echo "🔍 Inspecting image at: $image"
if skopeo inspect "$image" &>/dev/null; then
echo "✅ Image found for: $arch"
podman manifest add \
--arch $arch \
--os linux \
"$image_url" \
"$image"
else
echo "⚠️ Image not found for: $arch"
fi
done
echo "📤 Pushing manifest to: $registry_url"
podman push "$image_url" "$registry_url"
# Remote registry
registry_url="@property:remote_registry@/$image_url"
echo "📤 Pushing image to: $registry_url.$current_arch"
podman login "@property:remote_registry@" -u "@secret:remote_registry_user@" -p "@secret:remote_registry_token@"
podman push "$image_url.$current_arch" "$registry_url.$current_arch"
echo "📤 Pushing manifest to: $registry_url"
podman push "$image_url" "$registry_url"
useTTY: true
condition: SUCCESSFUL
optional: false
paramSpecs:
- !TextParam
name: docker-arch
allowEmpty: false
multiline: false
- !TextParam
name: dockerfile-path
allowEmpty: false
multiline: false
- !TextParam
name: image-url
allowEmpty: false
multiline: false