-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
138 lines (133 loc) · 4.2 KB
/
docker-compose.yml
File metadata and controls
138 lines (133 loc) · 4.2 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
services:
postgres:
image: postgres:15
container_name: db-server-postgres
restart: always
environment:
# Master admin user - used for creating databases for projects
POSTGRES_USER: ${DB_SERVER_ADMIN_USER:-dbadmin}
POSTGRES_PASSWORD: ${DB_SERVER_ADMIN_PASSWORD:-dbadmin_secret_change_in_production}
# Initial database (can be empty or used for management)
POSTGRES_DB: ${DB_SERVER_INIT_DB:-postgres}
# PostgreSQL configuration for multi-database setup
POSTGRES_INITDB_ARGS: ${POSTGRES_INITDB_ARGS:--E UTF8 --locale=C}
env_file:
- .env
ports:
# Expose for direct management (restrict to localhost)
- "127.0.0.1:${DB_SERVER_PORT:-5432}:5432"
volumes:
# Host directory bind mount - data stored on host filesystem for reliability
# This ensures data survives container/volume removal
- /data/db-server/postgres:/var/lib/postgresql/data
# Init scripts for automatic database creation
- ./scripts/db-server/init-databases.sh:/docker-entrypoint-initdb.d/01-init-databases.sh:ro
# Backup directory (mounted for easy access)
- ./backups:/backups:rw
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_SERVER_ADMIN_USER:-dbadmin} -d ${DB_SERVER_INIT_DB:-postgres}"]
interval: 10s
timeout: 5s
retries: 3
start_period: 10s
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
networks:
- nginx-network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
labels:
- "com.database.server=postgres"
- "com.database.version=15"
redis:
image: redis:7
container_name: db-server-redis
restart: always
command:
- redis-server
- --save ""
- --appendonly ${REDIS_APPENDONLY:-no}
- --maxmemory ${REDIS_MAXMEMORY:-256mb}
- --maxmemory-policy ${REDIS_MAXMEMORY_POLICY:-allkeys-lru}
env_file:
- .env
ports:
# Expose for direct management (restrict to localhost)
- "127.0.0.1:${REDIS_SERVER_PORT:-6379}:6379"
volumes:
# Host directory bind mount - data stored on host filesystem for reliability
- /data/db-server/redis:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 5
start_period: 10s
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 64M
networks:
- nginx-network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
labels:
- "com.database.server=redis"
- "com.database.version=7"
# Volumes removed - using host directory bind mounts for better reliability
# Data is stored on host filesystem: /data/db-server/postgres and /data/db-server/redis
# This ensures data survives container/volume removal
# Frontend: landing + admin panel (served at DOMAIN from .env on prod)
frontend:
build:
context: ./web
dockerfile: Dockerfile
container_name: db-server-frontend
ports:
- "127.0.0.1:${FRONTEND_PORT:-3390}:3390"
env_file:
- .env
environment:
- PORT=3390
- AUTH_SERVICE_URL=${AUTH_SERVICE_URL:-http://auth-microservice:3370}
- AUTH_SERVICE_PUBLIC_URL=${AUTH_SERVICE_PUBLIC_URL:-https://auth.statex.cz}
- DB_SERVER_POSTGRES_HOST=db-server-postgres
- DB_SERVER_PORT=${DB_SERVER_PORT:-5432}
- DB_SERVER_ADMIN_USER=${DB_SERVER_ADMIN_USER:-dbadmin}
- DB_SERVER_ADMIN_PASSWORD=${DB_SERVER_ADMIN_PASSWORD}
- DB_SERVER_INIT_DB=${DB_SERVER_INIT_DB:-postgres}
- DB_SERVER_REDIS_HOST=db-server-redis
- REDIS_SERVER_PORT=${REDIS_SERVER_PORT:-6379}
networks:
- nginx-network
depends_on:
- postgres
- redis
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://127.0.0.1:3390/health"]
interval: 10s
timeout: 5s
retries: 2
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 64M
networks:
nginx-network:
external: true
name: ${NGINX_NETWORK_NAME:-nginx-network}