-
Notifications
You must be signed in to change notification settings - Fork 75
/
render-dockerfiles.tmpl
34 lines (32 loc) · 1.62 KB
/
render-dockerfiles.tmpl
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
{{- range $version := .config.versions }}
{{- $minor := $version.caddy_version | regexp.Replace `([0-9]+\.[0-9]+).*$` `$1` }}
{{- $checksums := getChecksums "caddy" $version.caddy_version | json }}
{{- $xcaddy_checksums := getChecksums "xcaddy" $.config.xcaddy_config.version | json }}
{{- range $variant := $.config.variants }}
{{- $dir := filepath.Join $minor $variant.dir }}
{{- test.Assert (print "Expected " $dir " to be a directory") (file.IsDir $dir) }}
{{- if not (file.Exists (filepath.Join $dir ".skip")) }}
{{- $template := "dockerfile" }}
{{- if eq "builder" $variant.dir -}}
{{ $template = "builder-dockerfile" -}}
{{ end -}}
{{- if strings.HasPrefix "windows-builder" $variant.dir -}}
{{ $template = "windows-builder-dockerfile" -}}
{{- else if strings.HasPrefix "windows" $variant.dir -}}
{{ $template = "windows-dockerfile" -}}
{{ end -}}
{{- $base := file.Read (filepath.Join $dir "Dockerfile.base") }}
{{- $ctx := dict "base" $base "config" $version "xcaddy_config" $.config.xcaddy_config "checksums" $checksums "xcaddy_checksums" $xcaddy_checksums}}
{{- $outPath := filepath.Join $dir "Dockerfile" -}}
Rendering {{ $outPath }} with template {{ $template }}...{{ "\n" -}}
{{- tmpl.Exec $template $ctx | file.Write $outPath -}}
{{- if eq "builder" $variant.dir -}}
{{- $template = "caddy-builder" }}
{{- $ctx := dict "config" $version }}
{{- $outPath := filepath.Join $dir "caddy-builder.sh" -}}
Rendering {{ $outPath }} with template {{ $template }}...{{ "\n" -}}
{{- tmpl.Exec $template $ctx | file.Write $outPath -}}
{{ end -}}
{{ end -}}
{{- end }}
{{- end -}}