1
+ {{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }}
2
+ {{ $scopedContainersString := "" }}
3
+
4
+ {{ range $hosts, $containers := groupBy $ "Env.LETSENCRYPT_HOST" }}
5
+ {{ if trim $hosts }}
6
+ {{ range $container := $containers }}
7
+ {{ $cid := printf "%.12s" $container.ID }}
8
+ {{ if $CurrentContainer.Env.NETWORK_SCOPE }}
9
+ {{ range $containerNetwork := $container.Networks }}
10
+ {{ if eq $CurrentContainer.Env.NETWORK_SCOPE $containerNetwork.Name }}
11
+ {{ $scopedContainersString = (printf "%s %s" $scopedContainersString $cid) }}
12
+ {{ end }}
13
+ {{ end }}
14
+ {{ else }}
15
+ {{ $scopedContainersString = (printf "%s %s" $scopedContainersString $cid) }}
16
+ {{ end }}
17
+ {{ end }}
18
+ {{ end }}
19
+ {{ end }}
20
+
21
+ {{ $scopedContainersSlice := split (trim $scopedContainersString) " " }}
22
+
1
23
LETSENCRYPT_CONTAINERS=(
2
24
{{ range $hosts, $containers := groupBy $ "Env.LETSENCRYPT_HOST" }}
3
25
{{ if trim $hosts }}
4
26
{{ range $container := $containers }}
5
- {{ if parseBool (coalesce $container.Env.LETSENCRYPT_SINGLE_DOMAIN_CERTS "false") }}
6
- {{ range $host := split $hosts "," }}
7
- {{ $host := trim $host }}
8
- '{{ printf "%.12s" $container.ID }}_{{ sha1 $host }}'
27
+ {{ $cid := printf "%.12s" $container.ID }}
28
+ {{ if intersect $scopedContainersSlice (split $cid " ") }}
29
+ {{ if parseBool (coalesce $container.Env.LETSENCRYPT_SINGLE_DOMAIN_CERTS "false") }}
30
+ {{ range $host := split $hosts "," }}
31
+ '{{ printf "%s_%s" $cid (sha1 (trim $host)) }}'
32
+ {{ end }}
33
+ {{ else }}
34
+ '{{ $cid }}'
9
35
{{ end }}
10
- {{ else }}
11
- '{{ printf "%.12s" $container.ID }}'
12
36
{{ end }}
13
37
{{ end }}
14
38
{{ end }}
@@ -19,26 +43,28 @@ LETSENCRYPT_CONTAINERS=(
19
43
{{ $hosts := trimSuffix "," $hosts }}
20
44
{{ range $container := $containers }}
21
45
{{ $cid := printf "%.12s" $container.ID }}
22
- {{ if parseBool (coalesce $container.Env.LETSENCRYPT_SINGLE_DOMAIN_CERTS "false") }}
23
- {{ range $host := split $hosts "," }}
24
- {{ $host := trim $host }}
25
- {{ $hostHash := sha1 $host }}
26
- LETSENCRYPT_{{ $cid }}_{{ $hostHash }}_HOST=('{{ $host }}')
27
- LETSENCRYPT_{{ $cid }}_{{ $hostHash }}_EMAIL="{{ $container.Env.LETSENCRYPT_EMAIL }}"
28
- LETSENCRYPT_{{ $cid }}_{{ $hostHash }}_KEYSIZE="{{ $container.Env.LETSENCRYPT_KEYSIZE }}"
29
- LETSENCRYPT_{{ $cid }}_{{ $hostHash }}_TEST="{{ $container.Env.LETSENCRYPT_TEST }}"
30
- LETSENCRYPT_{{ $cid }}_{{ $hostHash }}_ACCOUNT_ALIAS="{{ $container.Env.LETSENCRYPT_ACCOUNT_ALIAS }}"
31
- LETSENCRYPT_{{ $cid }}_{{ $hostHash }}_RESTART_CONTAINER="{{ $container.Env.LETSENCRYPT_RESTART_CONTAINER }}"
32
- LETSENCRYPT_{{ $cid }}_{{ $hostHash }}_MIN_VALIDITY="{{ $container.Env.LETSENCRYPT_MIN_VALIDITY }}"
46
+ {{ if intersect $scopedContainersSlice (split $cid " ") }}
47
+ {{ if parseBool (coalesce $container.Env.LETSENCRYPT_SINGLE_DOMAIN_CERTS "false") }}
48
+ {{ range $host := split $hosts "," }}
49
+ {{ $host := trim $host }}
50
+ {{ $hostHash := sha1 $host }}
51
+ LETSENCRYPT_{{ $cid }}_{{ $hostHash }}_HOST=('{{ $host }}')
52
+ LETSENCRYPT_{{ $cid }}_{{ $hostHash }}_EMAIL="{{ $container.Env.LETSENCRYPT_EMAIL }}"
53
+ LETSENCRYPT_{{ $cid }}_{{ $hostHash }}_KEYSIZE="{{ $container.Env.LETSENCRYPT_KEYSIZE }}"
54
+ LETSENCRYPT_{{ $cid }}_{{ $hostHash }}_TEST="{{ $container.Env.LETSENCRYPT_TEST }}"
55
+ LETSENCRYPT_{{ $cid }}_{{ $hostHash }}_ACCOUNT_ALIAS="{{ $container.Env.LETSENCRYPT_ACCOUNT_ALIAS }}"
56
+ LETSENCRYPT_{{ $cid }}_{{ $hostHash }}_RESTART_CONTAINER="{{ $container.Env.LETSENCRYPT_RESTART_CONTAINER }}"
57
+ LETSENCRYPT_{{ $cid }}_{{ $hostHash }}_MIN_VALIDITY="{{ $container.Env.LETSENCRYPT_MIN_VALIDITY }}"
58
+ {{ end }}
59
+ {{ else }}
60
+ LETSENCRYPT_{{ $cid }}_HOST=( {{ range $host := split $hosts "," }}{{ $host := trim $host }}'{{ $host }}' {{ end }})
61
+ LETSENCRYPT_{{ $cid }}_EMAIL="{{ $container.Env.LETSENCRYPT_EMAIL }}"
62
+ LETSENCRYPT_{{ $cid }}_KEYSIZE="{{ $container.Env.LETSENCRYPT_KEYSIZE }}"
63
+ LETSENCRYPT_{{ $cid }}_TEST="{{ $container.Env.LETSENCRYPT_TEST }}"
64
+ LETSENCRYPT_{{ $cid }}_ACCOUNT_ALIAS="{{ $container.Env.LETSENCRYPT_ACCOUNT_ALIAS }}"
65
+ LETSENCRYPT_{{ $cid }}_RESTART_CONTAINER="{{ $container.Env.LETSENCRYPT_RESTART_CONTAINER }}"
66
+ LETSENCRYPT_{{ $cid }}_MIN_VALIDITY="{{ $container.Env.LETSENCRYPT_MIN_VALIDITY }}"
33
67
{{ end }}
34
- {{ else }}
35
- LETSENCRYPT_{{ $cid }}_HOST=( {{ range $host := split $hosts "," }}{{ $host := trim $host }}'{{ $host }}' {{ end }})
36
- LETSENCRYPT_{{ $cid }}_EMAIL="{{ $container.Env.LETSENCRYPT_EMAIL }}"
37
- LETSENCRYPT_{{ $cid }}_KEYSIZE="{{ $container.Env.LETSENCRYPT_KEYSIZE }}"
38
- LETSENCRYPT_{{ $cid }}_TEST="{{ $container.Env.LETSENCRYPT_TEST }}"
39
- LETSENCRYPT_{{ $cid }}_ACCOUNT_ALIAS="{{ $container.Env.LETSENCRYPT_ACCOUNT_ALIAS }}"
40
- LETSENCRYPT_{{ $cid }}_RESTART_CONTAINER="{{ $container.Env.LETSENCRYPT_RESTART_CONTAINER }}"
41
- LETSENCRYPT_{{ $cid }}_MIN_VALIDITY="{{ $container.Env.LETSENCRYPT_MIN_VALIDITY }}"
42
68
{{ end }}
43
69
{{ end }}
44
70
{{ end }}
0 commit comments