-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
92 lines (89 loc) · 2.89 KB
/
Copy pathdocker-compose.yml
File metadata and controls
92 lines (89 loc) · 2.89 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
# Local-only runner — convenient for quick iteration without kind.
#
# Two datasource backends are supported:
#
# Postgres (default):
# docker compose up -d postgres customer360
#
# MySQL 8 (compose profile "mysql"):
# SPRING_PROFILES_ACTIVE=mysql \
# docker compose --profile mysql up -d mysql customer360
#
# The Postgres service has no `profiles:` tag, so it starts on any
# `docker compose up` without arguments — backwards-compatible with the
# pre-existing flow. The MySQL service is tagged `profiles: [mysql]` so
# it only boots when explicitly requested.
#
# For the demo, prefer ./deploy_kind.sh (matches production topology).
services:
postgres:
image: postgres:16-alpine
container_name: customer360-postgres
environment:
POSTGRES_DB: customer360
POSTGRES_USER: customer360
POSTGRES_PASSWORD: customer360
PGDATA: /var/lib/postgresql/data/pgdata
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "pg_isready", "-U", "customer360", "-d", "customer360"]
interval: 5s
timeout: 3s
retries: 10
mysql:
image: mysql:8.0
container_name: customer360-mysql
profiles: ["mysql"]
environment:
MYSQL_DATABASE: customer360
MYSQL_USER: customer360
MYSQL_PASSWORD: customer360
MYSQL_ROOT_PASSWORD: customer360-root
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --default-authentication-plugin=caching_sha2_password
ports:
- "3306:3306"
volumes:
- mysqldata:/var/lib/mysql
healthcheck:
test:
- CMD
- mysqladmin
- ping
- -h
- localhost
- -u
- customer360
- -pcustomer360
interval: 5s
timeout: 3s
retries: 20
customer360:
build: .
container_name: customer360
image: customer360:local
# No depends_on block here — compose wires the right DB based on the
# profile. When the default compose profile runs, only `postgres` is
# reachable; when `--profile mysql` is used, only `mysql` is up.
env_file:
- .env
environment:
# Selects Spring profile; default keeps backwards compatibility.
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-postgres}
# The default below assumes the Postgres service. When running with
# --profile mysql the host command should override with:
# SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/customer360?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
SPRING_DATASOURCE_URL: ${SPRING_DATASOURCE_URL:-jdbc:postgresql://postgres:5432/customer360}
SPRING_DATASOURCE_USERNAME: ${SPRING_DATASOURCE_USERNAME:-customer360}
SPRING_DATASOURCE_PASSWORD: ${SPRING_DATASOURCE_PASSWORD:-customer360}
ports:
- "8080:8080"
restart: unless-stopped
volumes:
pgdata:
mysqldata: