-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
161 lines (153 loc) · 4.18 KB
/
docker-compose.yml
File metadata and controls
161 lines (153 loc) · 4.18 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
version: '3.8'
services:
# MySQL Service for test databases
mysql-service:
image: mysql:8.0
container_name: gosqlguard-mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: test-password
MYSQL_DATABASE: db1
MYSQL_USER: backup-user
MYSQL_PASSWORD: test-password
ports:
- "3306:3306"
- "33306:3306"
volumes:
- mysql_data:/var/lib/mysql
- ./init/mysql:/docker-entrypoint-initdb.d
networks:
- gosqlguard_network
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 5s
timeout: 5s
retries: 5
# PostgreSQL Service for test databases
postgres-service:
image: postgres:14
container_name: gosqlguard-postgres
restart: unless-stopped
environment:
POSTGRES_PASSWORD: test-password
POSTGRES_USER: backup-user
POSTGRES_DB: db1
ports:
- "5432:5432"
- "54332:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./init/postgres:/docker-entrypoint-initdb.d
networks:
- gosqlguard_network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U backup-user"]
interval: 5s
timeout: 5s
retries: 5
# MinIO (S3-compatible storage)
minio:
image: minio/minio
container_name: gosqlguard-minio
restart: unless-stopped
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
ports:
- "9000:9000" # API
- "9001:9001" # Console
volumes:
- minio_data:/data
networks:
- gosqlguard_network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 5s
timeout: 5s
retries: 5
# Create MinIO buckets
minio-setup:
image: minio/mc
container_name: gosqlguard-minio-setup
depends_on:
minio:
condition: service_healthy
entrypoint: >
/bin/sh -c "
# Configure MinIO client
/usr/bin/mc config host add myminio http://minio:9000 minioadmin minioadmin;
# Create bucket with parents flag
/usr/bin/mc mb -p myminio/gosqlguard-backups;
# Set bucket policy
/usr/bin/mc policy set public myminio/gosqlguard-backups;
# Add test file to verify bucket is working
echo 'Test file for GoSQLGuard' > /tmp/test.txt;
/usr/bin/mc cp /tmp/test.txt myminio/gosqlguard-backups/test.txt;
echo 'MinIO setup complete with test file';
exit 0;
"
networks:
- gosqlguard_network
# MySQL Configuration Database (Sidecar)
config-mysql:
image: mysql:8.0
container_name: gosqlguard-config-mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: config-password
MYSQL_DATABASE: gosqlguard_config
MYSQL_USER: gosqlguard
MYSQL_PASSWORD: config-password
volumes:
- config_mysql_data:/var/lib/mysql
- ./deployments/mysql-sidecar/init:/docker-entrypoint-initdb.d
networks:
- gosqlguard_network
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 5s
timeout: 5s
retries: 5
# GoSQLGuard Service
gosqlguard:
build:
context: .
dockerfile: Dockerfile
container_name: gosqlguard-controller
restart: unless-stopped
depends_on:
config-mysql:
condition: service_healthy
mysql-service:
condition: service_healthy
postgres-service:
condition: service_healthy
minio-setup:
condition: service_completed_successfully
environment:
DEBUG: "true"
METRICS_PORT: "8080"
# Configuration database connection
CONFIG_MYSQL_HOST: config-mysql
CONFIG_MYSQL_PORT: "3306"
CONFIG_MYSQL_DATABASE: gosqlguard_config
CONFIG_MYSQL_USER: gosqlguard
CONFIG_MYSQL_PASSWORD: config-password
volumes:
- gosqlguard_backups:/app/backups
- gosqlguard_metadata:/app/metadata
ports:
- "8888:8080" # Admin UI
networks:
- gosqlguard_network
volumes:
mysql_data:
postgres_data:
minio_data:
config_mysql_data:
gosqlguard_backups:
gosqlguard_metadata:
networks:
gosqlguard_network:
driver: bridge