-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
116 lines (110 loc) · 2.88 KB
/
Copy pathdocker-compose.yml
File metadata and controls
116 lines (110 loc) · 2.88 KB
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
version: '3.8'
services:
# PostgreSQL database for testing
postgres:
image: postgres:15-alpine
container_name: postgres-test
environment:
POSTGRES_DB: testdb
POSTGRES_USER: testuser
POSTGRES_PASSWORD: testpass
POSTGRES_INITDB_ARGS: "--auth-host=scram-sha-256"
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./docker/postgres-init:/docker-entrypoint-initdb.d
command: >
postgres
-c log_statement=all
-c log_destination=stderr
-c logging_collector=on
-c log_directory=/var/log/postgresql
-c log_filename=postgresql-%Y-%m-%d_%H%M%S.log
-c log_rotation_age=1d
-c log_rotation_size=100MB
networks:
- sniffer-network
# PostgreSQL Query Sniffer in network mode
sniffer-network:
build: .
container_name: postgresql-sniffer-network
environment:
- JAVA_OPTS=-Xmx512m -Xms256m
- ALLOW_ROOT=true
command: >
--mode NETWORK
--host postgres
--port 5432
--duration 300
--output-dir /app/reports
--verbose
volumes:
- ./reports:/app/reports
- ./logs:/app/logs
depends_on:
- postgres
networks:
- sniffer-network
cap_add:
- NET_ADMIN
- NET_RAW
privileged: true
# PostgreSQL Query Sniffer in proxy mode
sniffer-proxy:
build: .
container_name: postgresql-sniffer-proxy
environment:
- JAVA_OPTS=-Xmx512m -Xms256m
command: >
--mode PROXY
--host postgres
--port 5432
--duration 300
--output-dir /app/reports
--verbose
ports:
- "5433:5433"
volumes:
- ./reports:/app/reports
- ./logs:/app/logs
depends_on:
- postgres
networks:
- sniffer-network
profiles:
- proxy
# Test application that generates queries
test-app:
image: postgres:15-alpine
container_name: postgres-test-client
environment:
- PGHOST=postgres
- PGPORT=5432
- PGDATABASE=testdb
- PGUSER=testuser
- PGPASSWORD=testpass
command: >
sh -c "
sleep 10 &&
while true; do
psql -c 'SELECT NOW(), version();' &&
psql -c 'CREATE TABLE IF NOT EXISTS test_table (id SERIAL PRIMARY KEY, name VARCHAR(100), created_at TIMESTAMP DEFAULT NOW());' &&
psql -c \"INSERT INTO test_table (name) VALUES ('test_' || extract(epoch from now()));\" &&
psql -c 'SELECT COUNT(*) FROM test_table;' &&
psql -c 'UPDATE test_table SET name = name || '_updated' WHERE id = (SELECT MAX(id) FROM test_table);' &&
psql -c 'DELETE FROM test_table WHERE id < (SELECT MAX(id) - 10 FROM test_table);' &&
sleep 30;
done
"
depends_on:
- postgres
networks:
- sniffer-network
profiles:
- test
volumes:
postgres_data:
networks:
sniffer-network:
driver: bridge