-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
128 lines (124 loc) · 3.17 KB
/
docker-compose.yml
File metadata and controls
128 lines (124 loc) · 3.17 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
services:
loadbalancer:
image: haproxy:2.7
container_name: loadbalancer
ports:
- "80:80" # Bind to all interfaces
volumes:
- ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
networks:
- app-network
depends_on:
webserver1:
condition: service_healthy
webserver2:
condition: service_healthy
deploy:
resources:
limits:
cpus: '0.5'
memory: 256M
reservations:
cpus: '0.25'
memory: 128M
healthcheck:
test: ["CMD", "haproxy", "-c", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
interval: 30s
timeout: 3s
retries: 3
start_period: 10s
webserver1:
build:
context: .
dockerfile: ./docker/webserver/Dockerfile
container_name: webserver1
environment:
- SPRING_DATASOURCE_URL=${DB_URL:-jdbc:postgresql://database:5432/surveydb}
- SPRING_DATASOURCE_USERNAME=${DB_USERNAME:-postgres}
- SPRING_DATASOURCE_PASSWORD=${DB_PASSWORD:-test123}
- APP_BASE_URL=${APP_BASE_URL:-http://localhost}
networks:
- app-network
- db-network
ports:
- "8080:8080" # Expose webserver1 for local access
depends_on:
database:
condition: service_healthy
deploy:
resources:
limits:
cpus: '1.0'
memory: 1G
reservations:
cpus: '0.5'
memory: 512M
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
interval: 30s
timeout: 3s
retries: 3
start_period: 40s
webserver2:
build:
context: .
dockerfile: ./docker/webserver/Dockerfile
container_name: webserver2
environment:
- SPRING_DATASOURCE_URL=${DB2_URL:-jdbc:postgresql://database:5432/surveydb}
- SPRING_DATASOURCE_USERNAME=${DB2_USERNAME:-postgres}
- SPRING_DATASOURCE_PASSWORD=${DB2_PASSWORD:-test123}
- APP_BASE_URL=${APP_BASE_URL:-http://localhost}
networks:
- app-network
- db-network
ports:
- "8081:8080" # Expose webserver2 on a different host port
depends_on:
database:
condition: service_healthy
deploy:
resources:
limits:
cpus: '1.0'
memory: 1G
reservations:
cpus: '0.5'
memory: 512M
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
interval: 30s
timeout: 3s
retries: 3
start_period: 40s
database:
build:
context: .
dockerfile: ./docker/db/Dockerfile
container_name: database
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-test123}
POSTGRES_DB: ${POSTGRES_DB:-surveydb}
ports:
- "5432:5432"
networks:
- db-network
deploy:
resources:
limits:
cpus: '1.0'
memory: 512M
reservations:
cpus: '0.5'
memory: 256M
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER:-postgres}"]
interval: 10s
timeout: 3s
retries: 5
start_period: 30s
networks:
app-network:
db-network:
internal: true