forked from deckhouse/deckhouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
werf.yaml
750 lines (702 loc) · 21.4 KB
/
werf.yaml
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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
---
project: deckhouse
configVersion: 1
cleanup:
keepPolicies:
- references:
branch: /.*/
limit:
in: 720h
- references:
tag: /.*/
limit:
in: 720h
gitWorktree:
forceShallowClone: true
---
{{- define "base components" }}
{{- $CandiVersionMap := .Files.Get "candi/version_map.yml" | fromYaml }}
- name: "Install jo"
apk:
name:
- jo
update_cache: yes
- name: "install cfssl"
get_url:
url: https://github.com/cloudflare/cfssl/releases/download/v1.6.0/cfssl_1.6.0_linux_amd64
checksum: "sha256:b830b0faf606cb2ae8b45c783edf4776eedb3728efd515e7f1ce63b3a475d667"
dest: /usr/local/bin/cfssl
mode: +x
- name: "Install yq"
get_url:
url: https://github.com/mikefarah/yq/releases/download/2.4.1/yq_linux_amd64
checksum: "sha256:754c6e6a7ef92b00ef73b8b0bb1d76d651e04d26aa6c6625e272201afa889f8b"
dest: /usr/local/bin/yq
mode: +x
- name: "Install kubectl"
shell: |
{{- range $k8sVersion := tuple "1.20" "1.23" }}
curl -L https://dl.k8s.io/release/v{{ $k8sVersion }}.{{ index $CandiVersionMap "k8s" $k8sVersion "patch" }}/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl-{{ $k8sVersion }}
chmod +x /usr/local/bin/kubectl-{{ $k8sVersion }}
{{- end }}
- name: "Install kubectl wrapper"
copy:
content: |
{{- .Files.Get "deckhouse-controller/files/kubectl_wrapper.sh" | nindent 8 }}
dest: /usr/local/bin/kubectl
mode: +x
- name: "Install helm 3"
unarchive:
extra_opts:
- linux-amd64/helm
- --strip-components=1
src: https://get.helm.sh/helm-v3.2.4-linux-amd64.tar.gz
remote_src: yes
dest: /usr/local/bin
# TODO: checksum
- name: "Install semver"
unarchive:
extra_opts:
- semver-tool-2.1.0/src
- --strip-components=2
src: https://github.com/fsaintjacques/semver-tool/archive/2.1.0.tar.gz
remote_src: yes
dest: /usr/local/bin
- name: "Install registry client"
get_url:
url: https://github.com/genuinetools/reg/releases/download/v0.16.0/reg-linux-amd64
dest: /usr/local/bin/reg
mode: +x
checksum: "sha256:0470b6707ac68fa89d0cd92c83df5932c9822df7176fcf02d131d75f74a36a19"
- name: "Shell comfort: inputrc"
copy:
content: |
{{- .Files.Get "deckhouse-controller/files/inputrc" | nindent 8 }}
dest: /etc/inputrc
- name: "Shell comfort: bashrc"
copy:
content: |
{{- .Files.Get "deckhouse-controller/files/bashrc" | nindent 8 }}
dest: /etc/bashrc
- name: "Shell comfort: add bashrc for root"
shell: ln -s /etc/bashrc /root/.bashrc
- name: "Shell comfort: add bashrc for nobody"
shell: ln -s /etc/bashrc /.bashrc
- name: "Shell comfort: vimrc.local"
copy:
content: |
{{- .Files.Get "deckhouse-controller/files/vimrc.local" | nindent 8 }}
dest: /etc/vim/vimrc.local
- raw: rm -rf /var/cache/apk/*
{{- end }}
image: common-base
from: {{ env "BASE_ALPINE" }}
ansible:
beforeInstall:
- apk: update_cache=yes
- name: "Install dependencies"
apk:
name:
- bash
- bash-completion
- ca-certificates
- curl
- pwgen
- bc
- grep
- tar
- unzip
- coreutils
- util-linux
- sed
- gawk
- busybox-extras
- vim
- tini
{{- include "base components" . }}
---
image: base-for-go
from: {{ env "BASE_GOLANG_16_ALPINE" }}
ansible:
beforeInstall:
- name: "Install dependencies"
apk:
name:
- bash
- bash-completion
- ca-certificates
- curl
- pwgen
- bc
- grep
- tar
- unzip
- coreutils
- util-linux
- sed
- gawk
- busybox-extras
- vim
- tini
- git
- build-base
- libstdc++
- libgcc
- libcurl
- binutils
- binutils-dev
- elfutils-dev
{{- include "base components" . }}
docker:
ENV:
PATH: /usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/go/bin
---
image: dev-prebuild
fromImage: common-base
fromCacheVersion: 2020-05-08.1
git:
- add: /
to: /deckhouse
includePaths:
- candi
- modules
- global-hooks
- shell_lib.sh
- shell_lib
- deckhouse-controller/entrypoint.sh
- jq_lib
- helm_lib
excludePaths:
- docs
- modules/*/docs
- modules/*/README.md
- modules/*/images
- modules/*/hooks/**/*.go
- modules/*/template_tests
- modules/*/.namespace
- modules/*/values_matrix_test.yaml
- global-hooks/**/*.go
- candi/cloud-providers/*/layouts
- candi/cloud-providers/*/terraform-modules
- url: https://github.com/flant/shell-operator
tag: v1.0.1
add: /frameworks/shell
to: /deckhouse/shell-operator/frameworks/shell
{{ .Files.Get (printf "tools/build_includes/modules-with-exclude-%s.yaml" .Env) }}
{{ .Files.Get (printf "tools/build_includes/candi-%s.yaml" .Env) }}
import:
- artifact: deckhouse-controller
add: /out/deckhouse-controller
to: /usr/bin/deckhouse-controller
after: setup
- artifact: jq
add: /usr/bin/jq
to: /usr/bin/jq
after: setup
mount:
- fromPath: ~/go-pkg-cache
to: /go/pkg
ansible:
setup:
{{- range $key := list "default" "managed" "minimal" }}
- name: "Add bundle {{ $key }}"
copy:
content: |
{{- $.Files.Get (printf "modules/values-%s.yaml" $key ) | nindent 8 }}
{{- if eq $.Env "EE" }}
{{- $.Files.Get (printf "ee/modules/values-%s.yaml" $key ) | nindent 8 }}
{{- end }}
{{- if eq $.Env "FE" }}
{{- $.Files.Get (printf "ee/modules/values-%s.yaml" $key ) | nindent 8 }}
{{- $.Files.Get (printf "ee/fe/modules/values-%s.yaml" $key ) | nindent 8 }}
{{- end }}
dest: /deckhouse/modules/values-{{ $key }}.yaml
{{- end }}
- name: "Add version info"
copy:
content: |
{{- env "CI_COMMIT_TAG" | default "dev" | nindent 8}}
dest: /deckhouse/version
- name: "Add edition info"
copy:
content: |
{{- env "WERF_ENV" | default "unknown" | nindent 8}}
dest: /deckhouse/edition
# Because of https://github.com/flant/werf/issues/1741 just make symlink for the entry point
- name: "Make symlink for deckhouse entrypoint in the right location"
shell: ln -s /deckhouse/deckhouse-controller/entrypoint.sh /deckhouse/deckhouse
- name: "Run deckhouse from nobody"
file:
path: /deckhouse/
state: directory
recurse: yes
owner: 65534
group: 65534
docker:
ENV:
MODULES_DIR: /deckhouse/modules
GLOBAL_HOOKS_DIR: /deckhouse/global-hooks
---
image: tests-prebuild
fromImage: base-for-go
fromCacheVersion: "20210413"
git:
- add: /
to: /deckhouse
stageDependencies:
install:
- go.mod
- go.sum
includePaths:
- deckhouse-controller
- dhctl
- candi
- modules
- global-hooks
- go_lib
- shell_lib.sh
- shell_lib
- jq_lib
- helm_lib
- testing
- go.mod
- go.sum
excludePaths:
- docs
- modules/*/docs
- modules/*/README.md
- modules/*/images
- modules/*/webhooks
- modules/0[1-9][1-9]-*/crds # we need here only the 000-common/crds here
- modules/[1-9][0-9][0-9]-*/crds
- candi/cloud-providers/*/layouts
- candi/cloud-providers/*/terraform-modules
- url: https://github.com/flant/shell-operator
tag: v1.0.1
add: /frameworks/shell
to: /deckhouse/shell-operator/frameworks/shell
{{ .Files.Get (printf "tools/build_includes/modules-%s.yaml" .Env) }}
{{ .Files.Get (printf "tools/build_includes/candi-%s.yaml" .Env) }}
import:
- artifact: deckhouse-controller
add: /out/deckhouse-controller
to: /usr/bin/deckhouse-controller
after: setup
- artifact: libjq
add: /libjq
to: /libjq
after: setup
- artifact: jq
add: /usr/bin/jq
to: /usr/bin/jq
after: setup
mount:
- fromPath: ~/go-pkg-cache
to: /go/pkg
ansible:
install:
- name: "Install dumb-init"
apk:
name:
- dumb-init
- name: "Install ginkgo"
command: go get github.com/onsi/ginkgo/ginkgo
- name: "Install dlv"
command: go get github.com/go-delve/delve/cmd/dlv
- name: "Install GolangCI linter"
shell: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
| sh -s -- -b $(go env GOPATH)/bin v1.46.2
- raw: rm -rf /var/cache/apk/*
setup:
- name: "Migrate ee/fe internal packages imports"
shell: |
find /deckhouse/modules/* -type f -name '*.go' -exec sed -E -i 's|github.com/deckhouse/deckhouse/ee/modules|github.com/deckhouse/deckhouse/modules|g' {} +
find /deckhouse/modules/* -type f -name '*.go' -exec sed -E -i 's|github.com/deckhouse/deckhouse/ee/fe/modules|github.com/deckhouse/deckhouse/modules|g' {} +
docker:
ENV:
ADDON_OPERATOR_NAMESPACE: tests
DECKHOUSE_POD: tests
MODULES_DIR: /deckhouse/modules
GLOBAL_HOOKS_DIR: /deckhouse/global-hooks
CGO_CFLAGS: "-I/libjq/include"
CGO_LDFLAGS: "-L/libjq/lib"
---
artifact: deckhouse-controller
fromImage: base-for-go
fromCacheVersion: "20210413"
git:
- add: /
to: /deckhouse
includePaths:
- dhctl
- deckhouse-controller
- global-hooks/**/*.go
- go_lib/**/*.go
- modules/**/*.go
- go.mod
- go.sum
- tools
excludePaths:
- global-hooks/**/*_test.go
- modules/**/*_test.go
- modules/*/images
- dhctl/development
- deckhouse-controller/development
- deckhouse-controller/cmd/deckhouse-controller/register-go-hooks.go
stageDependencies:
setup:
- dhctl/go.mod
- dhctl/go.sum
- go.mod
- go.sum
- dhctl/**/*.go
- deckhouse-controller/**/*.go
- deckhouse-controller/go-build.sh
- global-hooks/**/*.go
- go_lib/**/*.go
- modules/**/*.go
{{ .Files.Get (printf "tools/build_includes/modules-with-dependencies-%s.yaml" .Env) }}
{{ .Files.Get (printf "tools/build_includes/candi-%s.yaml" .Env) }}
import:
- artifact: libjq
add: /libjq
to: /libjq
before: setup
mount:
- fromPath: ~/go-pkg-cache
to: /go/pkg
shell:
beforeInstall:
- apk add --no-cache git ca-certificates gcc libc-dev
- mkdir /deckhouse /out
setup:
# Migrate ee/fe internal packages imports
- find /deckhouse/modules/* -type f -name '*.go' -exec sed -E -i 's|github.com/deckhouse/deckhouse/ee/modules|github.com/deckhouse/deckhouse/modules|g' {} +
- find /deckhouse/modules/* -type f -name '*.go' -exec sed -E -i 's|github.com/deckhouse/deckhouse/ee/fe/modules|github.com/deckhouse/deckhouse/modules|g' {} +
- cd /deckhouse
# Generate hooks imports for particular edition (CE/EE/FE)
- go generate ./tools/register.go
# Go modules depend on `register-go-hooks.go` file, hence we cannot split downloading dependencies and building
# into separate phases.
- go mod download
- cd /deckhouse/deckhouse-controller
- ./go-build.sh /libjq
- mv deckhouse-controller /out
---
artifact: dhctl
fromImage: base-for-go
git:
- add: /dhctl
to: /dhctl
stageDependencies:
install:
- go.mod
- go.sum
setup:
- "**/*.go"
- Makefile
mount:
- fromPath: ~/go-pkg-cache
to: /go/pkg
ansible:
beforeInstall:
- apk:
name: git,ca-certificates,make
update_cache: yes
- command: rm -rf /var/cache/apk/*
install:
- shell: go mod download
args:
chdir: /dhctl
setup:
- command: make build
args:
chdir: /dhctl
---
image: dhctl-tests
fromCacheVersion: "20220131"
fromImage: base-for-go
git:
- add: /
to: /deckhouse
includePaths:
- dhctl
- candi
excludePaths:
- candi/cloud-providers/*/layouts
- candi/cloud-providers/*/terraform-modules
mount:
- fromPath: ~/go-pkg-cache
to: /go/pkg
ansible:
beforeInstall:
- apk:
name: git,ca-certificates,curl,bash,make
update_cache: yes
- command: rm -rf /var/cache/apk/*
install:
- shell: make deps
args:
chdir: /deckhouse/dhctl
---
artifact: jq
from: {{ env "BASE_ALPINE" }}
fromCacheVersion: "20210527"
git:
- url: https://github.com/stedolan/jq
add: /
to: /src
commit: b6be13d5de6dd7d8aad5fd871eb6b0b30fc7d7f6
stageDependencies:
install:
- "**/*"
ansible:
install:
- apk:
name:
- oniguruma-dev
- automake
- autoconf
- libtool
- build-base
update_cache: yes
- raw: rm -rf /var/cache/apk/*
- shell: |
cd /src
autoreconf -fi
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--mandir=/usr/share/man \
--localstatedir=/var \
--disable-docs
make LDFLAGS=-all-static
make prefix=/usr install
---
artifact: libjq
from: {{ env "BASE_ALPINE" }}
fromCacheVersion: "20210527"
git:
- url: https://github.com/flant/libjq-go
tag: v1.6.2
add: /
to: /src
stageDependencies:
install:
- "scripts/**"
setup:
- "modules/**"
ansible:
install:
- shell: /src/scripts/install-libjq-dependencies-alpine.sh
- raw: rm -rf /var/cache/apk/*
setup:
- shell: /src/scripts/build-libjq-static.sh /src /libjq
---
image: dev/install
from: {{ env "BASE_ALPINE" }}
git:
- add: /
to: /deckhouse
includePaths:
- candi
{{ .Files.Get (printf "tools/build_includes/candi-%s.yaml" .Env) }}
import:
- artifact: dhctl
add: /dhctl/bin/dhctl
to: /usr/bin/dhctl
after: setup
- artifact: terraform # from modules/040-terraform-manager/images/terraform-manager-base/werf.inc.yaml
add: /terraform/terraform
to: /bin/terraform
before: setup
- artifact: terraform # from modules/040-terraform-manager/images/terraform-manager-base/werf.inc.yaml
add: /root/.terraformrc
to: /etc/terraformrc
before: setup
- artifact: terraform-provider-aws # from modules/040-terraform-manager/images/terraform-manager-aws/werf.inc.yaml
add: /terraform-provider-aws
to: /usr/local/share/terraform/plugins/registry.terraform.io/{{ env "TF_AWS_NAMESPACE" }}/{{ env "TF_AWS_TYPE" }}/{{ env "TF_AWS_VERSION" }}/linux_amd64
before: setup
- artifact: terraform-provider-azure # from modules/040-terraform-manager/images/terraform-manager-azure/werf.inc.yaml
add: /terraform-provider-azure
to: /usr/local/share/terraform/plugins/registry.terraform.io/{{ env "TF_AZURE_NAMESPACE" }}/{{ env "TF_AZURE_TYPE" }}/{{ env "TF_AZURE_VERSION" }}/linux_amd64
before: setup
- artifact: terraform-provider-gcp # from modules/040-terraform-manager/images/terraform-manager-gcp/werf.inc.yaml
add: /terraform-provider-gcp/terraform-provider-gcp
to: /usr/local/share/terraform/plugins/registry.terraform.io/{{ env "TF_GCP_NAMESPACE" }}/{{ env "TF_GCP_TYPE" }}/{{ env "TF_GCP_VERSION" }}/linux_amd64/terraform-provider-google
after: setup
- artifact: terraform-provider-yandex # from modules/040-terraform-manager/images/terraform-manager-yandex/werf.inc.yaml
add: /terraform-provider-yandex
to: /usr/local/share/terraform/plugins/registry.terraform.io/{{ env "TF_YANDEX_NAMESPACE" }}/{{ env "TF_YANDEX_TYPE" }}/{{ env "TF_YANDEX_VERSION" }}/linux_amd64
before: setup
{{- if ne .Env "CE" }}
- artifact: terraform-provider-openstack # from ee/modules/040-terraform-manager/images/terraform-manager-openstack/werf.inc.yaml
add: /terraform-provider-openstack
to: /usr/local/share/terraform/plugins/registry.terraform.io/{{ env "TF_OPENSTACK_NAMESPACE" }}/{{ env "TF_OPENSTACK_TYPE" }}/{{ env "TF_OPENSTACK_VERSION" }}/linux_amd64
before: setup
- artifact: terraform-provider-vsphere # from modules/040-terraform-manager/images/terraform-manager-vsphere/werf.inc.yaml
add: /terraform-provider-vsphere/terraform-provider-vsphere
to: /usr/local/share/terraform/plugins/registry.terraform.io/{{ env "TF_VSPHERE_NAMESPACE" }}/{{ env "TF_VSPHERE_TYPE" }}/{{ env "TF_VSPHERE_VERSION" }}/linux_amd64/terraform-provider-vsphere
after: setup
{{- end }}
- image: images-tags
add: /images_tags.json
to: /deckhouse/candi/images_tags.json
after: setup
docker:
ENV:
EDITOR: vim
TF_CLI_CONFIG_FILE: /etc/terraformrc
shell:
beforeInstall:
- "apk update && apk add openssh-client gettext bash bash-completion coreutils util-linux sed gawk grep ca-certificates vim"
- "rm -rf /var/cache/apk/*"
setup:
- |
cat <<"EOD" > /etc/inputrc
{{- .Files.Get "deckhouse-controller/files/inputrc" | nindent 4 }}
EOD
cat <<"EOD" > /etc/bashrc
PS1='\[\033[01;30m\][deckhouse]\[\033[00m\] \[\033[01;33m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
source /etc/profile.d/bash_completion.sh
EOD
ln -s /etc/bashrc /root/.bashrc
ln -s /etc/bashrc /.bashrc
cat <<"EOD" > /etc/vim/vimrc.local
{{- .Files.Get "deckhouse-controller/files/vimrc.local" | nindent 4 }}
EOD
echo 'eval "$(dhctl --completion-script-bash)"' >> /etc/bashrc
---
image: release-channel-version
from: spotify/scratch
shell:
install:
- |
version="{{ env "CI_COMMIT_REF_NAME" }}"
canary='{{ .Files.Get "canary.json" | fromJson | toJson }}'
requirements='{{ .Files.Get "requirements.json" | fromJson | toJson }}'
json="{\"version\": \"${version}\", \"canary\": ${canary}, \"requirements\": ${requirements}}"
echo "$json" > /version.json
# changelog exists only for tags, we have to skip it for branches
{{- $changelog := index (.Files.Glob "CHANGELOG/CHANGELOG-*") (printf "CHANGELOG/CHANGELOG-%s.yml" (env "CI_COMMIT_REF_NAME")) }}
{{ if $changelog }}
/.werf/stapel/embedded/bin/cat <<EOF > /changelog.yaml
{{ $changelog | nindent 4 }}
EOF
{{ end }}
# modules_images
{{- define "module_image_template" }}
{{- if eq .ImageInstructionType "Dockerfile" }}
---
image: {{ .ModuleName }}/{{ .ImageName }}
context: {{ .ModulePath }}modules/{{ .ModulePriority }}-{{ .ModuleName }}/images/{{ .ImageName }}
dockerfile: Dockerfile
args:
BASE_ALPINE: {{ env "BASE_ALPINE" }}
BASE_ALPINE_3_15: {{ env "BASE_ALPINE_3_15" }}
BASE_DEBIAN: {{ env "BASE_DEBIAN" }}
BASE_RUST: {{ env "BASE_RUST" }}
BASE_DEBIAN_BULLSEYE: {{ env "BASE_DEBIAN_BULLSEYE" }}
BASE_GOLANG_ALPINE: {{ env "BASE_GOLANG_ALPINE" }}
BASE_GOLANG_16_ALPINE: {{ env "BASE_GOLANG_16_ALPINE" }}
BASE_GOLANG_17_ALPINE: {{ env "BASE_GOLANG_17_ALPINE" }}
BASE_GOLANG_BUSTER: {{ env "BASE_GOLANG_BUSTER" }}
BASE_GOLANG_16_BUSTER: {{ env "BASE_GOLANG_16_BUSTER" }}
BASE_GOLANG_17_BUSTER: {{ env "BASE_GOLANG_17_BUSTER" }}
BASE_GOLANG_18_BULLSEYE: {{ env "BASE_GOLANG_18_BULLSEYE" }}
BASE_NGINX_ALPINE: {{ env "BASE_NGINX_ALPINE" }}
BASE_NODE_16_ALPINE: {{ env "BASE_NODE_16_ALPINE" }}
BASE_PYTHON_ALPINE: {{ env "BASE_PYTHON_ALPINE" }}
BASE_SHELL_OPERATOR: {{ env "BASE_SHELL_OPERATOR" }}
BASE_UBUNTU: {{ env "BASE_UBUNTU" }}
BASE_JEKYLL: {{ env "BASE_JEKYLL" }}
{{- else }}
{{ tpl .ImageBuildData . }}
{{- end }}
{{- end }}
{{- $Root := . }}
{{- $CandiVersionMap := .Files.Get "candi/version_map.yml" | fromYaml }}
{{- $ModulesImagesIDList := list }}
# Collect EE and FE images if desired
{{ $ModulesImagesBuildFiles := .Files.Glob "modules/*/images/*/{Dockerfile,werf.inc.yaml}" }}
{{- if eq .Env "EE" }}
{{ $ModulesImagesBuildFiles = merge $ModulesImagesBuildFiles (.Files.Glob "ee/modules/*/images/*/{Dockerfile,werf.inc.yaml}") }}
{{- end }}
{{- if eq .Env "FE" }}
{{ $ModulesImagesBuildFiles = merge $ModulesImagesBuildFiles (.Files.Glob "ee/modules/*/images/*/{Dockerfile,werf.inc.yaml}") }}
{{ $ModulesImagesBuildFiles = merge $ModulesImagesBuildFiles (.Files.Glob "ee/fe/modules/*/images/*/{Dockerfile,werf.inc.yaml}") }}
{{- end }}
{{- range $path, $content := $ModulesImagesBuildFiles }}
{{- $ctx := dict }}
{{- if regexMatch "/werf.inc.yaml$" $path }}
{{- $_ := set $ctx "ImageInstructionType" "Stapel" }}
{{- else }}
{{- $_ := set $ctx "ImageInstructionType" "Dockerfile" }}
{{- end }}
{{- $ImageData := regexReplaceAll "^(.*)modules/([0-9]+)-([a-z-]+)/images/([0-9a-z-_]+)/(Dockerfile|werf.inc.yaml)$" $path "${1}#${2}#${3}#${4}" | split "#" }}
{{- $_ := set $ctx "CandiVersionMap" $CandiVersionMap }}
{{- $_ := set $ctx "ModulePath" $ImageData._0 }}
{{- $_ := set $ctx "ModulePriority" $ImageData._1 }}
{{- $_ := set $ctx "ModuleName" $ImageData._2 }}
{{- $_ := set $ctx "ImageName" $ImageData._3 }}
{{- $_ := set $ctx "ImageBuildData" $content }}
{{- $_ := set $ctx "Files" $Root.Files }}
{{- $_ := set $ctx "Env" $Root.Env }}
---
{{ include "module_image_template" $ctx }}
{{- range $ImageYamlMainfest := regexSplit "\n?---[ \t]*\n" (include "module_image_template" $ctx) -1 }}
{{- $ImageManifest := $ImageYamlMainfest | fromYaml }}
{{- if $ImageManifest.image }}
{{- $ModulesImagesIDList = append $ModulesImagesIDList $ImageManifest.image }}
{{- end }}
{{- end }}
{{- end }}
---
image: images-tags
from: {{ env "BASE_ALPINE" }}
dependencies:
{{- range $ImageID := $ModulesImagesIDList }}
{{- $ModuleNameCamel := $ImageID | splitList "/" | first | camelcase | untitle }}
{{- $ImageNameCamel := $ImageID | splitList "/" | last | camelcase | untitle }}
- image: {{ $ImageID }}
before: setup
imports:
- type: ImageTag
targetEnv: MODULES_IMAGES_TAGS_{{ $ModuleNameCamel }}_{{ $ImageNameCamel }}
{{- end }}
import:
- artifact: jq
add: /usr/bin/jq
to: /usr/bin/jq
before: setup
shell:
setup:
- |
env | grep MODULES_IMAGES_TAGS | jq -Rn '
reduce inputs as $i (
{};
. * (
$i | ltrimstr("MODULES_IMAGES_TAGS_") | sub("=";"_") |
split("_") as [$moduleName, $imageName, $tag] |
{($moduleName): {($imageName): $tag}}
)
)
' > /images_tags.json
---
image: dev
fromImage: dev-prebuild
import:
- image: images-tags
add: /images_tags.json
to: /deckhouse/modules/images_tags.json
after: setup
---
image: tests
fromImage: tests-prebuild
import:
- image: images-tags
add: /images_tags.json
to: /deckhouse/modules/images_tags.json
after: setup