Implemented helper role docker-central-database and refactored code

This commit is contained in:
2025-02-04 18:14:37 +01:00
parent cb6a42e97d
commit 5503326ea6
91 changed files with 358 additions and 237 deletions

View File

@@ -1,26 +0,0 @@
# This template needs to be included in docker-compose.yml, which depend on a mariadb database
{% if not enable_central_database | bool %}
database:
container_name: {{application_id}}-database
logging:
driver: journald
image: mariadb
restart: {{docker_restart_policy}}
environment:
MYSQL_DATABASE: "{{database_name}}"
MYSQL_USER: "{{database_username}}"
MYSQL_PASSWORD: "{{database_password}}"
MYSQL_ROOT_PASSWORD: "{{database_password}}"
MARIADB_AUTO_UPGRADE: "1"
command: "--transaction-isolation=READ-COMMITTED --binlog-format=ROW"
volumes:
- database:/var/lib/mysql
healthcheck:
test: "/usr/bin/mariadb --user={{database_username}} --password={{database_password}} --execute \"SHOW DATABASES;\""
interval: 3s
timeout: 1s
retries: 5
networks:
- default
{% endif %}
{{ "\n" }}

View File

@@ -1,24 +0,0 @@
# This template needs to be included in docker-compose.yml, which depend on a postgres database
{% if not enable_central_database | bool %}
database:
image: postgres:{{applications.postgres.database_version}}-alpine
container_name: {{application_id}}-database
environment:
- POSTGRES_PASSWORD={{database_password}}
- POSTGRES_USER={{database_username}}
- POSTGRES_DB={{database_name}}
- POSTGRES_INITDB_ARGS=--encoding=UTF8 --locale=C
restart: {{docker_restart_policy}}
healthcheck:
test: ["CMD-SHELL", "pg_isready -U {{database_name}}"]
interval: 10s
timeout: 5s
retries: 6
volumes:
- type: volume
source: database
target: /var/lib/postgresql/data
networks:
- default
{% endif %}
{{ "\n" }}