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 f77ec1e commit 8bbd8fe
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/actions/setup-gear/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ runs:
sudo sed -i -e "1i runner:$(getent group docker | cut -d: -f3):1" /etc/subgid
sudo sed -i -e "1i runner:$(id -u):1" /etc/subuid
sudo systemctl restart docker
docker network create gear
- uses: docker/[email protected]
- uses: docker/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/beyond-doubt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ jobs:
- name: Run ansible-playbook stacks.yaml -t test
run: >-
docker run --rm
--network gear
--volume $(pwd):$(pwd)
--volume ~/.m2:/root/.m2
--volume /var/run/docker.sock:/var/run/docker.sock
--network bezmen_product_network
--workdir $(pwd)/baker/ansible
${{ env.IMAGE_NAME }}:${{ matrix.env.dev }}
ansible-playbook stacks.yaml -t test
Expand Down
6 changes: 6 additions & 0 deletions baker/ansible/tasks/product/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
changed_when: false
when: hostvars.db.image_status|default({}) is changed

- name: Create network
ansible.builtin.shell:
cmd: docker network inspect gear || docker network create gear
strip_empty_ends: false
changed_when: false

- name: Create stand
ansible.builtin.command:
cmd: >-
Expand Down
30 changes: 19 additions & 11 deletions stack/product/compose.j2
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
name: {{ product.name }}

networks:
product_network:
product:
name: product
gear:
name: gear
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
- gear
ports:
- 5432:5432
environment:
Expand All @@ -22,11 +29,12 @@ services:
interval: 10s
timeout: 5s
retries: 5
networks:
- product_network

database:
image: {{ image_ns }}/{{ database.image }}:{{ database.cid }}
networks:
- product
- gear
depends_on:
storage:
condition: service_healthy
Expand All @@ -45,12 +53,13 @@ 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
- gear
depends_on:
database:
condition: service_completed_successfully
Expand All @@ -66,18 +75,19 @@ 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
- gear
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 +99,4 @@ services:
{% endfor %}
labels:
image.key: {{ app.image }}
networks:
- product_network
{% endfor %}

0 comments on commit 8bbd8fe

Please sign in to comment.