forked from deckhouse/deckhouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwerf.yaml
1208 lines (1139 loc) · 36.6 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
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
project: deckhouse
configVersion: 1
gitWorktree:
forceShallowClone: true
cleanup:
disableGitHistoryBasedPolicy: {{ env "WERF_DISABLE_META_TAGS" "false" }}
---
{{- $_ := set . "DistroPackagesProxy" (env "DISTRO_PACKAGES_PROXY" "") }}
{{- $_ := set . "CargoProxy" (env "CARGO_PROXY" "") }}
# Templates for distro proxy for packages (deb,rpm,apk)
{{- define "alt packages proxy" }}
# Replace altlinux repos with our proxy
{{- if $.DistroPackagesProxy }}
- sed -i "s|ftp.altlinux.org/pub/distributions/ALTLinux|{{ $.DistroPackagesProxy }}/repository/ALT-Linux-APT-Repository|g" /etc/apt/sources.list.d/alt.list
{{- end }}
- export DEBIAN_FRONTEND=noninteractive
- apt-get update
{{- end }}
{{- define "debian packages proxy" }}
# Replace debian repos with our proxy
{{- if $.DistroPackagesProxy }}
- sed -i "s|http://deb.debian.org|http://{{ $.DistroPackagesProxy }}/repository|g" /etc/apt/sources.list
{{- end }}
- export DEBIAN_FRONTEND=noninteractive
- apt-get update
{{- end }}
{{- define "ubuntu packages proxy" }}
# Replace ubuntu repos with our proxy
{{- if $.DistroPackagesProxy }}
- sed -i 's|http://archive.ubuntu.com|http://{{ $.DistroPackagesProxy }}/repository/archive-ubuntu|g' /etc/apt/sources.list
- sed -i 's|http://security.ubuntu.com|http://{{ $.DistroPackagesProxy }}/repository/security-ubuntu|g' /etc/apt/sources.list
{{- end }}
- export DEBIAN_FRONTEND=noninteractive
- apt-get update
{{- end }}
{{- define "alpine packages proxy" }}
# Replace alpine repos with our proxy
{{- if $.DistroPackagesProxy }}
- sed -i 's|https://dl-cdn.alpinelinux.org|http://{{ $.DistroPackagesProxy }}/repository|g' /etc/apk/repositories
{{- end }}
- apk update
{{- end }}
{{- define "node packages proxy" }}
{{- if $.DistroPackagesProxy }}
- npm config set registry http://{{ $.DistroPackagesProxy }}/repository/npmjs/
{{- end }}
{{- end }}
{{- define "pypi proxy" }}
{{- if $.DistroPackagesProxy }}
- |
cat <<"EOD" > /etc/pip.conf
[global]
index = http://{{ $.DistroPackagesProxy }}/repository/pypi-proxy/pypi
index-url = http://{{ $.DistroPackagesProxy }}/repository/pypi-proxy/simple
trusted-host = {{ $.DistroPackagesProxy }}
EOD
{{- end }}
{{- end }}
---
# revisions settings
{{- $editionsSettings := (.Files.Get "editions.yaml" | fromYaml) }}
{{- $_ := set . "Editions" $editionsSettings.editions }}
# checks redactions list
{{- if not $.Editions }}
{{ fail "Editions list is empty" }}
{{- end }}
{{- $editionsDict := dict }}
{{- range $_, $edition := $.Editions }}
{{- if not $edition.name }}
{{ fail printf "Editions name is empty" }}
{{- end }}
{{- $_ := set $editionsDict $edition.name "" }}
{{- end }}
{{- if not (hasKey $editionsDict .Env) }}
{{ fail (printf "Editions name not found %v" .Env) }}
{{- end }}
---
# Base Images
{{- $_ := set . "Images" (.Files.Get "candi/image_versions.yml" | fromYaml) }}
{{- range $k, $v := .Images }}
{{ $baseImagePath := (printf "%s%s" $.Images.REGISTRY_PATH (trimSuffix "/" $v)) }}
{{- if ne $k "REGISTRY_PATH" }}
{{- $_ := set $.Images $k $baseImagePath }}
{{- end }}
{{- end }}
---
# Version Map
{{- $versionMap := dict }}
{{- range $_, $edition := $.Editions }}
{{- if $edition.versionMapFile }}
{{- $versionMap = (merge $versionMap ($.Files.Get $edition.versionMapFile | fromYaml) )}}
{{- end }}
{{- if eq $.Env $edition.name }}
{{- break -}}
{{- end }}
{{- end }}
{{- $_ := set . "CandiVersionMap" $versionMap }}
---
# Terraform Versions
{{- $_ := set . "TF" (.Files.Get "candi/terraform_versions.yml" | fromYaml) }}
# Source repo settings
{{- $_ := set . "SOURCE_REPO" (env "SOURCE_REPO" | default "https://github.com") }}
# source repo with protected cloud providers
# use example.com as default because we can fail build without env
{{- $_ := set . "CLOUD_PROVIDERS_SOURCE_REPO" (env "CLOUD_PROVIDERS_SOURCE_REPO" | default "https://example.com") }}
# Source repo with observability private code
{{- $_ := set . "OBSERVABILITY_SOURCE_REPO" (env "OBSERVABILITY_SOURCE_REPO" | default "https://example.com") }}
# goproxy settings
{{- $_ := set . "GOPROXY" (env "GOPROXY") }}
---
artifact: jq
from: {{ $.Images.BASE_ALPINE_DEV }}
git:
- url: {{ .SOURCE_REPO }}/jqlang/jq
add: /
to: /src
commit: b6be13d5de6dd7d8aad5fd871eb6b0b30fc7d7f6
stageDependencies:
install:
- "**/*"
shell:
install:
- |
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: yq4-artifact
from: {{ $.Images.BASE_GOLANG_19_ALPINE_DEV }}
mount:
- fromPath: ~/go-pkg-cache
to: /go/pkg
shell:
install:
- export GOPROXY={{ .GOPROXY }}
- git clone {{ .SOURCE_REPO }}/mikefarah/yq --branch "v4.9.6"
- cd yq/
- CGO_ENABLED=0 GOOS=linux go build -ldflags '-s -w -extldflags "-static"' -o /usr/local/bin/yq
---
artifact: yq-artifact
from: {{ $.Images.BASE_GOLANG_19_ALPINE_DEV }}
mount:
- fromPath: ~/go-pkg-cache
to: /go/pkg
shell:
install:
- export GOPROXY={{ .GOPROXY }}
- git clone {{ .SOURCE_REPO }}/mikefarah/yq --branch v2.4.1
- cd yq/
- CGO_ENABLED=0 GOOS=linux go build -ldflags '-s -w -extldflags "-static"' -o /usr/local/bin/yq
---
artifact: semver-artifact
from: {{ $.Images.BASE_ALPINE_DEV }}
shell:
install:
- git clone {{ .SOURCE_REPO }}/fsaintjacques/semver-tool --branch 2.1.0
- cd /semver-tool/
- make install
---
artifact: tini-artifact
from: {{ $.Images.BASE_ALPINE_DEV }}
shell:
install:
- git clone {{ .SOURCE_REPO }}/krallin/tini --branch v0.19.0
- cd /tini/
- export CFLAGS="-DPR_SET_CHILD_SUBREAPER=36 -DPR_GET_CHILD_SUBREAPER=37"
- cmake . && make
---
{{- define "base components imports" }}
- artifact: tini-artifact
add: /tini/tini-static
to: /usr/bin/tini
before: setup
- artifact: semver-artifact
add: /usr/local/bin/semver
to: /usr/local/bin/semver
before: setup
{{- range $k8sVersion := tuple "1.27" "1.30"}}
{{- $image_version := printf "%s.%d" $k8sVersion (index $.CandiVersionMap "k8s" $k8sVersion "patch") | replace "." "-" }}
- artifact: common/kubernetes-artifact-{{ $image_version }}
add: /src/_output/bin/kubectl
to: /usr/local/bin/kubectl-{{ $k8sVersion }}
before: setup
{{- end }}
{{- end }}
{{- define "base components" }}
- |
# Install kubectl wrapper
cat <<"EOD" > /usr/local/bin/kubectl
{{- .Files.Get "deckhouse-controller/files/kubectl_wrapper.sh" | nindent 2 }}
EOD
chmod +x /usr/local/bin/kubectl
# Shell comfort: inputrc
cat <<"EOD" > /etc/inputrc
{{- .Files.Get "deckhouse-controller/files/inputrc" | nindent 2 }}
EOD
# Shell comfort: bashrc
cat <<"EOD" > /etc/bashrc
{{- .Files.Get "deckhouse-controller/files/bashrc" | nindent 2 }}
EOD
# Shell comfort: add bashrc for root
rm -f /root/.bashrc
ln -s /etc/bashrc /root/.bashrc
# Shell comfort: add bashrc for nobody
rm -f /.bashrc
ln -s /etc/bashrc /.bashrc
# Shell comfort: create /etc/vim
mkdir -p /etc/vim/
# Shell comfort: vimrc.local
cat <<"EOD" > /etc/vim/vimrc.local
{{- .Files.Get "deckhouse-controller/files/vimrc.local" | nindent 2 }}
EOD
{{- end }}
image: common-base
from: {{ .Images.BASE_ALT }}
import:
- artifact: dev-alt-artifact
add: /
to: /
before: setup
includePaths:
- lib64/libz.so*
- lib64/libexpat.so*
- lib64/libssl.so.*
- lib64/libcrypto.so.*
- etc/pki
- usr/share/ca-certificates/ca-bundle.crt
- usr/bin/python3
- usr/bin/python3.9
- usr/lib/python3
- usr/lib64/python3
- usr/lib64/python3.9
- usr/lib64/libffi.so*
- usr/share/vim
- etc/vim
- etc/bash_completion.d
- etc/bashrc.d/bash_completion.sh
- usr/share/bash-completion
- usr/bin/vim-console
{{- include "base components imports" . }}
- image: common/distroless
add: /etc/ssl
to: /etc/ssl
before: setup
- artifact: registrypackages/d8-curl-artifact-8-2-1
add: /d8-curl
to: /usr/bin/curl
before: setup
shell:
beforeInstall:
{{- include "base components" . | nindent 2 }}
---
image: base-for-go
from: {{ .Images.BASE_ALT_DEV }}
import:
{{- include "base components imports" . }}
shell:
beforeInstall:
{{/* TODO: Move it to the dev image */}}
- rm -rf /usr/local/go
- curl -sSfL https://go.dev/dl/go1.22.2.linux-amd64.tar.gz -o - | tar -C /usr/local -zxvf -
{{- include "base components" . | nindent 2 }}
---
{{- define "exclude_modules_dir_from_images" }}
- docs
- modules/*/docs
- modules/*/README.md
- modules/*/images
- modules/*/hooks/**/*.go
- modules/*/template_tests
- modules/*/.namespace
- modules/*/values_matrix_test.yaml
- modules/*/apis/**/*.go
- modules/*/requirements/**/*.go
- modules/*/settings-conversion/**/*.go
- modules/*/hack/**/*.go
- global-hooks/**/*.go
- candi/cloud-providers/*/layouts
- candi/cloud-providers/*/terraform-modules
- '**/testdata'
{{- end}}
---
artifact: dev-alt-artifact
from: {{ .Images.BASE_ALT_DEV }}
shell:
install:
- /binary_replace.sh -i "/usr/bin/envsubst" -o /relocate
---
artifact: golangci-lint-artifact
from: {{ $.Images.BASE_GOLANG_22_ALPINE_DEV }}
shell:
install:
- export GOPROXY={{ .GOPROXY }}
- git clone --depth 1 {{ .SOURCE_REPO }}/golangci/golangci-lint --branch v1.58.0
- cd golangci-lint/
- CGO_ENABLED=0 GOOS=linux go build -ldflags '-s -w -extldflags "-static"' -o /usr/local/bin/golangci-lint cmd/golangci-lint/main.go
---
image: dev-prebuild
fromImage: common-base
git:
- add: /
to: /deckhouse
stageDependencies:
setup:
- '**/*'
includePaths:
- candi
- modules
- global-hooks
- shell_lib.sh
- shell_lib
- deckhouse-controller/entrypoint.sh
- deckhouse-controller/crds/*.yaml
- jq_lib
- helm_lib
- python_lib
excludePaths:
{{- include "exclude_modules_dir_from_images" . | nindent 2}}
{{ .Files.Get (printf "tools/build_includes/modules-excluded-%s.yaml" .Env) | nindent 2}}
- url: {{ .SOURCE_REPO }}/flant/shell-operator
tag: v1.4.10
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
- artifact: version-map-artifact
add: /version_map_{{ $.Env }}.yml
to: /deckhouse/candi/version_map.yml
after: setup
mount:
- fromPath: ~/go-pkg-cache
to: /go/pkg
shell:
setup:
- |
{{- range $key := list "default" "managed" "minimal" }}
# Add bundle {{ $key }}
cat <<"EOD" > /deckhouse/modules/values-{{ $key }}.yaml
{{- range $_, $edition := $.Editions }}
{{- $.Files.Get (printf "%s/values-%s.yaml" $edition.modulesDir $key ) | nindent 4 }}
{{- if eq $.Env $edition.name }}
{{- break -}}
{{- end }}
{{- end }}
EOD
{{- end }}
# Add version info
cat <<"EOD" > /deckhouse/version
{{- env "CI_COMMIT_TAG" | default "dev" | nindent 4 }}
EOD
# Add edition info
cat <<"EOD" > /deckhouse/edition
{{- .Env | default "unknown" | nindent 4 }}
EOD
# Override deckhouse entrypoint to use tini as supervisor
cat <<"EOD" > /deckhouse/deckhouse
#!/bin/bash
exec tini -- /deckhouse/deckhouse-controller/entrypoint.sh
EOD
chmod +x /deckhouse/deckhouse
# Create symlink to grant entrypoint.sh write permission
ln -fs /tmp/values.yaml /deckhouse/modules/values.yaml
# Create deckhouse group
groupadd -g 64535 deckhouse
# Create deckhouse user
useradd -d / -u 64535 -g deckhouse -s /sbin/nologin deckhouse
# Run deckhouse from dedicated user
chown deckhouse:deckhouse -R /deckhouse
# Create symlink to vim-console
ln -fs /usr/bin/vim-console /usr/bin/vim
ln -fs /usr/bin/vim-console /usr/bin/vi
docker:
ENV:
MODULES_DIR: /deckhouse/modules
GLOBAL_HOOKS_DIR: /deckhouse/global-hooks
PYTHONPATH: /deckhouse/python_lib
LC_ALL: C
---
image: tests-prebuild
fromImage: base-for-go
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
- editions.yaml
excludePaths:
{{ .Files.Get (printf "tools/build_includes/modules-excluded-%s.yaml" .Env) | nindent 2}}
- 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
- 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.1.3
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: jq
add: /usr/bin/jq
to: /usr/bin/jq
after: setup
- artifact: version-map-artifact
add: /version_map_{{ $.Env }}.yml
to: /deckhouse/candi/version_map.yml
after: setup
- artifact: golangci-lint-artifact
add: /usr/local/bin/golangci-lint
to: /usr/local/bin/golangci-lint
before: install
mount:
- fromPath: ~/go-pkg-cache
to: /go/pkg
shell:
install:
- go install github.com/onsi/ginkgo/ginkgo@latest
- go install github.com/go-delve/delve/cmd/dlv@latest
setup:
{{- range $_, $edition := $.Editions }}
{{- if not $edition.skipFixingImports }}
- find /deckhouse/modules/* -type f -name '*.go' -exec sed -E -i 's|github.com/deckhouse/deckhouse/{{ $edition.modulesDir }}|github.com/deckhouse/deckhouse/modules|g' {} +
{{- end }}
{{- end }}
docker:
ENV:
ADDON_OPERATOR_NAMESPACE: tests
DECKHOUSE_POD: tests
MODULES_DIR: /deckhouse/modules
GLOBAL_HOOKS_DIR: /deckhouse/global-hooks
PATH: ${PATH}:/usr/local/go/bin:/root/go/bin
---
artifact: deckhouse-controller
fromImage: base-for-go
git:
- add: /
to: /deckhouse
includePaths:
- dhctl
- deckhouse-controller
- global-hooks/**/*.go
- go_lib/**/*.go
- modules/**/*.go
- ee/modules/021-cni-cilium/images/egress-gateway-agent/**/*.go
- ee/modules/021-cni-cilium/images/egress-gateway-agent/go.mod
- ee/modules/021-cni-cilium/images/egress-gateway-agent/go.sum
- go_lib/**/go.mod
- go_lib/**/go.sum
- go.mod
- go.sum
- tools
- editions.yaml
excludePaths:
{{ .Files.Get (printf "tools/build_includes/modules-excluded-%s.yaml" .Env) | nindent 4}}
- 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
- go_lib/**/go.mod
- go_lib/**/go.sum
- modules/**/*.go
- editions.yaml
{{ .Files.Get (printf "tools/build_includes/modules-with-dependencies-%s.yaml" .Env) }}
{{ .Files.Get (printf "tools/build_includes/candi-%s.yaml" .Env) }}
mount:
- fromPath: ~/go-pkg-cache
to: /go/pkg
shell:
beforeInstall:
- mkdir /deckhouse /out
setup:
# Migrate internal packages imports
{{- range $_, $edition := $.Editions }}
{{- if not $edition.skipFixingImports }}
- find /deckhouse/modules/* -type f -name '*.go' -exec sed -E -i 's|github.com/deckhouse/deckhouse/{{ $edition.modulesDir }}|github.com/deckhouse/deckhouse/modules|g' {} +
{{- end }}
{{- end }}
- cd /deckhouse
# Generate hooks imports for particular edition
- 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
- D8_VERSION={{- env "CI_COMMIT_TAG" | env "CI_COMMIT_REF_SLUG" | default "dev" }} ./go-build.sh
- mv deckhouse-controller /out
---
artifact: dhctl
fromImage: base-for-go
git:
- add: /dhctl
to: /dhctl
stageDependencies:
install:
- go.mod
- go.sum
setup:
- "**/*.go"
- Makefile
- add: /go_lib/registry-packages-proxy
to: /go_lib/registry-packages-proxy
stageDependencies:
install:
- go.mod
- go.sum
setup:
- "**/*.go"
mount:
- fromPath: ~/go-pkg-cache
to: /go/pkg
shell:
install:
- cd /dhctl && go mod download
setup:
- cd /dhctl && D8_VERSION={{- env "CI_COMMIT_TAG" | default "dev" }} make build
---
artifact: ssh-static
from: {{ .Images.BASE_ALPINE_DEV }}
shell:
install:
- mkdir /src
- cd /src
- git clone -b V_9_7_P1 --single-branch --depth=1 {{ $.SOURCE_REPO }}/openssh/openssh-portable .
- autoreconf
- ./configure LDFLAGS="-static $(LDFLAGS)" --prefix /ssh
- make install
---
image: dev/install
from: {{ .Images.BASE_ALT }}
git:
- add: /
to: /deckhouse
includePaths:
- candi
{{ .Files.Get (printf "tools/build_includes/candi-%s.yaml" .Env) }}
import:
- artifact: dhctl
add: /dhctl/bin/dhctl
to: /dhctl
after: setup
- image: dev-prebuild
add: /deckhouse
to: /deckhouse
includePaths:
- modules/*/openapi/config-values.yaml
- global-hooks/openapi/config-values.yaml
after: setup
- artifact: terraform # from modules/040-terraform-manager/images/terraform-manager-base/werf.inc.yaml
add: /terraform/terraform
to: /bin/terraform
before: setup
{{- range $_, $edition := $.Editions }}
{{- if $edition.terraformProviders }}
{{- range $_, $tfProvider := $edition.terraformProviders }}
{{- $tf := index $.TF $tfProvider }}
- artifact: {{ $tf.artifact }} # from modules/040-terraform-manager/images/terraform-manager-{PROVIDER}/werf.inc.yaml
add: /{{ $tf.artifactBinary }}
to: /plugins/registry.terraform.io/{{ $tf.namespace }}/{{ $tf.type }}/{{ $tf.version }}/linux_amd64/{{ $tf.destinationBinary }}
before: setup
{{- end }}
{{- end }}
{{- if eq $.Env $edition.name }}
{{- break -}}
{{- end }}
{{- end }}
- artifact: dev-alt-artifact
add: /relocate
to: /
before: setup
- artifact: ssh-static
add: /ssh/bin
to: /bin
before: setup
includePaths:
- ssh
- ssh-add
- ssh-agent
- scp
- image: images-digests
add: /images_digests.json
to: /deckhouse/candi/images_digests.json
after: setup
- artifact: version-map-artifact
add: /version_map_{{ $.Env }}.yml
to: /deckhouse/candi/version_map.yml
after: setup
- image: deckhouse-image-hash
add: /deckhouse_digest.txt
to: /deckhouse/image_digest
after: setup
- artifact: dev-alt-artifact
add: /
to: /
before: setup
includePaths:
- etc/pki
- usr/share/ca-certificates/ca-bundle.crt
- usr/share/vim
- etc/vim
- etc/bash_completion.d
- etc/bashrc.d/bash_completion.sh
- usr/share/bash-completion
- usr/bin/vim-console
docker:
ENV:
EDITOR: vim
shell:
setup:
- |
ln -fs /dhctl /usr/bin/dhctl
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/bashrc.d/bash_completion.sh
EOD
rm -f /root/.bashrc
ln -s /etc/bashrc /root/.bashrc
rm -f /.bashrc
ln -s /etc/bashrc /.bashrc
ln -fs /usr/bin/vim-console /usr/bin/vim
ln -fs /usr/bin/vim-console /usr/bin/vi
mkdir -p /etc/vim
cat <<"EOD" > /etc/vim/vimrc.local
{{- .Files.Get "deckhouse-controller/files/vimrc.local" | nindent 4 }}
EOD
echo 'eval "$(dhctl --completion-script-bash)"' >> /etc/bashrc
echo '{{- env "CI_COMMIT_TAG" | default "dev" }}' > /deckhouse/version
---
artifact: install-standalone-builder
from: {{ .Images.BASE_ALPINE }}
git:
- add: /
to: /image/deckhouse
includePaths:
- candi
{{ .Files.Get (printf "tools/build_includes/candi-%s.yaml" .Env) }}
import:
- artifact: dhctl
add: /dhctl/bin/dhctl
to: /image/dhctl
before: setup
- image: dev-prebuild
add: /deckhouse
to: /image/deckhouse
includePaths:
- modules/*/openapi/config-values.yaml
- global-hooks/openapi/config-values.yaml
before: setup
- artifact: terraform # from modules/040-terraform-manager/images/terraform-manager-base/werf.inc.yaml
add: /terraform/terraform
to: /image/bin/terraform
before: setup
{{- range $_, $edition := $.Editions }}
{{- if $edition.terraformProviders }}
{{- range $_, $tfProvider := $edition.terraformProviders }}
{{- $tf := index $.TF $tfProvider }}
- artifact: {{ $tf.artifact }} # from modules/040-terraform-manager/images/terraform-manager-{PROVIDER}/werf.inc.yaml
add: /{{ $tf.artifactBinary }}
to: /image/plugins/registry.terraform.io/{{ $tf.namespace }}/{{ $tf.type }}/{{ $tf.version }}/linux_amd64/{{ $tf.destinationBinary }}
before: setup
{{- end }}
{{- end }}
{{- if eq $.Env $edition.name }}
{{- break -}}
{{- end }}
{{- end }}
- image: images-digests
add: /images_digests.json
to: /image/deckhouse/candi/images_digests.json
before: setup
- artifact: version-map-artifact
add: /version_map_{{ $.Env }}.yml
to: /image/deckhouse/candi/version_map.yml
before: setup
- image: deckhouse-image-hash
add: /deckhouse_digest.txt
to: /image/deckhouse/image_digest
before: setup
- artifact: ssh-static
add: /ssh/bin
to: /image/bin
before: setup
includePaths:
- ssh
- ssh-add
- ssh-agent
- scp
shell:
setup:
- echo '{{- env "CI_COMMIT_TAG" | default "dev" }}' > /image/deckhouse/version
- cd /image
- tar -czf /dhctl-{{- env "CI_COMMIT_TAG" | default "dev" }}.x86_64.tar.gz *
---
image: dev/install-standalone
from: {{ .Images.BASE_SCRATCH }}
import:
- artifact: install-standalone-builder
add: /dhctl-{{- env "CI_COMMIT_TAG" | default "dev" }}.x86_64.tar.gz
to: /
before: setup
---
image: release-channel-version-prebuild
from: {{ .Images.BASE_ALPINE_DEV }}
dependencies:
- image: dev
before: setup
imports:
- type: ImageDigest
targetEnv: deckhouseImageDigest
import:
- artifact: yq-artifact
add: /usr/local/bin/yq
to: /usr/local/bin/yq
before: install
shell:
install:
- |
version="{{ env "CI_COMMIT_REF_NAME" }}"
yq w /deckhouse/release.yaml version $version digest $deckhouseImageDigest | yq r - -j > 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 }}
cat <<"EOF" > /changelog.yaml
{{ $changelog | nindent 6 }}
EOF
{{ end }}
git:
- add: /
to: /deckhouse
includePaths:
- release.yaml
---
image: release-channel-version
from: {{ .Images.BASE_SCRATCH }}
import:
- image: release-channel-version-prebuild
add: /
to: /
after: install
includePaths:
- version.json
- changelog.yaml
# 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: {{ .Images.BASE_ALPINE }}
BASE_ALPINE_DEV: {{ .Images.BASE_ALPINE_DEV }}
BASE_ALT: {{ .Images.BASE_ALT }}
BASE_ALT_DEV: {{ .Images.BASE_ALT_DEV }}
BASE_GOLANG_ALPINE: {{ .Images.BASE_GOLANG_ALPINE }}
BASE_GOLANG_ALPINE_DEV: {{ .Images.BASE_GOLANG_ALPINE_DEV }}
BASE_GOLANG_16_ALPINE: {{ .Images.BASE_GOLANG_16_ALPINE }}
BASE_GOLANG_16_ALPINE_DEV: {{ .Images.BASE_GOLANG_16_ALPINE_DEV }}
BASE_GOLANG_17_ALPINE: {{ .Images.BASE_GOLANG_17_ALPINE }}
BASE_GOLANG_17_ALPINE_DEV: {{ .Images.BASE_GOLANG_17_ALPINE_DEV }}
BASE_GOLANG_BUSTER: {{ .Images.BASE_GOLANG_BUSTER }}
BASE_GOLANG_BUSTER_DEV: {{ .Images.BASE_GOLANG_BUSTER_DEV }}
BASE_GOLANG_16_BUSTER: {{ .Images.BASE_GOLANG_16_BUSTER }}
BASE_GOLANG_17_BUSTER: {{ .Images.BASE_GOLANG_17_BUSTER }}
BASE_GOLANG_18_ALPINE: {{ .Images.BASE_GOLANG_18_ALPINE }}
BASE_GOLANG_18_ALPINE_DEV: {{ .Images.BASE_GOLANG_18_ALPINE_DEV }}
BASE_GOLANG_19_ALPINE: {{ .Images.BASE_GOLANG_19_ALPINE }}
BASE_GOLANG_19_ALPINE_DEV: {{ .Images.BASE_GOLANG_19_ALPINE_DEV }}
BASE_GOLANG_19_BULLSEYE: {{ .Images.BASE_GOLANG_19_BULLSEYE }}
BASE_GOLANG_19_BULLSEYE_DEV: {{ .Images.BASE_GOLANG_19_BULLSEYE_DEV }}
BASE_GOLANG_19_BUSTER: {{ .Images.BASE_GOLANG_19_BUSTER }}
BASE_GOLANG_20_ALPINE: {{ .Images.BASE_GOLANG_20_ALPINE }}
BASE_GOLANG_20_ALPINE_DEV: {{ .Images.BASE_GOLANG_20_ALPINE_DEV }}
BASE_GOLANG_20_BULLSEYE: {{ .Images.BASE_GOLANG_20_BULLSEYE }}
BASE_GOLANG_20_BULLSEYE_DEV: {{ .Images.BASE_GOLANG_20_BULLSEYE_DEV }}
BASE_GOLANG_20_BUSTER: {{ .Images.BASE_GOLANG_20_BUSTER }}
BASE_GOLANG_21_ALPINE: {{ .Images.BASE_GOLANG_21_ALPINE }}
BASE_GOLANG_21_ALPINE_DEV: {{ .Images.BASE_GOLANG_21_ALPINE_DEV }}
BASE_GOLANG_21_BULLSEYE: {{ .Images.BASE_GOLANG_21_BULLSEYE }}
BASE_GOLANG_21_BULLSEYE_DEV: {{ .Images.BASE_GOLANG_21_BULLSEYE_DEV }}
BASE_GOLANG_22_ALPINE: {{ .Images.BASE_GOLANG_22_ALPINE }}
BASE_GOLANG_22_ALPINE_DEV: {{ .Images.BASE_GOLANG_22_ALPINE_DEV }}
BASE_GOLANG_22_BULLSEYE: {{ .Images.BASE_GOLANG_22_BULLSEYE }}
BASE_NGINX_ALPINE: {{ .Images.BASE_NGINX_ALPINE }}
BASE_NGINX_ALPINE_DEV: {{ .Images.BASE_NGINX_ALPINE_DEV }}
BASE_NODE_16_ALPINE: {{ .Images.BASE_NODE_16_ALPINE }}
BASE_NODE_16_ALPINE_DEV: {{ .Images.BASE_NODE_16_ALPINE_DEV }}
BASE_PYTHON_ALPINE: {{ .Images.BASE_PYTHON_ALPINE }}
BASE_PYTHON_ALPINE_DEV: {{ .Images.BASE_PYTHON_ALPINE_DEV }}
BASE_UBUNTU: {{ .Images.BASE_UBUNTU }}
BASE_UBUNTU_BIONIC: {{ .Images.BASE_UBUNTU_BIONIC }}
BASE_UBUNTU_DEV: {{ .Images.BASE_UBUNTU_DEV }}
BASE_JEKYLL: {{ .Images.BASE_JEKYLL }}
BASE_SCRATCH: {{ .Images.BASE_SCRATCH }}
SOURCE_REPO: {{ .SOURCE_REPO }}
CLOUD_PROVIDERS_SOURCE_REPO: {{ .CLOUD_PROVIDERS_SOURCE_REPO }}
OBSERVABILITY_SOURCE_REPO: {{ .OBSERVABILITY_SOURCE_REPO }}
# proxies for various packages
GOPROXY: {{ .GOPROXY }}
{{- if not (has (list .ModuleName .ImageName | join "/") (list "common/distroless")) }}
dependencies:
- image: common/distroless
imports:
- type: ImageName
targetBuildArg: BASE_DISTROLESS
- image: common/iptables-wrapper
imports:
- type: ImageName
targetBuildArg: BASE_IPTABLES_WRAPPER
{{- end }}
{{- else }}
{{ tpl .ImageBuildData . }}
{{- end }}
{{- end }}
{{- $Root := . }}
{{- $ModulesImagesDigestList := list }}
{{- $ExcludedModulesDict := dict }}
# Collect images if desired for editions
{{- $ModulesImagesBuildFiles := dict }}
{{- range $_, $edition := $.Editions }}
{{- if not $edition.skipCollectImages }}
{{ $ModulesImagesBuildFiles = merge $ModulesImagesBuildFiles ($.Files.Glob (printf "%s/*/images/*/{Dockerfile,werf.inc.yaml}" $edition.modulesDir)) }}
{{- end }}
{{- if eq $.Env $edition.name }}
{{- if $edition.excludeModules }}
{{- range $_, $exludeModuleName := $edition.excludeModules }}
{{- $_ := set $ExcludedModulesDict (printf "%s" $exludeModuleName) "true" }}
{{- end }}
{{- end }}
{{- break -}}
{{- end }}
{{- 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-z0-9-]+)/images/([0-9a-z-_]+)/(Dockerfile|werf.inc.yaml)$" $path "${1}#${2}#${3}#${4}" | split "#" }}
{{- $moduleName := $ImageData._2 }}
# exclude modules and images from editions
{{- if hasKey $ExcludedModulesDict $moduleName }}
{{- continue -}}
{{- end }}
{{- $_ := set $ctx "CandiVersionMap" $.CandiVersionMap }}
{{- $_ := set $ctx "ModulePath" $ImageData._0 }}
{{- $_ := set $ctx "ModulePriority" $ImageData._1 }}
{{- $_ := set $ctx "ModuleName" $moduleName }}
{{- $_ := set $ctx "ImageName" $ImageData._3 }}
{{- $_ := set $ctx "ImageBuildData" $content }}
{{- $_ := set $ctx "Files" $Root.Files }}
{{- $_ := set $ctx "Env" $Root.Env }}
{{- $_ := set $ctx "Images" $Root.Images }}
{{- $_ := set $ctx "CandiVersionMap" $Root.CandiVersionMap }}
{{- $_ := set $ctx "TF" $Root.TF }}
{{- $_ := set $ctx "SOURCE_REPO" $Root.SOURCE_REPO }}
{{- $_ := set $ctx "CLOUD_PROVIDERS_SOURCE_REPO" $Root.CLOUD_PROVIDERS_SOURCE_REPO }}
{{- $_ := set $ctx "OBSERVABILITY_SOURCE_REPO" $Root.OBSERVABILITY_SOURCE_REPO }}
{{- $_ := set $ctx "GOPROXY" $Root.GOPROXY }}
{{- $_ := set $ctx "DistroPackagesProxy" $Root.DistroPackagesProxy }}
{{- $_ := set $ctx "CargoProxy" $Root.CargoProxy }}
---
{{ include "module_image_template" $ctx }}
{{- range $ImageYamlMainfest := regexSplit "\n?---[ \t]*\n" (include "module_image_template" $ctx) -1 }}
{{- $ImageManifest := $ImageYamlMainfest | fromYaml }}
{{- if $ImageManifest.image }}
{{- if ne $ImageManifest.final false }}
{{- $ModulesImagesDigestList = append $ModulesImagesDigestList $ImageManifest.image }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
---
image: images-digests
from: {{ .Images.BASE_ALPINE }}
dependencies:
{{- range $imageDigest := $ModulesImagesDigestList }}
{{- $ModuleNameCamel := $imageDigest | splitList "/" | first | camelcase | untitle }}
{{- $ImageDigestCamel := $imageDigest | splitList "/" | last | camelcase | untitle }}
- image: {{ $imageDigest }}
before: setup
imports:
- type: ImageDigest
targetEnv: MODULE_IMAGE_DIGEST_{{ $ModuleNameCamel }}_{{ $ImageDigestCamel }}
{{- end }}