From c5d6c67835a2d63d89c2d6ee0937ebc2789655f7 Mon Sep 17 00:00:00 2001 From: William Date: Fri, 1 Jul 2022 22:40:17 +0200 Subject: [PATCH] =?UTF-8?q?Possibilit=C3=A9=20d'associer=20des=20volumes?= =?UTF-8?q?=20au=20conteneur.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++++- templates/docker-compose.yml.j2 | 14 +++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 60e4202..b640fe6 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,9 @@ Then create a file `vars.json` vars who contain : "version": "master", "host": "myapp.example.com", "dockerfile": "Dockerfile", + "volumes": { + "storage": "/app/storage" + }, "envvars": { "APP_NAME": "Wonderful", "APP_ENV": "production" @@ -29,7 +32,7 @@ Then create a file `vars.json` vars who contain : Then run a playbook: ```bash -$ ansible-playbook -i hosts.ini playbooks/app-install.yml -e @vars.json +$ ansible-playbook -i hosts.ini -e @vars.json playbooks/app-install.yml ``` ## Available playbooks: diff --git a/templates/docker-compose.yml.j2 b/templates/docker-compose.yml.j2 index d8f67ed..a5cbb34 100644 --- a/templates/docker-compose.yml.j2 +++ b/templates/docker-compose.yml.j2 @@ -4,6 +4,13 @@ networks: web: external: true +{% if volumes is defined %} +volumes: +{% for key,value in volumes.items() %} + {{ key }}: +{% endfor %} +{% endif %} + services: app: build: @@ -13,8 +20,13 @@ services: - .env.pilot networks: - web +{% if volumes is defined %} + volumes: +{% for key,value in volumes.items() %} + - {{ key }}:{{ value }} +{% endfor %} +{% endif %} labels: - "traefik.enable=true" - - "traefik.http.routers.{{ name }}-http.rule=Host(`{{ host }}`)" - "traefik.http.routers.{{ name }}-http.entrypoints=http"