-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathdocker-compose.yml
137 lines (129 loc) · 4.17 KB
/
docker-compose.yml
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
version: "3.8"
volumes:
mysql:
postgres:
stan:
services:
mysql:
image: "mysql:5.7" # We're using 5.7.
container_name: "mono_mysql"
restart: "always"
ports:
- "${mono_mysql_addr_port:-0}:3306"
volumes:
- "mysql:/var/lib/mysql"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
postgres:
image: "postgres:12.7" # We're using 12.
container_name: "mono_postgres"
restart: "always"
shm_size: "256m"
ports:
- "${mono_postgres_addr_port:-0}:5432"
volumes:
- "postgres:/var/lib/postgresql/data"
- "${mono_postgres_tls_cert}:/dev.crt"
- "${mono_postgres_tls_key}:/dev.key"
environment:
POSTGRES_PASSWORD: "postgres"
entrypoint:
- bash
- -c
- |
set -x -e -o pipefail
install -m 0440 -o root -g postgres /dev.crt /server.crt
install -m 0440 -o root -g postgres /dev.key /server.key
exec docker-entrypoint.sh postgres -c ssl=on \
--ssl_cert_file=/server.crt --ssl_key_file=/server.key
postgres-setup:
depends_on:
- postgres
image: "postgres:12.7" # We're using 12.
container_name: "mono_postgres-setup"
restart: "no"
volumes:
- "./scripts/postgres-setup:/usr/local/bin/postgres-setup"
environment:
MONO__AUTH_POSTGRES_AUTH_LOGIN: "${MONO__AUTH_POSTGRES_AUTH_LOGIN}"
MONO__AUTH_POSTGRES_AUTH_PASS: "${MONO__AUTH_POSTGRES_AUTH_PASS}"
PGHOST: "postgres"
PGUSER: "postgres"
PGPASSWORD: "postgres"
command:
- bash
- -c
- |
while ! timeout --foreground 0.5 bash -c "echo -n >/dev/tcp/$${PGHOST}/$${PGPORT:-5432}" 2>/dev/null; do
echo waiting for postgres
sleep 0.5
done
set -x -e -o pipefail
postgres-setup | psql
nats:
image: "nats:2.2.6" # This is the latest version at the moment.
container_name: mono_nats
restart: always
ports:
- "${mono_nats_addr_port:-0}:4222"
stan:
image: "nats-streaming:0.21.2" # This is the latest version at the moment.
container_name: mono_stan
restart: always
volumes:
- "stan:/data"
command:
- "--cluster_id=local"
- "--max_channels=0"
- "--max_subs=0"
- "--max_msgs=0"
- "--max_bytes=0"
- "--max_age=0s"
- "--max_inactivity=0s"
- "--nats_server=nats://nats:4222"
- "--hb_interval=1s"
- "--hb_timeout=1s"
- "--hb_fail_count=3"
- "--store=FILE"
- "--dir=/data"
- "--file_fds_limit=4000"
mono:
build:
context: .
dockerfile: use `./scripts/build` instead of `docker-compose build`
image: "go-monolith-example:latest"
container_name: mono_mono
restart: always
ports:
- "${MONO_MONO_ADDR_PORT:-0}:17000"
- "${MONO_AUTH_ADDR_PORT:-0}:17003"
- "${MONO_AUTH_ADDR_PORT_INT:-0}:17004"
- "${MONO_AUTH_GRPCGW_ADDR_PORT:-0}:17006"
- "${MONO_AUTH_METRICS_ADDR_PORT:-0}:17005"
- "${MONO_EXAMPLE_ADDR_PORT:-0}:17001"
- "${MONO_EXAMPLE_METRICS_ADDR_PORT:-0}:17002"
volumes:
- "${MONO_TLS_CA_CERT}:/ca.crt"
- "${MONO__AUTH_TLS_CERT}:/auth.crt"
- "${MONO__AUTH_TLS_CERT_INT}:/auth-int.crt"
- "${MONO__AUTH_TLS_KEY}:/auth.key"
- "${MONO__AUTH_TLS_KEY_INT}:/auth-int.key"
environment:
MONO_ADDR_HOST: "${MONO_ADDR_HOST}"
MONO_ADDR_HOST_INT: "${MONO_ADDR_HOST_INT}"
MONO_AUTH_ADDR_HOST: "${MONO_AUTH_ADDR_HOST}"
MONO_AUTH_ADDR_HOST_INT: "${MONO_AUTH_ADDR_HOST_INT}"
MONO_TLS_CA_CERT: "/ca.crt"
MONO_X_MYSQL_ADDR_HOST: "mysql"
MONO_X_NATS_ADDR_URLS: "nats://nats:4222"
MONO_X_POSTGRES_ADDR_HOST: "postgres"
MONO_X_STAN_CLUSTER_ID: "local"
MONO__AUTH_POSTGRES_AUTH_LOGIN: "${MONO__AUTH_POSTGRES_AUTH_LOGIN}"
MONO__AUTH_POSTGRES_AUTH_PASS: "${MONO__AUTH_POSTGRES_AUTH_PASS}"
MONO__AUTH_SECRET: "${MONO__AUTH_SECRET}"
MONO__AUTH_TLS_CERT: "/auth.crt"
MONO__AUTH_TLS_CERT_INT: "/auth-int.crt"
MONO__AUTH_TLS_KEY: "/auth.key"
MONO__AUTH_TLS_KEY_INT: "/auth-int.key"
MONO__EXAMPLE_MYSQL_AUTH_LOGIN: "${MONO__EXAMPLE_MYSQL_AUTH_LOGIN}"
MONO__EXAMPLE_MYSQL_AUTH_PASS: "${MONO__EXAMPLE_MYSQL_AUTH_PASS}"