Skip to content

Commit d7ac8da

Browse files
groupskyclaude
andcommitted
fix: improve nginx template container matching for docker-gen 0.16.x
Use multiple fallback methods to find the target nginx container: 1. Try docker-compose service label (most reliable) 2. Try container name with leading slash 3. Try container name without slash This ensures compatibility across different docker-gen versions and container naming schemes. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent 8b1b63d commit d7ac8da

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

config/ingressgen/templates/nginx.tmpl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
{{ $TargetContainer := where $ "Name" (printf "/%s" $.Env.TARGET_CONTAINER) | first }}
1+
{{ $TargetContainer := whereLabelValueMatches $ "com.docker.compose.service" "ingress" | first }}
2+
{{ if not $TargetContainer }}
3+
{{ $TargetContainer = where $ "Name" (printf "/%s" $.Env.TARGET_CONTAINER) | first }}
4+
{{ end }}
5+
{{ if not $TargetContainer }}
6+
{{ $TargetContainer = where $ "Name" $.Env.TARGET_CONTAINER | first }}
7+
{{ end }}
28

39
{{ $external_http_port := coalesce $.Env.HTTP_PORT "80" }}
410
{{ $external_https_port := coalesce $.Env.HTTPS_PORT "443" }}

0 commit comments

Comments
 (0)