Skip to content

Commit

Permalink
Use external network
Browse files Browse the repository at this point in the history
  • Loading branch information
pavetok committed Feb 18, 2024
1 parent e99ef83 commit b25bc2c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
8 changes: 8 additions & 0 deletions baker/ansible/tasks/product/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
changed_when: false
when: hostvars.db.image_status|default({}) is changed

- name: Create network
ansible.builtin.shell:
cmd: >-
docker network inspect {{ product.name }}
|| docker network create {{ product.name }}
strip_empty_ends: false
changed_when: false

- name: Create stand
ansible.builtin.command:
cmd: >-
Expand Down
22 changes: 12 additions & 10 deletions stack/product/compose.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ name: {{ product.name }}

networks:
product_network:
name: {{ product.name }}
external: true

configs:
stack_config:
product_config:
file: ./{{ product.config.file_name }}

{% set storage = product.storages[ops[opsenv].storage.vendor]|combine(ops[opsenv].storage) %}
{% set database = product.databases[storage.vendor] %}
services:
storage:
image: {{ storage.image }}:{{ storage.version }}-alpine
networks:
- product_network
ports:
- 5432:5432
environment:
Expand All @@ -22,11 +26,11 @@ services:
interval: 10s
timeout: 5s
retries: 5
networks:
- product_network

database:
image: {{ image_ns }}/{{ database.image }}:{{ database.cid }}
networks:
- product_network
depends_on:
storage:
condition: service_healthy
Expand All @@ -45,12 +49,12 @@ services:
-Ddatabase.name={{ database.name }}
-Downer.username={{ storage.owner.username }}
-Downer.password={{ storage.owner.password }}
networks:
- product_network

{% for schema in product.schemas[storage.vendor] %}
{{ schema.name }}:
image: {{ image_ns }}/{{ database.image }}:{{ database.cid }}
networks:
- product_network
depends_on:
database:
condition: service_completed_successfully
Expand All @@ -66,18 +70,18 @@ services:
--password={{ storage.owner.password }}
update
-Dschema.name={{ schema.name }}
networks:
- product_network
{% endfor %}

{% set apps = product.apps[ops[opsenv].app.lang]|selectattr('service', 'in', usages[purpose].apps) %}
{% for app in apps %}
{{ app.service }}:
image: {{ image_ns }}/{{ app.image }}:{{ hostvars.app.image_tags[app.binary] }}
networks:
- product_network
ports:
- 8080:8080
configs:
- source: stack_config
- source: product_config
target: /home/app/{{ product.config.file_name }}
command: >-
--product.config.mapping.mode={{ product.config.mapping_mode }}
Expand All @@ -89,6 +93,4 @@ services:
{% endfor %}
labels:
image.key: {{ app.image }}
networks:
- product_network
{% endfor %}

0 comments on commit b25bc2c

Please sign in to comment.