From 8fe03b6a438a68065e25b26ed3795e716a175de5 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 26 Dec 2023 16:40:19 +0100 Subject: [PATCH] refactored redis implementation --- .../templates/docker-compose.yml.j2 | 8 +++++--- .../templates/docker-compose.yml.j2 | 7 ++----- .../templates/docker-compose.yml.j2 | 17 +++-------------- .../templates/docker-compose.yml.j2 | 13 ++++--------- .../templates/docker-compose.yml.j2 | 15 +++------------ .../templates/docker-compose.yml.j2 | 8 +++----- roles/docker-pixelfed/README.md | 2 +- .../templates/docker-compose.yml.j2 | 16 +++------------- templates/docker-redis-service.yml.j2 | 12 ++++++++++++ 9 files changed, 36 insertions(+), 62 deletions(-) create mode 100644 templates/docker-redis-service.yml.j2 diff --git a/roles/docker-attendize/templates/docker-compose.yml.j2 b/roles/docker-attendize/templates/docker-compose.yml.j2 index 5b3bbdf1..844fb203 100644 --- a/roles/docker-attendize/templates/docker-compose.yml.j2 +++ b/roles/docker-attendize/templates/docker-compose.yml.j2 @@ -31,7 +31,9 @@ services: image: maildev/maildev ports: - "{{ mail_interface_http_port }}:1080" - redis: - image: redis + +{% include 'templates/docker-redis-service.yml.j2' %} + volumes: - database: \ No newline at end of file + database: + redis: \ No newline at end of file diff --git a/roles/docker-funkwhale/templates/docker-compose.yml.j2 b/roles/docker-funkwhale/templates/docker-compose.yml.j2 index 9f63ce78..5defaa4e 100644 --- a/roles/docker-funkwhale/templates/docker-compose.yml.j2 +++ b/roles/docker-funkwhale/templates/docker-compose.yml.j2 @@ -10,12 +10,9 @@ services: volumes: - database:/var/lib/postgresql/data - redis: - restart: always +{% include 'templates/docker-redis-service.yml.j2' %} + env_file: .env - image: redis:7-alpine - volumes: - - redis:/data celeryworker: restart: always diff --git a/roles/docker-mailu/templates/docker-compose.yml.j2 b/roles/docker-mailu/templates/docker-compose.yml.j2 index 4144bed5..0841486d 100644 --- a/roles/docker-mailu/templates/docker-compose.yml.j2 +++ b/roles/docker-mailu/templates/docker-compose.yml.j2 @@ -2,20 +2,9 @@ version: '2.2' services: - # External dependencies - redis: - image: redis:alpine - restart: always +{% include 'templates/docker-redis-service.yml.j2' %} + env_file: mailu.env - volumes: - - "redis_data:/data" - healthcheck: - test: ["CMD", "redis-cli", "ping"] - interval: 1s - timeout: 3s - retries: 30 - logging: - driver: journald depends_on: - resolver dns: @@ -223,7 +212,7 @@ volumes: filter: dkim: dovecot_mail: - redis_data: + redis: networks: default: driver: bridge diff --git a/roles/docker-mastodon/templates/docker-compose.yml.j2 b/roles/docker-mastodon/templates/docker-compose.yml.j2 index 9a4d5edd..943140bc 100644 --- a/roles/docker-mastodon/templates/docker-compose.yml.j2 +++ b/roles/docker-mastodon/templates/docker-compose.yml.j2 @@ -14,17 +14,12 @@ services: - 'POSTGRES_HOST_AUTH_METHOD=trust' logging: driver: journald - redis: - restart: always - image: redis:7-alpine + +{% include 'templates/docker-redis-service.yml.j2' %} + networks: - internal_network - healthcheck: - test: ['CMD', 'redis-cli', 'ping'] - volumes: - - redis:/data - logging: - driver: journald + web: image: tootsuite/mastodon:{{version_mastodon}} restart: always diff --git a/roles/docker-nextcloud/templates/docker-compose.yml.j2 b/roles/docker-nextcloud/templates/docker-compose.yml.j2 index 7b505c59..356fcf31 100644 --- a/roles/docker-nextcloud/templates/docker-compose.yml.j2 +++ b/roles/docker-nextcloud/templates/docker-compose.yml.j2 @@ -47,18 +47,9 @@ services: - "{{path_docker_volumes}}nextcloud/nginx.conf:/etc/nginx/nginx.conf:ro" volumes_from: - application - redis: - image: redis:alpine - restart: always - logging: - driver: journald - volumes: - - redis:/data - healthcheck: - test: ["CMD", "redis-cli", "ping"] - interval: 1s - timeout: 3s - retries: 30 + +{% include 'templates/docker-redis-service.yml.j2' %} + cron: image: "nextcloud:{{version_nextcloud}}-fpm-alpine" restart: always diff --git a/roles/docker-peertube/templates/docker-compose.yml.j2 b/roles/docker-peertube/templates/docker-compose.yml.j2 index 06033853..907aa155 100644 --- a/roles/docker-peertube/templates/docker-compose.yml.j2 +++ b/roles/docker-peertube/templates/docker-compose.yml.j2 @@ -28,11 +28,9 @@ services: interval: 10s timeout: 5s retries: 6 - redis: - image: redis:alpine - volumes: - - redis:/data - restart: "always" + +{% include 'templates/docker-redis-service.yml.j2' %} + env_file: - .env volumes: diff --git a/roles/docker-pixelfed/README.md b/roles/docker-pixelfed/README.md index 0e1183d5..02a76ca6 100644 --- a/roles/docker-pixelfed/README.md +++ b/roles/docker-pixelfed/README.md @@ -93,7 +93,7 @@ docker-compose exec -u "www-data" application php artisan schedule:run For a hard reset, which will delete all data and stop all services, use the following commands: ```bash docker-compose down -docker volume rm pixelfed_application_data pixelfed_database pixelfed_redis_data +docker volume rm pixelfed_application_data pixelfed_database pixelfed_redis ``` ## Update Procedure diff --git a/roles/docker-pixelfed/templates/docker-compose.yml.j2 b/roles/docker-pixelfed/templates/docker-compose.yml.j2 index 73c30fc7..77a68306 100644 --- a/roles/docker-pixelfed/templates/docker-compose.yml.j2 +++ b/roles/docker-pixelfed/templates/docker-compose.yml.j2 @@ -41,20 +41,10 @@ services: {% include 'templates/docker-mariadb-service.yml.j2' %} - redis: - image: redis:alpine - restart: always - logging: - driver: journald - volumes: - - redis_data:/data - healthcheck: - test: ["CMD", "redis-cli", "ping"] - interval: 1s - timeout: 3s - retries: 30 +{% include 'templates/docker-redis-service.yml.j2' %} + volumes: database: - redis_data: + redis: application_data: bootstrap: \ No newline at end of file diff --git a/templates/docker-redis-service.yml.j2 b/templates/docker-redis-service.yml.j2 new file mode 100644 index 00000000..bc5c411c --- /dev/null +++ b/templates/docker-redis-service.yml.j2 @@ -0,0 +1,12 @@ + redis: + image: redis:alpine + restart: always + logging: + driver: journald + volumes: + - redis:/data + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 1s + timeout: 3s + retries: 30 \ No newline at end of file