Skip to content

Commit

Permalink
Maintenance: Refactor YAML for better maintainability. (#369)
Browse files Browse the repository at this point in the history
* Maintenance: Refactor YAML for better maintainability.

* Simplify service dependency definition.
  • Loading branch information
mgruner authored Aug 28, 2023
1 parent 755c756 commit cb6a82d
Showing 1 changed file with 25 additions and 69 deletions.
94 changes: 25 additions & 69 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
---
version: '3.8'

x-shared:
zammad-service: &zammad-service
environment:
- MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
- POSTGRESQL_DB=${POSTGRES_DB}
- POSTGRESQL_HOST=${POSTGRES_HOST}
- POSTGRESQL_USER=${POSTGRES_USER}
- POSTGRESQL_PASS=${POSTGRES_PASS}
- POSTGRESQL_PORT=${POSTGRES_PORT}
- REDIS_URL=${REDIS_URL}
image: ${IMAGE_REPO}:${VERSION}
restart: ${RESTART}
volumes:
- zammad-var:/opt/zammad/var
depends_on:
- zammad-memcached
- zammad-postgresql
- zammad-redis

services:

zammad-backup:
<<: *zammad-service
command: ["zammad-backup"]
depends_on:
- zammad-railsserver
Expand All @@ -18,8 +38,6 @@ services:
- POSTGRESQL_USER=${POSTGRES_USER}
- POSTGRESQL_PASS=${POSTGRES_PASS}
- POSTGRESQL_PORT=${POSTGRES_PORT}
image: postgres:${POSTGRES_VERSION}
restart: ${RESTART}
volumes:
- zammad-backup:/var/tmp/zammad
- zammad-var:/opt/zammad/var:ro
Expand All @@ -32,18 +50,10 @@ services:
- elasticsearch-data:/bitnami/elasticsearch/data

zammad-init:
<<: *zammad-service
command: ["zammad-init"]
depends_on:
- zammad-postgresql
environment:
- MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
- POSTGRESQL_DB=${POSTGRES_DB}
- POSTGRESQL_HOST=${POSTGRES_HOST}
- POSTGRESQL_USER=${POSTGRES_USER}
- POSTGRESQL_PASS=${POSTGRES_PASS}
- POSTGRESQL_PORT=${POSTGRES_PORT}
- REDIS_URL=${REDIS_URL}
image: ${IMAGE_REPO}:${VERSION}
restart: on-failure
user: 0:0
volumes:
Expand All @@ -56,21 +66,12 @@ services:
restart: ${RESTART}

zammad-nginx:
<<: *zammad-service
command: ["zammad-nginx"]
expose:
- "8080"
depends_on:
- zammad-railsserver
environment:
- MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
- POSTGRESQL_DB=${POSTGRES_DB}
- POSTGRESQL_HOST=${POSTGRES_HOST}
- POSTGRESQL_USER=${POSTGRES_USER}
- POSTGRESQL_PASS=${POSTGRES_PASS}
- POSTGRESQL_PORT=${POSTGRES_PORT}
- REDIS_URL=${REDIS_URL}
image: ${IMAGE_REPO}:${VERSION}
restart: ${RESTART}
volumes:
- zammad-config-nginx:/etc/nginx/sites-enabled:ro
- zammad-var:/opt/zammad/var:ro
Expand All @@ -86,23 +87,8 @@ services:
- postgresql-data:/var/lib/postgresql/data

zammad-railsserver:
<<: *zammad-service
command: ["zammad-railsserver"]
depends_on:
- zammad-memcached
- zammad-postgresql
- zammad-redis
environment:
- MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
- POSTGRESQL_DB=${POSTGRES_DB}
- POSTGRESQL_HOST=${POSTGRES_HOST}
- POSTGRESQL_USER=${POSTGRES_USER}
- POSTGRESQL_PASS=${POSTGRES_PASS}
- POSTGRESQL_PORT=${POSTGRES_PORT}
- REDIS_URL=${REDIS_URL}
image: ${IMAGE_REPO}:${VERSION}
restart: ${RESTART}
volumes:
- zammad-var:/opt/zammad/var

zammad-redis:
image: redis:${REDIS_VERSION}
Expand All @@ -111,42 +97,12 @@ services:
- redis-data:/data

zammad-scheduler:
<<: *zammad-service
command: ["zammad-scheduler"]
depends_on:
- zammad-memcached
- zammad-railsserver
- zammad-redis
environment:
- MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
- POSTGRESQL_DB=${POSTGRES_DB}
- POSTGRESQL_HOST=${POSTGRES_HOST}
- POSTGRESQL_USER=${POSTGRES_USER}
- POSTGRESQL_PASS=${POSTGRES_PASS}
- POSTGRESQL_PORT=${POSTGRES_PORT}
- REDIS_URL=${REDIS_URL}
image: ${IMAGE_REPO}:${VERSION}
restart: ${RESTART}
volumes:
- zammad-var:/opt/zammad/var

zammad-websocket:
<<: *zammad-service
command: ["zammad-websocket"]
depends_on:
- zammad-memcached
- zammad-railsserver
- zammad-redis
environment:
- MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
- POSTGRESQL_DB=${POSTGRES_DB}
- POSTGRESQL_HOST=${POSTGRES_HOST}
- POSTGRESQL_USER=${POSTGRES_USER}
- POSTGRESQL_PASS=${POSTGRES_PASS}
- POSTGRESQL_PORT=${POSTGRES_PORT}
- REDIS_URL=${REDIS_URL}
image: ${IMAGE_REPO}:${VERSION}
restart: ${RESTART}
volumes:
- zammad-var:/opt/zammad/var

volumes:
elasticsearch-data:
Expand Down

0 comments on commit cb6a82d

Please sign in to comment.