This repository has been archived by the owner on Apr 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
docker-compose-deploy.yml
228 lines (222 loc) · 6.83 KB
/
docker-compose-deploy.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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
version: '3.7'
services:
proxy:
image: geometalab/env-configurable-caddy:latest
environment:
# See https://caddyserver.com/docs/quick-starts/caddyfile for details
CADDY_CONFIG: |
:8080 {
route {
handle /media/* {
uri strip_prefix /media
file_server /* {
root /data/media/
browse
}
}
handle /static/* {
uri strip_prefix /static
file_server /* {
root /data/static/
browse
}
}
reverse_proxy /* {
to frontend:8000
}
}
}
volumes:
- frontend-static:/data/static
- frontend-media:/data/media
- worker-data:/data/media/job_result_files
networks:
- default
- web
deploy: &deploy
# when deployed using reverse proxy called caddy
labels:
caddy: "your.domain.name"
caddy.reverse_proxy: "{{upstreams 8000}}"
restart_policy:
condition: "on-failure"
replicas: 1
placement:
constraints:
- node.role == manager
logging: &logging
driver: json-file
options:
max-size: 50m
access-rights:
image: ubuntu:latest
command: bash -c 'chown -R 1000 /access'
user: root
volumes:
- frontend-media:/access/media
- frontend-static:/access/static
- worker-data:/access/job_result_files
- worker-data-ignored:/access/ignored-worker
logging: &logging
driver: json-file
options:
max-size: 50m
##### frontend START ########
frontend: &frontend
image: geometalab/osmaxx-frontend
build:
context: .
dockerfile: Dockerfile
target: frontend
entrypoint: dockerize -wait tcp://frontenddatabase:5432 -timeout 60s
command: ./manage.py runserver_plus 0.0.0.0:8000
user: "1000"
volumes:
# - ./osmaxx:/home/py/osmaxx/osmaxx
# - ./web_frontend:/home/py/osmaxx/web_frontend
- frontend-media:/data/media
- frontend-static:/data/static
- worker-data:/data/media/job_result_files
- osm_data:/var/data/osm-planet
environment: &baseenv
? DJANGO_ALLOWED_HOSTS=*
? DJANGO_SECRET_KEY=insecure!1
? DJANGO_SETTINGS_MODULE=config.settings
? DJANGO_DEBUG=false
# set the following two lines if you want to be able to log in using OSM
# but don't commit them!
? SOCIAL_AUTH_OPENSTREETMAP_KEY=
? SOCIAL_AUTH_OPENSTREETMAP_SECRET=
? DJANGO_LOG_LEVEL=INFO
? DJANGO_EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend
? DJANGO_CSRF_COOKIE_SECURE=false
? DJANGO_SESSION_COOKIE_SECURE=false
? DJANGO_DATABASE_URL=postgis://frontend:insecureChangeInProduction!@frontenddatabase/frontend
? CELERY_BROKER_URL=redis://redis:6379/1
networks:
- default
logging:
<<: *logging
frontend-setup:
<<: *frontend
command: bash -c "./manage.py migrate --noinput && ./manage.py collectstatic --noinput"
frontend-purge-files:
<<: *frontend
command: ./manage.py purge_expired_result_files
frontenddatabase:
image: postgis/postgis:13-3.1
volumes:
- frontend-database-data:/database/data
environment:
- PGDATA=/database/data
- POSTGRES_DB=frontend
- POSTGRES_USER=frontend
- POSTGRES_PASSWORD=insecureChangeInProduction!
networks:
- default
logging:
<<: *logging
redis:
image: redis
networks:
- default
logging:
<<: *logging
worker: &worker
<<: *frontend
image: geometalab/osmaxx-worker
build:
context: .
dockerfile: Dockerfile
target: worker
entrypoint: dockerize -wait tcp://worker-db:5432 -timeout 60s
user: "1000"
command: celery -A config worker -l INFO
environment:
<<: *baseenv
? DJANGO_SECRET_KEY=insecure!3
? GIS_CONVERSION_DB_HOST=worker-db
# needs to be the password of the conversion db!
? PGPASSWORD=worker
? GIS_CONVERSION_DB_PASSWORD=worker
? GIS_CONVERSION_DB_USER=worker
? OSM_BOUNDARIES_DB_NAME=osmboundaries
? DJANGO_DEBUG=false
# set this at maximum your availbale number of cores
? CELERY_WORKER_CONCURRENCY=4
networks:
- default
logging:
<<: *logging
scheduler:
<<: *worker
command: celery -A config beat -l INFO --scheduler django_celery_beat.schedulers:DatabaseScheduler
worker-db:
image: geometalab/osmaxx-worker-db
build:
context: docker-helper-images/osmaxx-postgis-translit/
dockerfile: Dockerfile
# this can and probably should be further optimized
# see https://www.postgresql.org/docs/current/app-postgres.html
command: postgres --shared_buffers=2GB --synchronous_commit=off --full_page_writes=off --fsync=off --max_wal_size=10GB --autovacuum=off --checkpoint_timeout=360
# command: postgres -B 1GB -F -S 1GB --max_wal_size=10GB
volumes:
- worker-db:/database
environment:
- PGDATA=/database/data
- POSTGRES_DB=worker
- POSTGRES_USER=worker
- POSTGRES_PASSWORD=worker
logging:
<<: *logging
osmboundaries-importer:
# to build/update this image see `docker-helper-images/osmboundaries/`
image: geometalab/osmboundaries:latest
environment:
# TODO: make osmboundaries more flexible concerning the database name
# db-name must be osmboundaries. this is a hard-coded dependency
- POSTGRES_DB=osmboundaries
# the same as the ones in the database above
- POSTGRES_USER=worker
- POSTGRES_PASSWORD=worker
- POSTGRES_HOST=worker-db
networks:
- default
logging:
<<: *logging
##### CONVERSION SERVICE END ########
##### WORLD PBF UPDATER START ########
osm-pbf-updater:
image: geometalab/osmaxx-osm-pbf-updater
build:
context: docker-helper-images/osm_pbf_updater/
dockerfile: Dockerfile
volumes:
- osm_data:/var/data/osm-planet
entrypoint: /bin/bash
command: -c "echo 0"
# command: /opt/development_download_only.sh
# these are just examples
# environment:
# - osmupdate_extra_params=--base-url=download.geofabrik.de/europe/switzerland-updates/
# - osm_planet_mirror=http://download.geofabrik.de/
# - osm_planet_path_relative_to_mirror=europe/switzerland-latest.osm.pbf
networks:
- default
logging:
<<: *logging
##### WORLD PBF UPDATER END ########
volumes:
# osmaxx
frontend-database-data: {}
frontend-media: {}
frontend-static: {}
mediator-database-data: {}
worker-data: {}
worker-data-ignored: {}
worker-db: {}
osm_data: {}
database-postgis-data: {}