-
Notifications
You must be signed in to change notification settings - Fork 23
/
docker-compose.template.yaml
207 lines (195 loc) · 5.78 KB
/
docker-compose.template.yaml
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
#
# the value of the INSTANCE_CONFIG is used to identify the correct environment file located at
# env.INSTANCE_CONFIG (default is 'demo')
#
version: '3'
services:
build_deps:
image: "${DOCKER_REGISTRY:-localhost.localdomain}/productdb/build_deps:stable"
build:
context: .
dockerfile: deploy/docker/Dockerfile-build_deps
environment: &app
INSTANCE_NAME: productdb
DJANGO_SECRET_KEY: plschgme
DJANGO_LOG_LEVEL: info
POSTGRES_DB: productdb
POSTGRES_USER: productdb
POSTGRES_PASSWORD: plschgme
PDB_REDIS_PASSWORD: plschgme
# only required for the initial build, the certificates can be changed afterwards within the ssl_files volume
#HTTPS_SELF_SIGNED_CERT_COUNTRY: DE
#HTTPS_SELF_SIGNED_CERT_FQDN: productdb
#==============================================================================================================
# Django (optional settings)
#
#PDB_LANGUAGE_CODE=en-us
#PDB_TIME_ZONE=Europe/Berlin
#PDB_TIME_FORMAT=P
#PDB_DATE_FORMAT=N j, Y
#PDB_SHORT_DATE_FORMAT=Y-m-d
#==============================================================================================================
# Sentry integration (optional settings)
#
#PDB_ENABLE_SENTRY=1
#PDB_SENTRY_DSN=https://localhost/4
# add ?verify_ssl=0 if self-signed certificates are used
#==============================================================================================================
# LDAP authentication (optional)
#PDB_LDAP_ENABLE=1
#PDB_LDAP_SERVER_URL=ldap://127.0.0.1:389/
#PDB_LDAP_BIND_AS_AUTHENTICATING_USER=1
#PDB_LDAP_USER_SEARCH=ou=users,dc=example,dc=com
#PDB_LDAP_ENABLE_TLS=1
# set the option if you want to use self-signed certificates
#PDB_LDAP_ALLOW_SELF_SIGNED_CERT=1
# limit the search to a specific group - leave empty to disable
#PDB_LDAP_GROUP_SEARCH=cn=groups,dc=example,dc=com
# if a specific LDAP group should be allowed to access the instance - leave empty to disable
#PDB_LDAP_REQUIRE_GROUP=cn=group,dc=example,dc=com
volumes:
- static_files:/var/www/productdb/static
- ssl_files:/var/www/productdb/ssl
- data:/var/www/productdb/data
- postgres_backup:/backups
networks:
- default
- internal
labels:
productdb: build_deps
redis:
restart: always
image: redis:6
command: /bin/sh -c "redis-server --appendonly yes --requirepass $$PDB_REDIS_PASSWORD"
environment: *app
volumes:
- redis_data:/data
networks:
- internal
healthcheck:
interval: 30s
timeout: 5s
retries: 2
start_period: 30s
test: "redis-cli -a $$REDIS_PASSWORD ping"
database:
command: -c ssl=on -c ssl_cert_file=/var/www/productdb/ssl/database.crt -c ssl_key_file=/var/www/productdb/ssl/database.key
restart: always
image: postgres:12.3
environment: *app
volumes:
- postgres_data:/var/lib/postgresql/data
- ssl_files:/var/www/productdb/ssl:ro
networks:
- internal
healthcheck:
interval: 30s
timeout: 5s
retries: 2
start_period: 15s
test: [ "CMD-SHELL", "pg_isready -U $$POSTGRES_USER" ]
beat:
restart: always
image: "${DOCKER_REGISTRY:-localhost.local}/productdb/django:stable"
build:
context: .
dockerfile: deploy/docker/Dockerfile-django
command: start_celery_beat
environment: *app
networks:
- default
- internal
volumes:
- data:/var/www/productdb/data
depends_on:
- build_deps
- database
- redis
worker:
restart: always
image: "${DOCKER_REGISTRY:-localhost.local}/productdb/django:stable"
build:
context: .
dockerfile: deploy/docker/Dockerfile-django
command: start_celery_worker
environment: *app
networks:
- default
- internal
volumes:
- data:/var/www/productdb/data
- ssl_files:/var/www/productdb/ssl:ro
depends_on:
- build_deps
- database
- redis
- beat
healthcheck:
interval: 1m
timeout: 10s
retries: 2
start_period: 60s
test: "celery -A django_project inspect ping -d celery@$$HOSTNAME"
web:
restart: always
image: "${DOCKER_REGISTRY:-localhost.local}/productdb/django:stable"
build:
context: .
dockerfile: deploy/docker/Dockerfile-django
command: start_gunicorn
environment: *app
networks:
- default
- internal
volumes:
- data:/var/www/productdb/data
- ssl_files:/var/www/productdb/ssl:ro
depends_on:
- build_deps
- database
- redis
healthcheck:
test: [ "CMD", "curl", "--fail", "--insecure", "https://localhost:8443/productdb/" ]
interval: 1m
timeout: 10s
retries: 2
start_period: 60s
labels:
# used to auto-build the nginx configuration in the nginx service
productdb: web
nginx:
restart: always
image: "${DOCKER_REGISTRY:-localhost.local}/productdb/nginx:stable"
build:
context: .
dockerfile: deploy/docker/Dockerfile-nginx
environment: *app
ports:
- "${EXPOSE_IP:-0.0.0.0}:${NGINX_HTTP_PORT:-80}:80"
- "${EXPOSE_IP:-0.0.0.0}:${NGINX_HTTPS_PORT:-443}:443"
networks:
- default
volumes:
- static_files:/var/www/productdb/static:ro
- ssl_files:/var/www/productdb/ssl:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
depends_on:
- build_deps
- web
healthcheck:
test: "service nginx status || exit 1"
interval: 30s
timeout: 10s
retries: 2
start_period: 60s
networks:
default:
internal:
driver: bridge
volumes:
postgres_data:
static_files:
ssl_files:
data:
postgres_backup:
redis_data: