Skip to content

Commit

Permalink
Add internal network option
Browse files Browse the repository at this point in the history
Sometimes it is possible, that one or more networks are external and the other(s) not. In that case, we have to be able to differentiate between these networks in docker-compose.yml file. To do that, I have set another variable and condition, and put the external check in that condition.
  • Loading branch information
serknsvnc committed Sep 5, 2024
1 parent d8e36fc commit 892a157
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions roles/project_deployment/templates/docker-compose.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ services:
{% endif %}
{% endif %}
{% endfor %}
{% if current_project.value.external_networks is defined and current_project.value.external_networks | length > 0 %}
{% if current_project.value.networks is defined and current_project.value.networks | length > 0 %}

networks:
{% for external_network in current_project.value.external_networks %}
{{ external_network }}:
{% for network in current_project.value.networks %}
{{ network }}:
{% if current_project.value.external_networks is defined and current_project.value.external_networks | length > 0 and network in current_project.value.external_networks %}
external: true
{% endif %}
{% endfor %}
{% endif %}
{% if docker_volumes is defined and docker_volumes | length > 0 %}
Expand Down

0 comments on commit 892a157

Please sign in to comment.