-
Notifications
You must be signed in to change notification settings - Fork 1
/
werf.yaml
161 lines (141 loc) · 4.3 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
project: virtualization
configVersion: 1
{{ $_ := set . "Images" dict }}
# Deckhouse Images
{{- $BaseImagesPath := "base-images/deckhouse_image_versions.yml" }}
{{ $baseImages := (.Files.Get $BaseImagesPath | fromYaml) }}
{{- range $k, $v := $baseImages }}
{{ $baseImagePath := (printf "%s%s" $baseImages.REGISTRY_PATH (trimSuffix "/" $v)) }}
{{- if ne $k "REGISTRY_PATH" }}
{{- $_ := set $.Images $k $baseImagePath }}
{{- end }}
{{- end }}
# Base Images
{{- $BaseVirtImagesPath := "base-images/image_versions.yml" }}
{{ $baseImages := (.Files.Get $BaseVirtImagesPath | fromYaml) }}
{{- range $k, $v := $baseImages }}
{{ $baseVirtImagePath := (printf "%s%s" $baseImages.REGISTRY_PATH (trimSuffix "/" $v)) }}
{{- if ne $k "REGISTRY_PATH" }}
{{- $_ := set $.Images $k $baseVirtImagePath }}
{{- end }}
{{- end }}
# Distroless altlinux Images
{{- $AltDistroVirtImagesPath := "base-images/alt_image_versions.yml" }}
{{ $baseImages := (.Files.Get $AltDistroVirtImagesPath | fromYaml) }}
{{- range $k, $v := $baseImages }}
{{ $altDistroVirtImagePath := (printf "%s%s" $baseImages.REGISTRY_PATH (trimSuffix "/" $v)) }}
{{- if ne $k "REGISTRY_PATH" }}
{{- $_ := set $.Images $k $altDistroVirtImagePath }}
{{- end }}
{{- end }}
# Source repo settings
{{- $_ := set . "SOURCE_REPO" (env "SOURCE_REPO" | default "https://github.com") }}
# Modules_images
{{- define "module_image_template" }}
{{- if eq .ImageInstructionType "Dockerfile" }}
---
image: images/{{ .ImageName }}
context: images/{{ .ImageName }}
dockerfile: Dockerfile
{{- else }}
{{ tpl .ImageBuildData . }}
{{- end }}
{{- end }}
{{- $Root := . }}
{{- $ImagesIDList := list }}
{{ $ImagesBuildFiles := .Files.Glob "images/*/{Dockerfile,werf.inc.yaml}" }}
{{- range $path, $content := $ImagesBuildFiles }}
{{- $ctx := dict }}
{{- if regexMatch "/werf.inc.yaml$" $path }}
{{- $_ := set $ctx "ImageInstructionType" "Stapel" }}
{{- else }}
{{- $_ := set $ctx "ImageInstructionType" "Dockerfile" }}
{{- end }}
{{- $ImageData := $path | split "/" }}
{{- $_ := set $ctx "ImageName" $ImageData._1 }}
{{- $_ := set $ctx "ImageBuildData" $content }}
{{- $_ := set $ctx "Images" $Root.Images }}
{{- $_ := set $ctx "SOURCE_REPO" $Root.SOURCE_REPO }}
{{- include "module_image_template" $ctx }}
{{- range $ImageYamlMainfest := regexSplit "\n?---[ \t]*\n" (include "module_image_template" $ctx) -1 }}
{{- $ImageManifest := $ImageYamlMainfest | fromYaml }}
{{- if $ImageManifest | dig "final" true }}
{{- if $ImageManifest.image }}
{{- $ImagesIDList = append $ImagesIDList $ImageManifest.image }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
---
image: images-digests
from: {{ .Images.BASE_ALPINE }}
dependencies:
{{- range $ImageID := $ImagesIDList }}
{{- $ImageNameCamel := $ImageID | splitList "/" | last | camelcase | untitle }}
- image: {{ $ImageID }}
before: setup
imports:
- type: ImageDigest
targetEnv: MODULE_IMAGE_DIGEST_{{ $ImageNameCamel }}
{{- end }}
shell:
beforeInstall:
- apk add --no-cache jq
setup:
- |
env | grep MODULE_IMAGE_DIGEST | jq -Rn '
reduce inputs as $i (
{};
. * (
$i | ltrimstr("MODULE_IMAGE_DIGEST_") | sub("=";"_") |
split("_") as [$imageName, $digest] |
{($imageName): $digest}
)
)
' > /images_digests.json
cat images_digests.json
---
image: python-dependencies
from: python:3.9-slim
fromCacheVersion: "2024-11-07.1"
git:
- add: /lib/python/requirements.txt
to: /requirements.txt
shell:
setup:
- pip3 install -r /requirements.txt -t /dist
---
image: bundle
from: {{ .Images.BASE_SCRATCH }}
fromCacheVersion: "2024-11-07.1"
import:
- image: images-digests
add: /images_digests.json
to: /images_digests.json
after: setup
- image: python-dependencies
add: /dist
to: /lib/python/dist
after: setup
git:
- add: /
to: /
includePaths:
- charts
- crds
- docs
- hooks
- openapi
- monitoring
- templates
- Chart.yaml
- .helmignore
excludePaths:
- hooks/lib/tests
- hooks/test*
---
image: release-channel-version
from: {{ .Images.BASE_SCRATCH }}
shell:
install:
- echo '{"version":"{{ env "MODULES_MODULE_TAG" }}"}' > version.json