-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwerf.yaml
125 lines (123 loc) · 3.16 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
project: virtualization
configVersion: 1
# modules_images
{{- define "module_image_template" }}
{{- if eq .ImageInstructionType "Dockerfile" }}
---
image: images/{{ .ImageName }}
context: images/{{ .ImageName }}
dockerfile: Dockerfile
{{- else }}
{{ tpl .ImageBuildData . }}
{{- end }}
{{- end }}
{{- $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 }}
{{- include "module_image_template" $ctx }}
{{- range $ImageYamlMainfest := regexSplit "\n?---[ \t]*\n" (include "module_image_template" $ctx) -1 }}
{{- $ImageManifest := $ImageYamlMainfest | fromYaml }}
{{- if $ImageManifest.image }}
{{- $ImagesIDList = append $ImagesIDList $ImageManifest.image }}
{{- end }}
{{- end }}
{{- end }}
---
image: images-digests
from: alpine:3.17
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-02-15.1"
git:
- add: /lib/python/requirements.txt
to: /requirements.txt
shell:
setup:
- pip3 install -r /requirements.txt -t /dist
---
image: bundle
from: spotify/scratch
fromCacheVersion: "2024-02-15.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
- templates
- Chart.yaml
- .helmignore
---
artifact: release-channel-version-artifact
from: alpine:3.17
git:
- add: /
to: /
includePaths:
- release.yaml
shell:
beforeInstall:
- apk add --no-cache curl
- curl -sfL https://github.com/mikefarah/yq/releases/download/2.4.1/yq_linux_amd64 --output /usr/local/bin/yq
- chmod +x /usr/local/bin/yq
install:
- |
version="{{ env "MODULES_MODULE_TAG" }}"
yq w /release.yaml version $version | yq r - -j > version.json
---
image: release-channel-version
from: spotify/scratch
import:
- artifact: release-channel-version-artifact
add: /
to: /
after: install
includePaths:
- version.json