diff --git a/compose_zabbix_components.yaml b/compose_zabbix_components.yaml index 38e241342..efc4d0213 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 @@ -172,6 +220,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 672dbf543..ff01077f4 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 bcc2747b7..661d4d913 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 b3ef5dd6a..b53c4c326 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 07691427e..8e9dc40bf 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 0d82bade7..d42dd86bd 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 dd70329d4..a88d81f16 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 b6ea6a248..a9186d363 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 e7af9ac8d..44dc8bb87 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}"