Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
255 lines (247 loc) · 9.26 KB
/
Copy pathdocker-compose.yml
File metadata and controls
255 lines (247 loc) · 9.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# SITMUN Application Stack - Docker Compose Configuration
#
# ============================================================================
# Environment Configuration (.env files)
# ============================================================================
#
# This stack uses Docker Compose's environment file system:
#
# 1. .env (not committed) - Default development configuration
# - At least should include COMPOSE_PROFILES
# - Minimum content:
# COMPOSE_PROFILES=postgres
#
# 2. Profile files (profiles/*.env) - Predefined configurations
# - development-postgres.env: Development PostgreSQL (Liquibase seed in main DB)
# - development-oracle.env: Development Oracle (Liquibase seed in main DB)
# - postgres.env: Production with PostgreSQL (minimal seed data)
# - oracle.env: Production with Oracle (minimal seed data)
# - Optional profiles: ,demo (example demo DB; ,dev is a deprecated alias), ,mbtiles
#
# Docker Compose reads files in this order (last wins):
# .env → .env.local → Environment variables
#
# ============================================================================
# Quick Start
# ============================================================================
#
# Development (default):
# cp profiles/development-postgres.env .env
# docker compose up -d
#
# Production:
# cp profiles/postgres.env .env
# docker compose up -d
#
# Local customization:
# echo "PUBLIC_PORT=8080" >> .env.local
# docker compose up -d
#
# ============================================================================
# Default Configuration (from committed .env)
# ============================================================================
#
# Frontend:
# - ENVIRONMENT=development (shows "development", source maps enabled)
# - PUBLIC_PORT=9000 (http://localhost:9000)
#
# Backend / Compose:
# - DATABASE_TYPE=postgres
# - SITMUN_CONFIG_DIR=development/backend (Liquibase demo seed in main DB)
# - COMPOSE_PROFILES=postgres (main PostgreSQL only)
# - Optional: add ,demo for example demo DB (host port 9005; ,dev still works)
# - Optional: add ,mbtiles for edition-mobile tile export service
#
# Databases (when profiles enabled):
# - PostgreSQL on port 9003 (profile postgres)
# - Example demo DB on port 9005 (profile demo; alias dev)
# - MBTiles internal-only (profile mbtiles; no host port)
#
# ============================================================================
services:
front:
build:
context: .
dockerfile: front/Dockerfile
args:
- PUBLIC_BASE_PATH=${PUBLIC_BASE_PATH:-/}
- ENVIRONMENT=${ENVIRONMENT:-development}
restart: always
ports:
- "${LOCAL_PORT:-9000}:80"
environment:
- PUBLIC_URL_SCHEME=${PUBLIC_URL_SCHEME:-http}
- PUBLIC_HOSTNAME=${PUBLIC_HOSTNAME:-localhost}
- PUBLIC_PORT=${PUBLIC_PORT:-9000}
- PUBLIC_BASE_PATH=${PUBLIC_BASE_PATH:-/}
- LOCAL_BASE_PATH=${LOCAL_BASE_PATH:-/}
volumes:
- ./front/config:/etc/nginx/conf.d
- ./logs/front/nginx:/var/log/nginx
depends_on:
- backend
command: /bin/sh -c "envsubst '$${PUBLIC_URL_SCHEME},$${PUBLIC_HOSTNAME},$${PUBLIC_PORT},$${PUBLIC_BASE_PATH},$${LOCAL_BASE_PATH}' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost"]
interval: 30s
timeout: 30s
start_period: 5s
retries: 3
backend:
build: ./back/backend
ports:
- "9001:8080"
restart: always
environment:
- SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE:-${DATABASE_TYPE:-postgres}}
- SPRING_DATASOURCE_URL=${DATABASE_URL:-jdbc:postgresql://postgres:5432/}${DATABASE:-sitmun3}
- SPRING_DATASOURCE_USERNAME=${DATABASE_USERNAME:-sitmun3}
- SPRING_DATASOURCE_PASSWORD=${DATABASE_PASSWORD:-sitmun3}
- SPRING_LIQUIBASE_URL=${DATABASE_URL:-jdbc:postgresql://postgres:5432/}${DATABASE:-sitmun3}
- SPRING_LIQUIBASE_USER=${DATABASE_USERNAME:-sitmun3}
- SPRING_LIQUIBASE_PASSWORD=${DATABASE_PASSWORD:-sitmun3}
- SPRING_LIQUIBASE_CHANGE_LOG=${SPRING_LIQUIBASE_CHANGE_LOG:-file:/usr/src/config/liquibase/master.xml}
- SPRING_LIQUIBASE_CONTEXTS=${SPRING_LIQUIBASE_CONTEXTS:-dev}
- SPRING_JPA_DATABASE_PLATFORM=org.hibernate.dialect.PostgreSQLDialect
- SITMUN_PROXY_FORCE=${FORCE_USE_OF_PROXY:-false}
- SITMUN_PROXY_MIDDLEWARE_URL=${PUBLIC_URL_SCHEME:-http}://${PUBLIC_HOSTNAME:-localhost}:${PUBLIC_PORT:-9000}${PUBLIC_BASE_PATH:-/}middleware
- SITMUN_PROXY_MIDDLEWARE_VALIDATE_USER_ACCESS=${SITMUN_PROXY_MIDDLEWARE_VALIDATE_USER_ACCESS:-true}
- SITMUN_BACKEND_URL=${PUBLIC_URL_SCHEME:-http}://${PUBLIC_HOSTNAME:-localhost}:${PUBLIC_PORT:-9000}${PUBLIC_BASE_PATH:-/}backend
- SITMUN_USER_SECRET=${SITMUN_USER_SECRET:-dev-only-insecure-user-secret-32-bytes}
- SITMUN_PROXY_MIDDLEWARE_SECRET=${MIDDLEWARE_SECRET:-dev-only-insecure-middleware-secret}
- LOGGING_LEVEL_ROOT=${LOGGING_LEVEL_ROOT:-INFO}
- LOGGING_LEVEL_ORG_SITMUN=${LOGGING_LEVEL_ORG_SITMUN:-DEBUG}
- SPRING_JPA_HIBERNATE_DDL_AUTO=${SPRING_JPA_HIBERNATE_DDL_AUTO:-none}
- SPRING_DATASOURCE_HIKARI_CONNECTION_TIMEOUT=${HIKARI_CONNECTION_TIMEOUT:-60000}
volumes:
- ./profiles/${SITMUN_CONFIG_DIR:-development/backend}:/usr/src/config
depends_on:
postgres:
condition: service_healthy
required: false
oracle:
condition: service_healthy
required: false
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:8080/api/dashboard/health"]
interval: 30s
timeout: 30s
start_period: 60s
retries: 5
proxy:
build: ./back/proxy
restart: always
ports:
- "9002:8080"
depends_on:
backend:
condition: service_started
mbtiles:
condition: service_healthy
required: false
environment:
- SITMUN_BACKEND_CONFIG_URL=http://backend:8080/api/config/proxy
- SITMUN_BACKEND_CONFIG_SECRET=${MIDDLEWARE_SECRET:-dev-only-insecure-middleware-secret}
- SITMUN_MBTILES_URL=http://mbtiles:8080/mbtiles
- SITMUN_MBTILES_JOB_HANDLE_SECRET=${SITMUN_MBTILES_JOB_HANDLE_SECRET:-dev-only-insecure-mbtiles-job-handle-secret}
- LOGGING_LEVEL_ROOT=${LOGGING_LEVEL_ROOT:-INFO}
- LOGGING_LEVEL_ORG_SITMUN=${LOGGING_LEVEL_ORG_SITMUN:-DEBUG}
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:8080/actuator/health"]
interval: 30s
timeout: 30s
start_period: 5s
retries: 3
# Internally unauthenticated. Reachable only on the Compose network via middleware.
# Do not publish a host port; nginx must not route /mbtiles/**.
# Opt-in: COMPOSE_PROFILES must include mbtiles.
mbtiles:
profiles:
- mbtiles
build: ./back/mbtiles
restart: always
expose:
- "8080"
environment:
- SPRING_PROFILES_ACTIVE=${MBTILES_SPRING_PROFILES_ACTIVE:-prod}
- LOGGING_LEVEL_ROOT=${LOGGING_LEVEL_ROOT:-INFO}
- LOGGING_LEVEL_ORG_SITMUN=${LOGGING_LEVEL_ORG_SITMUN:-INFO}
volumes:
- mbtiles_tmp:/tmp/mbtiles
deploy:
resources:
limits:
memory: 1G
reservations:
memory: 256M
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:8080/actuator/health"]
interval: 30s
timeout: 30s
start_period: 40s
retries: 5
postgres:
profiles:
- postgres
image: postgres:16-alpine
restart: always
ports:
- "9003:5432"
environment:
POSTGRES_DB: ${DATABASE:-sitmun3}
POSTGRES_USER: ${DATABASE_USERNAME:-sitmun3}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD:-sitmun3}
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
# Test that PostgreSQL is accepting connections and can execute queries
test: ["CMD-SHELL", "pg_isready -U ${DATABASE_USERNAME:-sitmun3} -d ${DATABASE:-sitmun3} && psql -U ${DATABASE_USERNAME:-sitmun3} -d ${DATABASE:-sitmun3} -c 'SELECT 1' > /dev/null 2>&1"]
interval: 5s
timeout: 3s
start_period: 5s
retries: 5
oracle:
profiles:
- oracle
image: gvenzl/oracle-free:23-slim
restart: always
ports:
- "9004:1521"
environment:
ORACLE_PASSWORD: password
APP_USER: ${DATABASE_USERNAME:-sitmun3}
APP_USER_PASSWORD: ${DATABASE_PASSWORD:-sitmun3}
ORACLE_DATABASE: ${DATABASE:-sitmun3}
volumes:
- oradata:/opt/oracle/oradata
healthcheck:
# Test that the service is registered with the listener AND database accepts connections
test: |
bash -c '
lsnrctl status | grep -q "Service \"${DATABASE:-sitmun3}\"" &&
echo "SELECT 1 FROM DUAL;" | sqlplus -s ${DATABASE_USERNAME:-sitmun3}/${DATABASE_PASSWORD:-sitmun3}@//localhost:1521/${DATABASE:-sitmun3} | grep -q "1"
'
interval: 5s
timeout: 5s
start_period: 60s
retries: 20
example:
profiles:
- demo
- dev # deprecated alias for demo
image: postgres:16-alpine
restart: always
environment:
POSTGRES_DB: example
POSTGRES_USER: example
POSTGRES_PASSWORD: example
ports:
- "9005:5432"
volumes:
- example_data:/var/lib/postgresql/data
- ./profiles/development/demo-data:/docker-entrypoint-initdb.d
volumes:
pgdata:
oradata:
example_data:
mbtiles_tmp: