Skip to content

Commit 624a9ec

Browse files
authored
Merge pull request #1078 from nginx-proxy/1049
fix: handle most recently created containers first
2 parents 3aced4b + cb69387 commit 624a9ec

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

app/letsencrypt_service_data.tmpl

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1+
#!/bin/bash
2+
# shellcheck disable=SC2034
13
LETSENCRYPT_CONTAINERS=(
2-
{{ range $hosts, $containers := groupBy $ "Env.LETSENCRYPT_HOST" }}
3-
{{ if trim $hosts }}
4-
{{ range $container := $containers }}
5-
{{ if parseBool (coalesce $container.Env.LETSENCRYPT_SINGLE_DOMAIN_CERTS "false") }}
6-
{{/* Explicit per-domain splitting of the certificate */}}
7-
{{ range $host := split $hosts "," }}
8-
{{ $host := trim $host }}
9-
{{- "\t"}}'{{ printf "%.12s" $container.ID }}_{{ sha1 $host }}'
10-
{{ end }}
11-
{{ else }}
12-
{{/* Default: multi-domain (SAN) certificate */}}
13-
{{- "\t"}}'{{ printf "%.12s" $container.ID }}'
14-
{{ end }}
4+
{{ $orderedContainers := sortObjectsByKeysDesc $ "Created" }}
5+
{{ range $_, $container := whereExist $orderedContainers "Env.LETSENCRYPT_HOST" }}
6+
{{ if trim $container.Env.LETSENCRYPT_HOST }}
7+
{{ if parseBool (coalesce $container.Env.LETSENCRYPT_SINGLE_DOMAIN_CERTS "false") }}
8+
{{/* Explicit per-domain splitting of the certificate */}}
9+
{{ range $host := split $container.Env.LETSENCRYPT_HOST "," }}
10+
{{ $host := trim $host }}
11+
{{- "\n " }}'{{ printf "%.12s" $container.ID }}_{{ sha1 $host }}' # {{ $container.Name }}, created at {{ $container.Created }}
1512
{{ end }}
13+
{{ else }}
14+
{{/* Default: multi-domain (SAN) certificate */}}
15+
{{- "\n " }}'{{ printf "%.12s" $container.ID }}' # {{ $container.Name }}, created at {{ $container.Created }}
1616
{{ end }}
1717
{{ end }}
18+
{{ end }}
1819
)
1920

2021
{{ range $hosts, $containers := groupBy $ "Env.LETSENCRYPT_HOST" }}
@@ -34,6 +35,7 @@ LETSENCRYPT_CONTAINERS=(
3435
{{ $PRE_HOOK := trim (coalesce $container.Env.ACME_PRE_HOOK "") }}
3536
{{ $POST_HOOK := trim (coalesce $container.Env.ACME_POST_HOOK "") }}
3637
{{ $cid := printf "%.12s" $container.ID }}
38+
{{- "\n" }}# Container {{ $cid }} ({{ $container.Name }})
3739
{{ if parseBool (coalesce $container.Env.LETSENCRYPT_SINGLE_DOMAIN_CERTS "false") }}
3840
{{/* Explicit per-domain splitting of the certificate */}}
3941
{{ range $host := split $hosts "," }}

0 commit comments

Comments
 (0)