This repository has been archived by the owner on Apr 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker-compose.yml
188 lines (182 loc) · 4.38 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
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
version: '3.8'
services:
frontend:
profiles: [ "deploy" ]
hostname: frontend
container_name: getby_frontend
image: getby_frontend:1.0
build:
context: frontend
dockerfile: frontend.Dockerfile
stop_signal: SIGINT
networks:
- front
deploy:
resources:
limits:
memory: 50M
reservations:
memory: 10M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 120s
environment:
- NODE_ENV=production
- NODE_CONFIG_LOGLEVEL=debug
- NPM_CONFIG_PREFIX=/home/getby/.npm-global
ports: ["80:80"]
backend:
profiles: [ "deploy" ]
hostname: backend
container_name: getby_backend
image: getby_backend:1.0
build:
context: backend
dockerfile: backend.Dockerfile
stop_signal: SIGINT
deploy:
resources:
limits:
memory: 100M
reservations:
memory: 40M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 120s
user: "getby"
restart: always
cap_drop: [ "ALL" ]
environment:
- UVICORN_PORT=8000
- UVICORN_HOST=0.0.0.0
- UVICORN_WORKERS=1
- POSTGRES_DB_FILE=${POSTGRES_DB_FILE:?err}
- POSTGRES_USER_FILE=${POSTGRES_USER_FILE:?err}
- POSTGRES_PASSWORD_FILE=${POSTGRES_PASSWORD_FILE:?err}
networks: [ "database" ]
ports: [ "8000:8000" ]
read_only: true
depends_on:
database:
condition: service_healthy
secrets:
- source: db
target: postgres_db
mode: 0440
- source: user
target: postgres_user
mode: 0440
- source: passwd
target: postgres_passwd
mode: 0440
backend-test:
profiles: [ "test" ]
hostname: backend
container_name: getby_backend_test
image: getby_backend_test:1.0
build:
context: backend
dockerfile: backend_test.Dockerfile
deploy:
resources:
limits:
memory: 100M
reservations:
memory: 40M
restart_policy:
condition: "no"
stop_signal: SIGINT
user: "getby"
restart: "no"
cap_drop: [ "ALL" ]
environment:
- UVICORN_PORT=8000
- UVICORN_HOST=0.0.0.0
- UVICORN_WORKERS=1
- POSTGRES_DB_FILE=${POSTGRES_DB_FILE:?err}
- POSTGRES_USER_FILE=${POSTGRES_USER_FILE:?err}
- POSTGRES_PASSWORD_FILE=${POSTGRES_PASSWORD_FILE:?err}
networks: [ "database" ]
ports: [ "8000:8000" ]
read_only: true
tmpfs: [ "/tmp" ]
depends_on:
database:
condition: service_healthy
secrets:
- source: db
target: postgres_db
mode: 0440
- source: user
target: postgres_user
mode: 0440
- source: passwd
target: postgres_passwd
mode: 0440
database:
profiles: [ "deploy", "test" ]
hostname: database
container_name: getby_database
image: getby_database:1.0
build:
context: ./database
dockerfile: postgres.Dockerfile
stop_signal: SIGINT
deploy:
resources:
limits:
memory: 200M
reservations:
memory: 50M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 120s
user: "postgres"
restart: unless-stopped
cap_drop: [ "ALL" ]
environment:
- POSTGRES_DB_FILE=${POSTGRES_DB_FILE:?err}
- POSTGRES_USER_FILE=${POSTGRES_USER_FILE:?err}
- POSTGRES_PASSWORD_FILE=${POSTGRES_PASSWORD_FILE:?err}
- LANG="pt_BR-UTF-8"
secrets:
- source: db
target: postgres_db
mode: 0440
- source: user
target: postgres_user
mode: 0440
- source: passwd
target: postgres_passwd
mode: 0440
networks: [ "database" ]
expose: [ "5432" ]
volumes:
- postgres_db:/var/lib/postgresql/data:rw
read_only: true
tmpfs: [ "/var/run/postgresql" ]
healthcheck:
test: [ "CMD-SHELL", "pg_isready --dbname=$$(cat ${POSTGRES_DB_FILE:?err}) --username=$$(cat ${POSTGRES_USER_FILE:?err})" ]
interval: 5s
timeout: 5s
retries: 5
networks:
database:
driver: bridge
front:
driver: bridge
volumes:
postgres_db:
secrets:
db:
file: ./database/postgres-db.txt
user:
file: ./database/postgres-user.txt
passwd:
file: ./database/postgres-passwd.txt