forked from mnadeem/prometheus-sql-exporter-usage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yaml
128 lines (118 loc) · 3.54 KB
/
docker-compose.yaml
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
119
120
121
122
123
124
125
126
127
128
version: "3.8"
services:
mssql:
image: mcr.microsoft.com/mssql/server
environment:
- SA_PASSWORD=P@ssw0rd
- ACCEPT_EULA=Y
volumes:
- ./data/db/mssql/scripts:/scripts/
ports:
- "1433:1433"
#entrypoint: /bin/bash
command:
- /bin/bash
- -c
- |
/opt/mssql/bin/sqlservr &
pid=$$!
echo "Waiting for MS SQL to be available ⏳"
/opt/mssql-tools/bin/sqlcmd -l 30 -S localhost -h-1 -V1 -U sa -P $$SA_PASSWORD -Q "SET NOCOUNT ON SELECT \"YAY WE ARE UP\" , @@servername"
is_up=$$?
while [ $$is_up -ne 0 ] ; do
echo -e $$(date)
/opt/mssql-tools/bin/sqlcmd -l 30 -S localhost -h-1 -V1 -U sa -P $$SA_PASSWORD -Q "SET NOCOUNT ON SELECT \"YAY WE ARE UP\" , @@servername"
is_up=$$?
sleep 5
done
for foo in /scripts/*.sql
do /opt/mssql-tools/bin/sqlcmd -U sa -P $$SA_PASSWORD -l 30 -e -i $$foo
done
echo "All scripts have been executed. Waiting for MS SQL(pid $$pid) to terminate."
wait $$pid
healthcheck:
test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$$SA_PASSWORD" -Q "SELECT 1" || exit 1
interval: 10s
timeout: 3s
retries: 10
start_period: 10s
postgres:
image: postgres
restart: always
environment:
- POSTGRES_DB=postgresdb
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgrespassword
- PGDATA=/var/lib/postgresql/data/pgdata
ports:
- 5432:5432
volumes:
- ./data/db/postgresql/data:/var/lib/postgresql
- ./data/db/postgresql/scripts/init.sql:/docker-entrypoint-initdb.d/init.sql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
mysql:
image: mysql
restart: always
volumes:
- ./data/db/mysql/data:/var/lib/mysql
- ./data/db/mysql/scripts:/docker-entrypoint-initdb.d
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: mysqldb
MYSQL_USER: testuser
MYSQL_PASSWORD: testuser
ports:
- "3306:3306"
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
timeout: 20s
retries: 10
volume_exporter:
image: mnadeem/volume_exporter
command: ["--volume-dir=mysql:/data/mysql", "--volume-dir=pgdata:/data/postgresql"]
volumes:
- ./data/db/mysql/data:/data/mysql
- ./data/db/postgresql/data:/data/postgresql
ports:
- 9889:9888
sql_exporter:
image: githubfree/sql_exporter:latest
command: ["--config.file=/etc/sql-exporter/sql-exporter.yaml"]
volumes:
- ./etc/sql-exporter:/etc/sql-exporter
ports:
- 9399:9399
depends_on:
mssql:
condition: service_healthy
mysql:
condition: service_healthy
postgres:
condition: service_healthy
prometheus:
image: prom/prometheus:latest
volumes:
- ./etc/prometheus.yaml:/etc/prometheus.yaml
entrypoint:
- /bin/prometheus
- --config.file=/etc/prometheus.yaml
ports:
- "9090:9090"
grafana:
image: grafana/grafana:7.4.0-ubuntu
volumes:
- ./data/grafana/datasources:/etc/grafana/provisioning/datasources
- ./data/grafana/dashboards-provisioning:/etc/grafana/provisioning/dashboards
- ./data/grafana/dashboards:/var/lib/grafana/dashboards
environment:
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
- GF_AUTH_DISABLE_LOGIN_FORM=true
ports:
- "3000:3000"
depends_on:
- sql_exporter