From 850cde0309f6c63ab27a755f4c897baed6167ff5 Mon Sep 17 00:00:00 2001 From: Alexey Pustovalov Date: Sat, 21 Dec 2024 21:19:17 +0900 Subject: [PATCH] Added init services for DB schema create only to compose file --- compose_zabbix_components.yaml | 76 ++++++++++++++++++++++ docker-compose_v3_alpine_mysql_latest.yaml | 38 +++++++++-- docker-compose_v3_alpine_pgsql_latest.yaml | 38 +++++++++-- docker-compose_v3_centos_mysql_latest.yaml | 38 +++++++++-- docker-compose_v3_centos_pgsql_latest.yaml | 38 +++++++++-- docker-compose_v3_ol_mysql_latest.yaml | 38 +++++++++-- docker-compose_v3_ol_pgsql_latest.yaml | 38 +++++++++-- docker-compose_v3_ubuntu_mysql_latest.yaml | 34 ++++++++-- docker-compose_v3_ubuntu_pgsql_latest.yaml | 34 ++++++++-- 9 files changed, 340 insertions(+), 32 deletions(-) diff --git a/compose_zabbix_components.yaml b/compose_zabbix_components.yaml index ece0cb2ed..b4e31b004 100644 --- a/compose_zabbix_components.yaml +++ b/compose_zabbix_components.yaml @@ -62,6 +62,54 @@ services: com.zabbix.company: "Zabbix LLC" com.zabbix.component: "zabbix-server" + server-mysql-db-init: + init: true + attach: true + volumes: + - /etc/localtime:/etc/localtime:ro + - ${DATA_DIRECTORY}/var/lib/zabbix/dbscripts:/var/lib/zabbix/dbscripts:ro + - ${DATA_DIRECTORY}/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro + command: init_db_only + tmpfs: /tmp +# volumes: +# - dbsocket:/var/run/mysqld/ + env_file: + - ${ENV_VARS_DIRECTORY}/.env_db_mysql + secrets: + - MYSQL_USER + - MYSQL_PASSWORD +# - client-key.pem +# - client-cert.pem +# - root-ca.pem + networks: + database: + aliases: + - zabbix-server-mysql-init + labels: + com.zabbix.description: "Zabbix server with MySQL database support (database init)" + com.zabbix.dbtype: "mysql" + + server-pgsql-db-init: + init: true + attach: true +# volumes: +# - ${ENV_VARS_DIRECTORY}/.ZBX_DB_CA_FILE:/run/secrets/root-ca.pem:ro +# - ${ENV_VARS_DIRECTORY}/.ZBX_DB_CERT_FILE:/run/secrets/client-cert.pem:ro +# - ${ENV_VARS_DIRECTORY}/.ZBX_DB_KEY_FILE:/run/secrets/client-key.pem:ro + command: init_db_only + env_file: + - ${ENV_VARS_DIRECTORY}/.env_db_pgsql + secrets: + - POSTGRES_USER + - POSTGRES_PASSWORD + networks: + database: + aliases: + - zabbix-server-pgsql-init + labels: + com.zabbix.description: "Zabbix server with PostgreSQL database support (database init)" + com.zabbix.dbtype: "pgsql" + server-mysql: extends: service: server @@ -171,6 +219,34 @@ services: com.zabbix.description: "Zabbix proxy with SQLite3 database support" com.zabbix.dbtype: "sqlite3" + proxy-mysql-db-init: + init: true + profiles: + - all + attach: true + volumes: + - /etc/localtime:/etc/localtime:ro + - ${DATA_DIRECTORY}/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro + command: init_db_only + tmpfs: /tmp +# volumes: +# - dbsocket:/var/run/mysqld/ + env_file: + - ${ENV_VARS_DIRECTORY}/.env_db_mysql_proxy + secrets: + - MYSQL_USER + - MYSQL_PASSWORD +# - client-key.pem +# - client-cert.pem +# - root-ca.pem + networks: + database: + aliases: + - zabbix-proxy-mysql-init + labels: + com.zabbix.description: "Zabbix proxy with MySQL database support (database init)" + com.zabbix.dbtype: "mysql" + proxy-mysql: extends: service: proxy diff --git a/docker-compose_v3_alpine_mysql_latest.yaml b/docker-compose_v3_alpine_mysql_latest.yaml index 35a42509d..ad3ee4575 100644 --- a/docker-compose_v3_alpine_mysql_latest.yaml +++ b/docker-compose_v3_alpine_mysql_latest.yaml @@ -1,4 +1,30 @@ services: + server-db-init: + extends: + file: compose_zabbix_components.yaml + service: server-mysql-db-init + image: "${ZABBIX_SERVER_MYSQL_IMAGE}:${ZABBIX_ALPINE_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" + volumes: + - /etc/timezone:/etc/timezone:ro + depends_on: + mysql-server: + condition: service_started + labels: + com.zabbix.os: "${ALPINE_OS_TAG}" + + proxy-db-init: + extends: + file: compose_zabbix_components.yaml + service: proxy-mysql-db-init + image: "${ZABBIX_PROXY_MYSQL_IMAGE}:${ZABBIX_ALPINE_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" + volumes: + - /etc/timezone:/etc/timezone:ro + depends_on: + mysql-server: + condition: service_started + labels: + com.zabbix.os: "${ALPINE_OS_TAG}" + zabbix-server: extends: file: compose_zabbix_components.yaml @@ -7,7 +33,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - mysql-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${ALPINE_OS_TAG}" @@ -29,7 +56,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - mysql-server + proxy-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${ALPINE_OS_TAG}" @@ -41,7 +69,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - mysql-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${ALPINE_OS_TAG}" @@ -53,7 +82,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - mysql-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${ALPINE_OS_TAG}" diff --git a/docker-compose_v3_alpine_pgsql_latest.yaml b/docker-compose_v3_alpine_pgsql_latest.yaml index ad2dbc096..a8dcd0fbe 100644 --- a/docker-compose_v3_alpine_pgsql_latest.yaml +++ b/docker-compose_v3_alpine_pgsql_latest.yaml @@ -1,4 +1,30 @@ services: + server-db-init: + extends: + file: compose_zabbix_components.yaml + service: server-pgsql-db-init + image: "${ZABBIX_SERVER_PGSQL_IMAGE}:${ZABBIX_ALPINE_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" + volumes: + - /etc/timezone:/etc/timezone:ro + depends_on: + postgres-server: + condition: service_started + labels: + com.zabbix.os: "${ALPINE_OS_TAG}" + + proxy-db-init: + extends: + file: compose_zabbix_components.yaml + service: proxy-mysql-db-init + image: "${ZABBIX_PROXY_MYSQL_IMAGE}:${ZABBIX_ALPINE_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" + volumes: + - /etc/timezone:/etc/timezone:ro + depends_on: + mysql-server: + condition: service_started + labels: + com.zabbix.os: "${ALPINE_OS_TAG}" + zabbix-server: extends: file: compose_zabbix_components.yaml @@ -7,7 +33,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - postgres-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${ALPINE_OS_TAG}" @@ -29,7 +56,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - mysql-server + proxy-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${ALPINE_OS_TAG}" @@ -41,7 +69,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - postgres-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${ALPINE_OS_TAG}" @@ -53,7 +82,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - postgres-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${ALPINE_OS_TAG}" diff --git a/docker-compose_v3_centos_mysql_latest.yaml b/docker-compose_v3_centos_mysql_latest.yaml index 63dc08867..51b1e28da 100644 --- a/docker-compose_v3_centos_mysql_latest.yaml +++ b/docker-compose_v3_centos_mysql_latest.yaml @@ -1,4 +1,30 @@ services: + server-db-init: + extends: + file: compose_zabbix_components.yaml + service: server-mysql-db-init + image: "${ZABBIX_SERVER_MYSQL_IMAGE}:${ZABBIX_CENTOS_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" + volumes: + - /etc/timezone:/etc/timezone:ro + depends_on: + mysql-server: + condition: service_started + labels: + com.zabbix.os: "${CENTOS_OS_TAG}" + + proxy-db-init: + extends: + file: compose_zabbix_components.yaml + service: proxy-mysql-db-init + image: "${ZABBIX_PROXY_MYSQL_IMAGE}:${ZABBIX_CENTOS_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" + volumes: + - /etc/timezone:/etc/timezone:ro + depends_on: + mysql-server: + condition: service_started + labels: + com.zabbix.os: "${CENTOS_OS_TAG}" + zabbix-server: extends: file: compose_zabbix_components.yaml @@ -7,7 +33,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - mysql-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${CENTOS_OS_TAG}" @@ -29,7 +56,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - mysql-server + proxy-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${CENTOS_OS_TAG}" @@ -41,7 +69,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - mysql-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${CENTOS_OS_TAG}" @@ -53,7 +82,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - mysql-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${CENTOS_OS_TAG}" diff --git a/docker-compose_v3_centos_pgsql_latest.yaml b/docker-compose_v3_centos_pgsql_latest.yaml index ce9ad67ab..f80faf700 100644 --- a/docker-compose_v3_centos_pgsql_latest.yaml +++ b/docker-compose_v3_centos_pgsql_latest.yaml @@ -1,4 +1,30 @@ services: + server-db-init: + extends: + file: compose_zabbix_components.yaml + service: server-pgsql-db-init + image: "${ZABBIX_SERVER_PGSQL_IMAGE}:${ZABBIX_CENTOS_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" + volumes: + - /etc/timezone:/etc/timezone:ro + depends_on: + postgres-server: + condition: service_started + labels: + com.zabbix.os: "${CENTOS_OS_TAG}" + + proxy-db-init: + extends: + file: compose_zabbix_components.yaml + service: proxy-mysql-db-init + image: "${ZABBIX_PROXY_MYSQL_IMAGE}:${ZABBIX_CENTOS_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" + volumes: + - /etc/timezone:/etc/timezone:ro + depends_on: + mysql-server: + condition: service_started + labels: + com.zabbix.os: "${CENTOS_OS_TAG}" + zabbix-server: extends: file: compose_zabbix_components.yaml @@ -7,7 +33,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - postgres-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${CENTOS_OS_TAG}" @@ -29,7 +56,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - mysql-server + proxy-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${CENTOS_OS_TAG}" @@ -41,7 +69,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - postgres-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${CENTOS_OS_TAG}" @@ -53,7 +82,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - postgres-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${CENTOS_OS_TAG}" diff --git a/docker-compose_v3_ol_mysql_latest.yaml b/docker-compose_v3_ol_mysql_latest.yaml index 772e8f56d..a29c8ea6f 100644 --- a/docker-compose_v3_ol_mysql_latest.yaml +++ b/docker-compose_v3_ol_mysql_latest.yaml @@ -1,4 +1,30 @@ services: + server-db-init: + extends: + file: compose_zabbix_components.yaml + service: server-mysql-db-init + image: "${ZABBIX_SERVER_MYSQL_IMAGE}:${ZABBIX_OL_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" + volumes: + - /etc/timezone:/etc/timezone:ro + depends_on: + mysql-server: + condition: service_started + labels: + com.zabbix.os: "${OL_OS_TAG}" + + proxy-db-init: + extends: + file: compose_zabbix_components.yaml + service: proxy-mysql-db-init + image: "${ZABBIX_PROXY_MYSQL_IMAGE}:${ZABBIX_OL_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" + volumes: + - /etc/timezone:/etc/timezone:ro + depends_on: + mysql-server: + condition: service_started + labels: + com.zabbix.os: "${OL_OS_TAG}" + zabbix-server: extends: file: compose_zabbix_components.yaml @@ -7,7 +33,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - mysql-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${OL_OS_TAG}" @@ -29,7 +56,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - mysql-server + proxy-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${OL_OS_TAG}" @@ -41,7 +69,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - mysql-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${OL_OS_TAG}" @@ -53,7 +82,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - mysql-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${OL_OS_TAG}" diff --git a/docker-compose_v3_ol_pgsql_latest.yaml b/docker-compose_v3_ol_pgsql_latest.yaml index 899b0e5c2..ad51b49a0 100644 --- a/docker-compose_v3_ol_pgsql_latest.yaml +++ b/docker-compose_v3_ol_pgsql_latest.yaml @@ -1,4 +1,30 @@ services: + server-db-init: + extends: + file: compose_zabbix_components.yaml + service: server-pgsql-db-init + image: "${ZABBIX_SERVER_PGSQL_IMAGE}:${ZABBIX_OL_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" + volumes: + - /etc/timezone:/etc/timezone:ro + depends_on: + postgres-server: + condition: service_started + labels: + com.zabbix.os: "${OL_OS_TAG}" + + proxy-db-init: + extends: + file: compose_zabbix_components.yaml + service: proxy-mysql-db-init + image: "${ZABBIX_PROXY_MYSQL_IMAGE}:${ZABBIX_OL_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" + volumes: + - /etc/timezone:/etc/timezone:ro + depends_on: + mysql-server: + condition: service_started + labels: + com.zabbix.os: "${OL_OS_TAG}" + zabbix-server: extends: file: compose_zabbix_components.yaml @@ -7,7 +33,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - postgres-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${OL_OS_TAG}" @@ -29,7 +56,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - mysql-server + proxy-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${OL_OS_TAG}" @@ -41,7 +69,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - postgres-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${OL_OS_TAG}" @@ -53,7 +82,8 @@ services: volumes: - /etc/timezone:/etc/timezone:ro depends_on: - - postgres-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${OL_OS_TAG}" diff --git a/docker-compose_v3_ubuntu_mysql_latest.yaml b/docker-compose_v3_ubuntu_mysql_latest.yaml index 39c5409ff..5510b0df6 100644 --- a/docker-compose_v3_ubuntu_mysql_latest.yaml +++ b/docker-compose_v3_ubuntu_mysql_latest.yaml @@ -1,11 +1,34 @@ services: + server-db-init: + extends: + file: compose_zabbix_components.yaml + service: server-mysql-db-init + image: "${ZABBIX_SERVER_MYSQL_IMAGE}:${ZABBIX_UBUNTU_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" + depends_on: + mysql-server: + condition: service_started + labels: + com.zabbix.os: "${UBUNTU_OS_TAG}" + + proxy-db-init: + extends: + file: compose_zabbix_components.yaml + service: proxy-mysql-db-init + image: "${ZABBIX_PROXY_MYSQL_IMAGE}:${ZABBIX_UBUNTU_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" + depends_on: + mysql-server: + condition: service_started + labels: + com.zabbix.os: "${UBUNTU_OS_TAG}" + zabbix-server: extends: file: compose_zabbix_components.yaml service: server-mysql image: "${ZABBIX_SERVER_MYSQL_IMAGE}:${ZABBIX_UBUNTU_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" depends_on: - - mysql-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${UBUNTU_OS_TAG}" @@ -23,7 +46,8 @@ services: service: proxy-mysql image: "${ZABBIX_PROXY_MYSQL_IMAGE}:${ZABBIX_UBUNTU_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" depends_on: - - mysql-server + proxy-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${UBUNTU_OS_TAG}" @@ -33,7 +57,8 @@ services: service: web-apache-mysql image: "${ZABBIX_WEB_APACHE_MYSQL_IMAGE}:${ZABBIX_UBUNTU_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" depends_on: - - mysql-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${UBUNTU_OS_TAG}" @@ -43,7 +68,8 @@ services: service: web-nginx-mysql image: "${ZABBIX_WEB_NGINX_MYSQL_IMAGE}:${ZABBIX_UBUNTU_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" depends_on: - - mysql-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${UBUNTU_OS_TAG}" diff --git a/docker-compose_v3_ubuntu_pgsql_latest.yaml b/docker-compose_v3_ubuntu_pgsql_latest.yaml index 9283e91f2..fecd0b3db 100644 --- a/docker-compose_v3_ubuntu_pgsql_latest.yaml +++ b/docker-compose_v3_ubuntu_pgsql_latest.yaml @@ -1,11 +1,34 @@ services: + server-db-init: + extends: + file: compose_zabbix_components.yaml + service: server-pgsql-db-init + image: "${ZABBIX_SERVER_PGSQL_IMAGE}:${ZABBIX_UBUNTU_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" + depends_on: + postgres-server: + condition: service_started + labels: + com.zabbix.os: "${UBUNTU_OS_TAG}" + + proxy-db-init: + extends: + file: compose_zabbix_components.yaml + service: proxy-mysql-db-init + image: "${ZABBIX_PROXY_MYSQL_IMAGE}:${ZABBIX_UBUNTU_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" + depends_on: + mysql-server: + condition: service_started + labels: + com.zabbix.os: "${UBUNTU_OS_TAG}" + zabbix-server: extends: file: compose_zabbix_components.yaml service: server-pgsql image: "${ZABBIX_SERVER_PGSQL_IMAGE}:${ZABBIX_UBUNTU_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" depends_on: - - postgres-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${UBUNTU_OS_TAG}" @@ -23,7 +46,8 @@ services: service: proxy-mysql image: "${ZABBIX_PROXY_MYSQL_IMAGE}:${ZABBIX_UBUNTU_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" depends_on: - - mysql-server + proxy-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${UBUNTU_OS_TAG}" @@ -33,7 +57,8 @@ services: service: web-apache-pgsql image: "${ZABBIX_WEB_APACHE_PGSQL_IMAGE}:${ZABBIX_UBUNTU_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" depends_on: - - postgres-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${UBUNTU_OS_TAG}" @@ -43,7 +68,8 @@ services: service: web-nginx-pgsql image: "${ZABBIX_WEB_NGINX_PGSQL_IMAGE}:${ZABBIX_UBUNTU_IMAGE_TAG}${ZABBIX_IMAGE_TAG_POSTFIX}" depends_on: - - postgres-server + server-db-init: + condition: service_completed_successfully labels: com.zabbix.os: "${UBUNTU_OS_TAG}"