You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hetzner-ansible/templates/_docker/docker-compose.yml.j2

177 lines
4.5 KiB
Django/Jinja

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

version: '3.7'
{# ################################################## networks #}
{% if
current_docker.networks is defined
and (current_docker.networks|length>0)
%}
networks:
{% for network in current_docker.networks %}
{{ network.name }}:
external: {{ network.external | default('false') }}
{% if network.ipams is defined %}
ipam:
config:
{% for config in network.ipams %}
- subnet: "{{ config.subnet }}"
gateway: "{{ config.gateway }}"
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{# ################################################## networks #}
{# ################################################### volumes #}
{% if
current_docker.volumes is defined
and (current_docker.volumes|length>0)
%}
volumes:
{% for volume in current_docker.volumes %}
{{ volume.name }}: {}
{% endfor %}
{% else %}
{% endif %}
{# ################################################### volumes #}
{# ################################################## services #}
services:
{% for service in current_docker.services %}
{{ service.name }}:
image: "{{ service.image_name }}:{{ service.image_version }}"
container_name: "{{ service.name }}"
restart: {{ service.restart | default('always') }}
{% if
service.user is defined
%}
user: "{{ service.user }}"
{% endif %}
{# ########################################## command #}
{% if
service.command is defined
and (service.command|length>0)
%}
{% if service.command is string %}
command: "{{ service.command }}"
{% elif service.command is iterable %}
command: [
{% for item in service.command %}
{{ item }},
{% endfor %}
]
{% endif %}
{% endif %}
{# ########################################## command #}
{# ###################################### labels #}
{% if
service.labels is defined
and (service.labels|length>0)
%}
labels:
{% for item in service.labels %}
- {{ item }}
{% endfor %}
{% endif %}
{# ###################################### labels #}
{# ###################################### environment #}
{% if
service.environment is defined
and (service.environment|length>0)
%}
environment:
{% for item in service.environment %}
{{ item }}
{% endfor %}
{% endif %}
{# ###################################### environment #}
{# ######################################### env_file #}
{% if
service.env_file is defined
and (service.env_file|length>0)
%}
env_file:
{% for item in service.env_file %}
- {{ item }}
{% endfor %}
{% endif %}
{# ######################################## env_file #}
{# ######################################### volumes #}
{% if
service.volumes is defined
and (service.volumes|length>0)
%}
volumes:
{% for item in service.volumes %}
- {{ item }}
{% endfor %}
{% endif %}
{# ######################################### volumes #}
{# ########################################## dns #}
{% if
service.dns is defined
and (service.dns|length>0)
%}
dns:
{% for item in service.dns %}
- {{ item }}
{% endfor %}
{% endif %}
{# ########################################## dns #}
{# ######################################## networks #}
{% if
service.networks is defined
and (service.networks|length>0)
%}
networks:
{% for network in service.networks %}
{% if network.name is defined %}
{{ network.name }}:
{% if network.ipv4_address is defined %}
ipv4_address: {{ network.ipv4_address }}
{% endif %}
{% if network.aliases is defined %}
aliases:
- {{ network.aliases }}
{% endif %}
{% else %}
- {{ network }}
{% endif %}
{% endfor %}
{% endif %}
{# ######################################## networks #}
{# ##################################### extra_hosts #}
{% if
service.extra_hosts is defined
and (service.extra_hosts|length>0)
%}
extra_hosts:
{% for item in service.extra_hosts %}
- {{ item.hostname }}:{{ item.ip }}
{% endfor %}
{% endif %}
{# ##################################### extra_hosts #}
{# ########################################### ports #}
{% if
service.ports is defined
and (service.ports|length>0)
%}
ports:
{% for item in service.ports %}
- "{{ item.external }}:{{ item.internal }}"
{% endfor %}
{% endif %}
{# ########################################### ports #}
{# ########################################### lines #}
{% if
service.lines is defined
and (service.lines|length>0)
%}
{% for line in service.lines %}
{{ line }}
{% endfor %}
{% endif %}
{# ########################################### lines #}
{% endfor %}
{# ################################################## services #}