fix(port mapping,docker): fixed duplicate port mapping on hosts and incompatible docker options in compose
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
This commit is contained in:
@@ -178,7 +178,7 @@ services:
|
||||
ports:
|
||||
- name: "http"
|
||||
internal: 8000
|
||||
external: 8000
|
||||
external: 8001
|
||||
- name: sonarr
|
||||
vm:
|
||||
- docker-host00
|
||||
@@ -410,7 +410,7 @@ services:
|
||||
ports:
|
||||
- name: "http"
|
||||
internal: proxy_only
|
||||
external: 8082
|
||||
external: 8083
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
|
||||
@@ -2,19 +2,24 @@ services:
|
||||
{% for service in services %}
|
||||
{% if inventory_hostname in service.vm %}
|
||||
{{service.name}}:
|
||||
hostname: {{service.name}}
|
||||
container_name: {{ service.container_name }}
|
||||
image: {{ service.image }}
|
||||
restart: {{ service.restart }}
|
||||
{% if service.network_mode is not defined %}
|
||||
hostname: {{service.name}}
|
||||
networks:
|
||||
- net
|
||||
{% if service.ports is iterable%}
|
||||
{% endif %}
|
||||
{% if service.ports is iterable %}
|
||||
{% if service.ports[0].internal != 'proxy_only' %}
|
||||
ports:
|
||||
{% for port in service.ports %}
|
||||
{% if port.internal != 'proxy_only' %}
|
||||
- {{port.external}}:{{port.internal}}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if service.cap_add is defined and service.cap_add is iterable %}
|
||||
cap_add:
|
||||
{% for cap in service.cap_add %}
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
|
||||
{% for service in services %}
|
||||
{% if service.ports is iterable %}
|
||||
{% set http_port = service.ports | selectattr('name', 'equalto', 'http') | map(attribute='external') | list %}
|
||||
{% if http_port %}
|
||||
{{ service.name }}.{{ domain }} {
|
||||
{% for vm in service.vm %}
|
||||
reverse_proxy {{ hostvars[vm].ansible_host }}:{{ service.ports | selectattr('name', 'equalto', 'http') | map(attribute='external') | first }}
|
||||
reverse_proxy {{ hostvars[vm].ansible_host }}:{{ http_port[0] }}
|
||||
{% endfor %}
|
||||
log {
|
||||
output file /var/log/caddy/{{ service.name }}.log
|
||||
@@ -25,4 +27,5 @@
|
||||
}
|
||||
}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user