Finished docker refactoring

This commit is contained in:
2025-07-07 03:48:19 +02:00
parent 38ed1e94e8
commit ca0602a1c8
58 changed files with 252 additions and 160 deletions

View File

@@ -12,10 +12,10 @@
- data:/var/www/html
environment:
- AKAUNTING_SETUP
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -12,18 +12,18 @@
worker:
env_file:
- ./.env
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
worker:
image: "{{ applications[application_id].images.worker }}"
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
maildev:
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
volumes:
- .:/usr/share/nginx/html
- .:/var/www
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
redis:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -8,11 +8,11 @@
- data:/baserow/data
ports:
- "{{ports.localhost.http[application_id]}}:80"
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:
redis:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -12,7 +12,7 @@
- "127.0.0.1:{{ports.localhost.http.bluesky_api}}:{{ container_port }}"
{% include 'roles/docker-container/templates/healthcheck/wget.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
# Deactivated for the moment @see https://github.com/bluesky-social/social-app
web:
@@ -33,9 +33,9 @@
interval: 30s
timeout: 10s
retries: 3
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
pds_data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -8,6 +8,6 @@
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -6,7 +6,7 @@ services:
{% endif %}
{# Load Redis #}
{% if applications[application_id].docker.redis.enabled | default(false) | bool %}
{% include 'templates/docker/services/redis.yml.j2' %}
{% include 'roles/docker-redis/templates/service.yml.j2' %}
{% endif %}
{# Load OAuth2 Proxy #}
{% if not applications | is_feature_enabled('oauth2',application_id) %}

View File

@@ -0,0 +1,19 @@
{# This template needs to be included in docker-compose.yml #}
networks:
{% if applications | is_feature_enabled('central_database',application_id) and database_type is defined %}
central_{{ database_type }}:
external: true
{% endif %}
{% if applications[application_id].get('features', {}).get('ldap', false) and applications.ldap.network.docker | bool %}
central_ldap:
external: true
{% endif %}
default:
{% if application_id in networks.local and networks.local[application_id].subnet is defined %}
driver: bridge
ipam:
driver: default
config:
- subnet: {{networks.local[application_id].subnet}}
{% endif %}
{{ "\n" }}

View File

@@ -0,0 +1,6 @@
{# This needs to be included in docker-compose.yml which just contain a database volume #}
{% if not applications | is_feature_enabled('central_database',application_id) %}
volumes:
database:
{% endif %}
{{ "\n" }}

View File

@@ -0,0 +1,6 @@
{# This template needs to be included in docker-compose.yml which contain a database and additional volumes #}
volumes:
{% if not applications | is_feature_enabled('central_database',application_id) %}
database:
{% endif %}
{{ "\n" }}

View File

@@ -0,0 +1,49 @@
# Role: docker-container
## Description
This Ansible role supplies common Jinja2 snippets for composing Docker services consistently. Rather than repeating the same YAML blocks, you include one or more of the provided templates in your `docker-compose.yml.j2`.
## Overview
The following templates are available under `roles/docker-container/templates/`:
- **base.yml.j2**
Common service settings: `restart`, `env_file`, `logging`.
- **networks.yml.j2**
Conditional network attachments:
- `central_<database_type>` when `central_database` feature is enabled
- `central_ldap` when LDAP feature and network are enabled
- `default`
- **depends_on_dmbs.j2**
Builds a `depends_on:` block automatically:
- If `central_database` is **off**, renders an empty list `depends_on: []`
- Otherwise, includes `database` and/or `redis` with healthcheck conditions
- **healthcheck/**
Four strategies:
- `curl.yml.j2` (HTTP via `curl -f`)
- `wget.yml.j2` (HTTP via `wget --spider`)
- `tcp.yml.j2` (TCP socket test)
- `msmtp_curl.yml.j2` (SMTP first, then HTTP via `curl`; avoids duplicate emails)
Include whichever snippets your service requires to keep your Compose files DRY and maintainable.
## Features
- **Modular templates**
Mix only the blocks you need.
- **Featuredriven logic**
Networks and dependencies adjust automatically based on your `applications` variables.
- **Multiple healthcheck options**
Pick the probe that works best for your containers protocol and requirements.
## Further Resources
- [Docker Compose file reference](https://docs.docker.com/compose/compose-file/)
- [Ansible variable precedence](https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#understanding-variable-precedence)
- [Jinja2 templating guide](https://jinja.palletsprojects.com/)

View File

@@ -0,0 +1,10 @@
{# This template needs to be included in docker-compose.yml containers #}
networks:
{% if applications | is_feature_enabled('central_database',application_id) | bool and database_type is defined %}
central_{{ database_type }}:
{% endif %}
{% if applications[application_id].get('features', {}).get('ldap', false) | bool and applications.ldap.network.docker|bool %}
central_ldap:
{% endif %}
default:
{{ "\n" }}

View File

@@ -11,13 +11,13 @@
- /etc/localtime:/etc/localtime:ro
{% include 'roles/docker-container/templates/healthcheck/curl.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
coturn:
image: coturn/coturn
restart: always

View File

@@ -1,8 +1,8 @@
{% include 'roles/docker-compose/templates/base.yml.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
redis:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
discourse_default:
external: true

View File

@@ -61,7 +61,7 @@
depends_on:
- elasticsearch
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
elasticsearch:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -6,7 +6,7 @@
ports:
- "127.0.0.1:{{ ports.localhost.http[application_id] }}:80"
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
volumes:
- data:/var/www/html
@@ -16,7 +16,7 @@
logging:
driver: journald
entrypoint: docker-daemon.sh
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
volumes:
- data:/var/www/html
@@ -32,13 +32,13 @@
- ESPOCRM_CONFIG_WEB_SOCKET_ZERO_M_Q_SUBMISSION_DSN=tcp://websocket:7777
entrypoint: docker-websocket.sh
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
volumes:
- data:/var/www/html
ports:
- "127.0.0.1:{{ ports.localhost.websocket[application_id] }}:8080"
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -10,11 +10,11 @@
- "127.0.0.1:{{ports.localhost.http[application_id]}}:80"
{% include 'roles/docker-container/templates/healthcheck/msmtp_curl.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:
html:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -17,14 +17,14 @@
- "data:{{funkwhale_media_root}}"
- "music:{{funkwhale_music_directory_path}}:ro"
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
celerybeat:
{% include 'roles/docker-container/templates/base.yml.j2' %}
image: "{{ applications | get_docker_image(application_id,'api') }}"
command: celery -A funkwhale_api.taskapp beat --pidfile= -l INFO
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
api:
{% include 'roles/docker-container/templates/base.yml.j2' %}
@@ -36,7 +36,7 @@
ports:
- "{{ funkwhale_docker_api_port }}"
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
front:
{% include 'roles/docker-container/templates/base.yml.j2' %}
@@ -60,10 +60,10 @@
profiles:
- typesense
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:
funkwhale_static_root:
redis:
music:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -23,7 +23,7 @@
- fusiondirectory_data:/assets/fusiondirectory
restart: always
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
fusiondirectory_data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -11,10 +11,10 @@
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
{% include 'roles/docker-container/templates/healthcheck/curl.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -13,12 +13,12 @@
- 'data:/var/opt/gitlab'
shm_size: '256m'
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
redis:
config:
logs:
data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -6,10 +6,10 @@
- data:/var/www/html
ports:
- "127.0.0.1:{{ports.localhost.http[application_id]}}:80"
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -10,9 +10,9 @@
volumes:
- "{{import_directory_host}}:{{import_directory_docker}}"
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% set container_port = 9000 %}
{% set container_healthcheck = 'health/live' %}
{% include 'roles/docker-container/templates/healthcheck/tcp.yml.j2' %}
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -6,6 +6,6 @@
ports:
- 127.0.0.1:{{ports.localhost.http[application_id]}}:80
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -20,9 +20,9 @@
-b cn=config "(&(objectClass=olcOverlayConfig)(olcOverlay=memberof))" \
| grep "olcOverlay:" | grep -q "memberof"
'
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -7,10 +7,10 @@
- "127.0.0.1:{{ports.localhost.http[application_id]}}:{{ container_port }}"
volumes:
- {{docker_compose.directories.config}}config.toml:/listmonk/config.toml
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'roles/docker-container/templates/healthcheck/wget.yml.j2' %}
{% include 'templates/docker/compose/volumes-just-database.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes-just-database.yml.j2' %}
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -4,7 +4,7 @@
resolver:
image: {{docker_source}}/unbound:{{applications.mailu.version}}
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
ipv4_address: {{networks.local.mailu.dns}}
front:
@@ -26,7 +26,7 @@
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
resolver:
condition: service_started
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
webmail:
radicale:
dns:
@@ -45,7 +45,7 @@
condition: service_started
dns:
- {{networks.local.mailu.dns}}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
imap:
image: {{docker_source}}/dovecot:{{applications.mailu.version}}
@@ -58,7 +58,7 @@
- resolver
dns:
- {{networks.local.mailu.dns}}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
smtp:
image: {{docker_source}}/postfix:{{applications.mailu.version}}
@@ -71,7 +71,7 @@
- resolver
dns:
- {{networks.local.mailu.dns}}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
oletools:
image: {{docker_source}}/oletools:{{applications.mailu.version}}
@@ -81,7 +81,7 @@
- resolver
dns:
- {{networks.local.mailu.dns}}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
noinet:
antispam:
@@ -98,7 +98,7 @@
- resolver
dns:
- {{networks.local.mailu.dns}}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
noinet:
@@ -112,7 +112,7 @@
- resolver
dns:
- {{networks.local.mailu.dns}}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
webdav:
image: {{docker_source}}/radicale:{{applications.mailu.version}}
@@ -123,7 +123,7 @@
- resolver
dns:
- {{networks.local.mailu.dns}}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
radicale:
fetchmail:
@@ -138,7 +138,7 @@
- resolver
dns:
- {{networks.local.mailu.dns}}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
webmail:
image: {{docker_source}}/webmail:{{applications.mailu.version}}
@@ -152,10 +152,10 @@
- resolver
dns:
- {{networks.local.mailu.dns}}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
webmail:
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
smtp_queue:
admin_data:
webdav_data:
@@ -165,7 +165,7 @@
dovecot_mail:
redis:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
radicale:
driver: bridge
webmail:

View File

@@ -12,7 +12,7 @@
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
volumes:
- data:/mastodon/public/system
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
streaming:
{% set container_port = 4000 %}
@@ -24,7 +24,7 @@
ports:
- "127.0.0.1:{{ports.localhost.websocket[application_id]}}:{{ container_port }}"
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
sidekiq:
image: "{{ applications[application_id].images.mastodon }}"
@@ -35,10 +35,10 @@
- data:/mastodon/public/system
healthcheck:
test: ['CMD-SHELL', "ps aux | grep '[s]idekiq\ 6' || false"]
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
redis:
data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -8,9 +8,9 @@
volumes:
- data:/var/www/html
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/healthcheck/tcp.yml.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -27,7 +27,7 @@
{% else %}
{% endif %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
element:
{% set container_port = 80 %}
image: "{{ applications[application_id].images.element }}"
@@ -38,7 +38,7 @@
ports:
- "127.0.0.1:{{ports.localhost.http.element}}:{{ container_port }}"
{% include 'roles/docker-container/templates/healthcheck/wget.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% for item in bridges %}
mautrix-{{item.bridge_name}}:
@@ -52,7 +52,7 @@
interval: 1m
timeout: 10s
retries: 3
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% endfor %}
{% if applications[application_id].plugins.chatgpt | bool %}
matrix-chatgpt-bot:
@@ -96,10 +96,10 @@
MATRIX_RICH_TEXT: 'true'
{% endif %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
synapse_data:
{% if applications[application_id].plugins.chatgpt | bool %}
chatgpt_data:
{% endif %}
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -9,10 +9,10 @@
- "mediawiki-data:/var/www/html/"
ports:
- "127.0.0.1:{{ports.localhost.http[application_id]}}:80"
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -9,10 +9,10 @@
{% include 'roles/docker-container/templates/healthcheck/curl.yml.j2' %}
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
uploads:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -15,11 +15,11 @@
- 'data:{{ bitnami_data_dir }}'
{% include 'roles/docker-container/templates/healthcheck/tcp.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
code:
data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -9,7 +9,7 @@
volumes:
- data:/var/www/html
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
server:
logging:
@@ -23,9 +23,9 @@
volumes:
- "{{docker_compose_instance_confd_directory}}:{{target_mount_conf_d_directory}}:ro"
- "data:/var/www/html:ro"
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -13,7 +13,7 @@
retries: 3
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
ipv4_address: 192.168.102.69
# @Todo activate
@@ -71,11 +71,11 @@
timeout: 10s
retries: 3
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
ipv4_address: 192.168.102.70
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:
redis:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -34,7 +34,7 @@ x-op-app: &app
{% include 'roles/docker-container/templates/base.yml.j2' %}
command: "./docker/prod/web"
container_name: openproject-web
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
cache:
condition: service_started
@@ -52,7 +52,7 @@ x-op-app: &app
{% include 'roles/docker-container/templates/base.yml.j2' %}
command: "./docker/prod/worker"
container_name: openproject-worker
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
cache:
condition: service_started
@@ -68,7 +68,7 @@ x-op-app: &app
{% include 'roles/docker-container/templates/base.yml.j2' %}
command: "./docker/prod/cron"
container_name: openproject-cron
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
cache:
condition: service_started
@@ -87,12 +87,12 @@ x-op-app: &app
logging:
driver: journald
restart: on-failure
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
volumes:
- "data:/var/openproject/assets"
- "{{dummy_volume}}:/var/openproject/pgdata" # This mount is unnecessary and just done to prevent anonymous volumes
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -13,14 +13,14 @@
- data:/data
- config:/config
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
healthcheck:
# This just tests if the service is running on port 9000. It doesn't check if there is an 200 or e.g. an 404 response
{% include 'roles/docker-container/templates/healthcheck/tcp.yml.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
assets:
data:
redis:
config:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -8,7 +8,7 @@
ports:
- "127.0.0.1:{{ports.localhost.http[application_id]}}:80"
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/healthcheck/wget.yml.j2' %}
volumes:
- "data:/var/lib/pgadmin"
@@ -17,7 +17,7 @@
- "{{ pgadmin_host_password_file }}:{{ pgadmin_docker_password_file }}"
{% endif %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -7,9 +7,9 @@
- 127.0.0.1:{{ports.localhost.http[application_id]}}:8080
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -8,7 +8,7 @@
ports:
- "127.0.0.1:{{ports.localhost.http[application_id]}}:{{ container_port }}"
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/healthcheck/tcp.yml.j2' %}
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -9,7 +9,7 @@
ports:
- "{{ports.localhost.http[application_id]}}:80"
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
worker:
image: "{{ applications[application_id].images.pixelfed }}"
{% include 'roles/docker-container/templates/base.yml.j2' %}
@@ -25,10 +25,10 @@
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
application:
condition: service_started
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
redis:
data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -11,7 +11,7 @@
volumes:
- {{docker_repository_path}}app:/app
restart: unless-stopped
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/healthcheck/tcp.yml.j2' %}
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -9,7 +9,7 @@
- {{ path_cymais_presentation_output.stdout }}:/app
- {{ path_cymais_output.stdout }}:/source
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -0,0 +1,43 @@
# Role: docker-redis
## Description
This Ansible role provides a Jinja2 snippet to inject a Redis service definition into your Docker Compose setup. It renders a `service.yml.j2` template that defines a `redis` container with sensible defaults.
## Overview
The roles `service.yml.j2` template includes:
- An Alpine-based Redis image (`redis:alpine`)
- Container naming based on `application_id` (defaults to `redis`)
- Restart policy
- Journald logging driver
- A named volume (`redis:/data`) for persistence
- A basic healthcheck using `redis-cli ping`
- Attachment to the default network
Include this snippet in your top-level `docker-compose.yml.j2` where you want Redis to appear.
## Features
- **Configurable `application_id`**
Sets container name (`{{ application_id }}-redis`).
- **Restart policy**
Controlled by `docker_restart_policy`.
- **Journald logging**
Ensures logs are captured by systemds journal.
- **Persistent storage**
Declares and mounts `redis:/data`.
- **Built-in healthcheck**
Uses `redis-cli ping` with configurable intervals and retries.
## Further Resources
- [Official Redis Docker image on Docker Hub](https://hub.docker.com/_/redis)
- [Ansible Jinja2 documentation](https://docs.ansible.com/ansible/latest/user_guide/playbooks_templating.html)
- [Docker Compose reference](https://docs.docker.com/compose/compose-file/)

View File

@@ -0,0 +1,17 @@
# This template needs to be included in docker-compose.yml, which depend on redis
redis:
image: redis:alpine
container_name: {{application_id}}-redis
restart: {{docker_restart_policy}}
logging:
driver: journald
volumes:
- redis:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 1s
timeout: 3s
retries: 30
networks:
- default
{{ "\n" }}

View File

@@ -0,0 +1 @@
application_id: redis

View File

@@ -7,4 +7,4 @@
- 127.0.0.1:{{ports.localhost.http[application_id]}}:8080
restart: {{docker_restart_policy}}
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -8,7 +8,7 @@
ports:
- "{{ports.localhost.http[application_id]}}:3000"
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -9,10 +9,10 @@
ports:
- "127.0.0.1:{{ports.localhost.http[application_id]}}:{{ container_port }}"
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/healthcheck/tcp.yml.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
redis:
data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -8,6 +8,6 @@
- "127.0.0.1:{{ports.localhost.http[application_id]}}:{{ container_port }}"
{% include 'roles/docker-container/templates/healthcheck/curl.yml.j2' %}
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -35,4 +35,4 @@
SPRING_PROFILES_ACTIVE: docker,saml2
SERVICE_DISCOVERY_ADDRESS: {{ domains | get_url(application_id, web_protocol) }}/{{syncope_paths[enduser]}}/
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -4,11 +4,11 @@ services:
environment:
CELERY_ENABLED: "False"
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
entrypoint: "python manage.py"
volumes:
- static-data:/taiga-back/static
- media-data:/taiga-back/media
# - ./config.py:/taiga-back/settings/config.py
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
taiga:

View File

@@ -15,7 +15,7 @@
{% endif %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
taiga:
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
taiga-events-rabbitmq:
@@ -50,7 +50,7 @@
{% endif %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
taiga:
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
taiga-events-rabbitmq:
@@ -72,13 +72,13 @@
volumes:
- async-rabbitmq-data:/var/lib/rabbitmq
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
taiga:
taiga-front:
image: {{taiga_image_frontend}}:{{applications.taiga.version}}
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
taiga:
# volumes:
# - {{ taiga_frontend_conf_path }}:/usr/share/nginx/html/conf.json:ro
@@ -86,7 +86,7 @@
taiga-events:
image: taigaio/taiga-events:latest
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
taiga:
depends_on:
taiga-events-rabbitmq:
@@ -99,14 +99,14 @@
- events-rabbitmq-data:/var/lib/rabbitmq
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
taiga:
taiga-protected:
image: taigaio/taiga-protected:latest
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
taiga:
taiga-gateway:
@@ -119,18 +119,18 @@
- media-data:/taiga/media
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
taiga:
depends_on:
- taiga-front
- taiga-back
- taiga-events
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
static-data:
media-data:
async-rabbitmq-data:
events-rabbitmq-data:
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
taiga:

View File

@@ -12,9 +12,9 @@
{% include 'roles/docker-container/templates/healthcheck/msmtp_curl.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:

View File

@@ -10,8 +10,8 @@
{% include 'roles/docker-container/templates/healthcheck/curl.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on_dmbs.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
{% include 'templates/docker/compose/volumes-just-database.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes-just-database.yml.j2' %}
{% include 'templates/docker/compose/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}