-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
169 lines (136 loc) · 4.45 KB
/
Copy pathdocker-compose.yml
File metadata and controls
169 lines (136 loc) · 4.45 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
162
163
164
165
166
167
168
169
services:
# ==================================================
# MySQL 8.4 (LTS)
# ==================================================
mysql:
image: mysql:8.4
container_name: mysql_db
restart: unless-stopped
networks:
- shared-net
environment:
# Container timezone
TZ: ${MYSQL_TZ}
# Root (superuser) password
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
# Application user (created at init)
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
# MySQL host access
- "${MYSQL_HOST_PORT}:3306"
volumes:
# Persistent MySQL data
- ${MYSQL_DATA_PATH}:/var/lib/mysql
# Initialization scripts:
# - ./mysql/init:/docker-entrypoint-initdb.d
# Custom scripts (if any)
- ./scripts:/scripts:ro
command:
# Allow remote connections
- --bind-address=0.0.0.0
# Disable reverse DNS lookups (recommended)
- --skip-name-resolve
# ==================================================
# MariaDB 11.4 (LTS)
# ==================================================
mariadb:
image: mariadb:11.4
container_name: mariadb_db
restart: unless-stopped
networks:
- shared-net
environment:
# Container timezone
TZ: ${MARIADB_TZ}
# Root (superuser) password
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}
# Application user (created at init)
MARIADB_USER: ${MARIADB_USER}
MARIADB_PASSWORD: ${MARIADB_PASSWORD}
ports:
# MariaDB host access
- "${MARIADB_HOST_PORT}:3306"
volumes:
# Persistent MariaDB data
- ${MARIADB_DATA_PATH}:/var/lib/mysql
# Initialization scripts:
# - ./mariadb/init:/docker-entrypoint-initdb.d
# Custom scripts (if any)
- ./scripts:/scripts:ro
command:
# Allow remote connections
- --bind-address=0.0.0.0
# Disable reverse DNS lookups
- --skip-name-resolve
# ==================================================
# PostgreSQL 18 (LTS track)
# ==================================================
postgres:
image: postgres:18.4
container_name: postgres_db
restart: unless-stopped
networks:
- shared-net
environment:
# Container timezone
TZ: ${POSTGRES_TZ}
# --------------------------------------------------
# PostgreSQL superuser (root-equivalent)
#
# IMPORTANT:
# PostgreSQL Docker image only supports ONE user
# via environment variables at initialization.
# We always keep this as 'postgres'.
# --------------------------------------------------
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ${POSTGRES_ROOT_PASSWORD}
# --------------------------------------------------
# Application user credentials
#
# These variables are NOT handled by PostgreSQL
# directly, but are consumed by:
# - init scripts (docker-entrypoint-initdb.d)
# - PgBouncer entrypoint script
# --------------------------------------------------
POSTGRES_USER_APP: ${POSTGRES_USER_APP}
POSTGRES_PASSWORD_APP: ${POSTGRES_PASSWORD_APP}
ports:
# Direct PostgreSQL access
# (admin tasks, migrations, debugging)
- "${POSTGRES_HOST_PORT}:5432"
volumes:
# Persistent PostgreSQL data
- ${POSTGRES_DATA_PATH}:/var/lib/postgresql
# Initialization scripts:
# - Create application user
# - Assign CREATEDB / CREATEROLE privileges
# NOTE: Scripts run ONLY if data directory is empty
- ./postgres/init:/docker-entrypoint-initdb.d
# ==================================================
# PgBouncer (PostgreSQL Connection Pooler)
# ==================================================
pgbouncer:
build: ./pgbouncer
container_name: pgbouncer
restart: unless-stopped
networks:
- shared-net
depends_on:
- postgres
ports:
# PgBouncer client access (applications / SQL clients)
- "${PGBOUNCER_PORT}:6432"
environment:
# Admin / auth user (must exist in PostgreSQL)
PGBOUNCER_AUTH_USER: ${PGBOUNCER_AUTH_USER}
PGBOUNCER_AUTH_PASSWORD: ${PGBOUNCER_AUTH_PASSWORD}
# Application user
PGBOUNCER_APP_USER: ${PGBOUNCER_APP_USER}
PGBOUNCER_APP_PASSWORD: ${PGBOUNCER_APP_PASSWORD}
volumes:
# PgBouncer runtime configuration only
- ./pgbouncer/pgbouncer.ini:/etc/pgbouncer/pgbouncer.ini
networks:
shared-net:
name: shared-net