-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcompose.yaml
More file actions
128 lines (120 loc) · 2.82 KB
/
Copy pathcompose.yaml
File metadata and controls
128 lines (120 loc) · 2.82 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
version: '3.9'
services:
mysql:
build:
context: ./containers/mysql
environment:
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/mysql_root_password
MYSQL_DATABASE: taskapp
MYSQL_USER: taskapp_user
MYSQL_PASSWORD_FILE: /run/secrets/mysql_user_password
secrets:
- mysql_root_password
- mysql_user_password
volumes:
- mysql_data:/var/lib/mysql
ports:
- "3306:3306"
migrator:
build:
context: ./containers/migrator
depends_on:
- mysql
environment:
DB_HOST: mysql
DB_NAME: taskapp
DB_PORT: "3306"
DB_USERNAME: taskapp_user
command: >
sh -c '
bash /migrator/migrate.sh $$DB_HOST $$DB_PORT $$DB_NAME $$DB_USERNAME /run/secrets/mysql_user_password up
'
secrets:
- mysql_user_password
api:
build:
context: .
dockerfile: ./containers/api/Dockerfile
depends_on:
- mysql
healthcheck:
test: "curl -f http://localhost:8180/healthz || exit 1"
interval: 10s
timeout: 10s
retries: 3
start_period: 30s
command:
- "server"
- "--config-file=/run/secrets/api_config"
secrets:
- api_config
nginx-api:
build:
context: ./containers/nginx-api
depends_on:
api:
condition: service_healthy
healthcheck:
test: "curl -H 'Host: api' -f http://localhost:80/healthz || exit 1"
interval: 10s
timeout: 10s
retries: 3
start_period: 30s
environment:
NGINX_PORT: 80
SERVER_NAME: api
BACKEND_HOST: api:8180
BACKEND_MAX_FAILS: 3
BACKEND_FAIL_TIMEOUT: 10s
ports:
- "9180:80"
web:
build:
context: .
dockerfile: ./containers/web/Dockerfile
depends_on:
- nginx-api
healthcheck:
test: "curl -f http://localhost:8280/healthz || exit 1"
interval: 10s
timeout: 10s
retries: 3
start_period: 30s
command:
- "server"
- "--api-address=http://nginx-api:80"
volumes:
- assets_data:/go/src/github.com/gihyodocker/taskapp/assets
nginx-web:
build:
context: ./containers/nginx-web
depends_on:
web:
condition: service_healthy
healthcheck:
test: "curl -f http://localhost:80/healthz || exit 1"
interval: 10s
timeout: 10s
retries: 3
start_period: 30s
environment:
NGINX_PORT: 80
SERVER_NAME: localhost
ASSETS_DIR: /var/www/assets
BACKEND_HOST: web:8280
BACKEND_MAX_FAILS: 3
BACKEND_FAIL_TIMEOUT: 10s
ports:
- "9280:80"
volumes:
- assets_data:/var/www/assets
secrets:
mysql_root_password:
file: ./secrets/mysql_root_password
mysql_user_password:
file: ./secrets/mysql_user_password
api_config:
file: ./api-config.yaml
volumes:
mysql_data:
assets_data: