-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzabbix-docker-compose.yml
118 lines (112 loc) · 3.36 KB
/
zabbix-docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
networks:
zabbix-network:
external: true
volumes:
zabbix-postgres:
zabbix-postgres-backup:
zabbix-database-backups:
services:
postgres:
image: ${ZABBIX_POSTGRES_IMAGE_TAG}
volumes:
- zabbix-postgres:/var/lib/postgresql/data
environment:
POSTGRES_DB: ${ZABBIX_DB_NAME}
POSTGRES_USER: ${ZABBIX_DB_USER}
POSTGRES_PASSWORD: ${ZABBIX_DB_PASSWORD}
networks:
- zabbix-network
healthcheck:
test: [ "CMD", "pg_isready", "-q", "-d", "${ZABBIX_DB_NAME}", "-U", "${ZABBIX_DB_USER}" ]
interval: 10s
timeout: 5s
retries: 3
start_period: 60s
restart: unless-stopped
zabbix-server:
image: ${ZABBIX_SERVER_IMAGE_TAG}
environment:
DB_SERVER_HOST: postgres
DB_SERVER_PORT: 5432
POSTGRES_DB: ${ZABBIX_DB_NAME}
POSTGRES_USER: ${ZABBIX_DB_USER}
POSTGRES_PASSWORD: ${ZABBIX_DB_PASSWORD}
ZBX_CACHESIZE: ${ZABBIX_CACHESIZE}
networks:
- zabbix-network
ports:
- "10051:10051"
healthcheck:
test: grep -qr "zabbix_server" /proc/*/status || exit 1
interval: 10s
timeout: 5s
retries: 3
start_period: 90s
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
zabbix-dashboard:
image: ${ZABBIX_WEB_IMAGE_TAG}
environment:
DB_SERVER_HOST: postgres
DB_SERVER_PORT: 5432
POSTGRES_DB: ${ZABBIX_DB_NAME}
POSTGRES_USER: ${ZABBIX_DB_USER}
POSTGRES_PASSWORD: ${ZABBIX_DB_PASSWORD}
ZBX_SERVER_HOST: zabbix-server
PHP_TZ: ${ZABBIX_TIMEZONE}
networks:
- zabbix-network
ports:
- "80:8080"
- "443:8443"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/"]
interval: 10s
timeout: 5s
retries: 3
start_period: 90s
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
zabbix-server:
condition: service_healthy
zabbix-agent:
image: ${ZABBIX_AGENT_IMAGE_TAG}
environment:
ZBX_HOSTNAME: Zabbix server
ZBX_SERVER_HOST: zabbix-server
networks:
- zabbix-network
restart: unless-stopped
depends_on:
- postgres
- zabbix-server
backups:
image: ${ZABBIX_POSTGRES_IMAGE_TAG}
command: >-
sh -c 'sleep $ZABBIX_BACKUP_INIT_SLEEP &&
while true; do
pg_dump -h postgres -p 5432 -d $ZABBIX_DB_NAME -U $ZABBIX_DB_USER | gzip > $ZABBIX_POSTGRES_BACKUPS_PATH/$ZABBIX_POSTGRES_BACKUP_NAME-$(date "+%Y-%m-%d_%H-%M").gz &&
find $ZABBIX_POSTGRES_BACKUPS_PATH -type f -mtime +$ZABBIX_POSTGRES_BACKUP_PRUNE_DAYS | xargs rm -f &&
sleep $ZABBIX_BACKUP_INTERVAL; done'
volumes:
- zabbix-postgres-backup:/var/lib/postgresql/data
- zabbix-database-backups:${ZABBIX_POSTGRES_BACKUPS_PATH}
environment:
ZABBIX_DB_NAME: ${ZABBIX_DB_NAME}
ZABBIX_DB_USER: ${ZABBIX_DB_USER}
PGPASSWORD: ${ZABBIX_DB_PASSWORD}
ZABBIX_BACKUP_INIT_SLEEP: ${ZABBIX_BACKUP_INIT_SLEEP}
ZABBIX_BACKUP_INTERVAL: ${ZABBIX_BACKUP_INTERVAL}
ZABBIX_POSTGRES_BACKUP_PRUNE_DAYS: ${ZABBIX_POSTGRES_BACKUP_PRUNE_DAYS}
ZABBIX_POSTGRES_BACKUPS_PATH: ${ZABBIX_POSTGRES_BACKUPS_PATH}
ZABBIX_POSTGRES_BACKUP_NAME: ${ZABBIX_POSTGRES_BACKUP_NAME}
networks:
- zabbix-network
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy