-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
158 lines (148 loc) · 4.26 KB
/
docker-compose.prod.yml
File metadata and controls
158 lines (148 loc) · 4.26 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
# Production Docker Compose for QR Code Based Survey App
# This file uses pre-built images from GitHub Container Registry
#
# Usage:
# 1. Download this file
# 2. (Optional) Create a .env file to customize settings
# 3. Run: docker compose -f docker-compose.prod.yml up -d
# 4. Access: http://localhost
#
# Environment Variables (optional, with defaults):
# POSTGRES_USER=postgres
# POSTGRES_PASSWORD=test123
# POSTGRES_DB=surveydb
# APP_BASE_URL=http://localhost
# IMAGE_TAG=latest (or specific version like v1.0.0)
services:
loadbalancer:
image: haproxy:2.7
container_name: survey-loadbalancer
ports:
- "80:80"
configs:
- source: haproxy_config
target: /usr/local/etc/haproxy/haproxy.cfg
networks:
- app-network
depends_on:
webserver1:
condition: service_healthy
webserver2:
condition: service_healthy
deploy:
resources:
limits:
cpus: '0.5'
memory: 256M
restart: unless-stopped
healthcheck:
test: ["CMD", "haproxy", "-c", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
interval: 30s
timeout: 3s
retries: 3
start_period: 10s
webserver1:
image: ghcr.io/sero583/java_survey_app-cloud_computing_2025-webserver:${IMAGE_TAG:-latest}
container_name: survey-webserver1
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://database:5432/${POSTGRES_DB:-surveydb}
- SPRING_DATASOURCE_USERNAME=${POSTGRES_USER:-postgres}
- SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD:-test123}
- APP_BASE_URL=${APP_BASE_URL:-http://localhost}
networks:
- app-network
- db-network
depends_on:
database:
condition: service_healthy
deploy:
resources:
limits:
cpus: '1.0'
memory: 1G
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
interval: 30s
timeout: 3s
retries: 3
start_period: 40s
webserver2:
image: ghcr.io/sero583/java_survey_app-cloud_computing_2025-webserver:${IMAGE_TAG:-latest}
container_name: survey-webserver2
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://database:5432/${POSTGRES_DB:-surveydb}
- SPRING_DATASOURCE_USERNAME=${POSTGRES_USER:-postgres}
- SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD:-test123}
- APP_BASE_URL=${APP_BASE_URL:-http://localhost}
networks:
- app-network
- db-network
depends_on:
database:
condition: service_healthy
deploy:
resources:
limits:
cpus: '1.0'
memory: 1G
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
interval: 30s
timeout: 3s
retries: 3
start_period: 40s
database:
image: ghcr.io/sero583/java_survey_app-cloud_computing_2025-database:${IMAGE_TAG:-latest}
container_name: survey-database
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-test123}
POSTGRES_DB: ${POSTGRES_DB:-surveydb}
volumes:
- survey-db-data:/var/lib/pgsql/data
networks:
- db-network
deploy:
resources:
limits:
cpus: '1.0'
memory: 512M
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]
interval: 10s
timeout: 3s
retries: 5
start_period: 30s
networks:
app-network:
driver: bridge
db-network:
driver: bridge
internal: true
volumes:
survey-db-data:
driver: local
configs:
haproxy_config:
content: |
global
log stdout format raw local0
defaults
log global
mode http
option httplog
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http_front
bind *:80
default_backend http_back
backend http_back
balance roundrobin
option httpchk GET /actuator/health
http-check expect status 200
server webserver1 webserver1:8080 check inter 10s fall 3 rise 2
server webserver2 webserver2:8080 check inter 10s fall 3 rise 2