forked from ietf-tools/bibxml-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
167 lines (160 loc) · 5.09 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
version: "3.3"
services:
# Single instance only.
redis:
restart: unless-stopped
image: redis
# Single instance only.
db:
restart: unless-stopped
build:
context: ops
dockerfile: db.Dockerfile
args:
POSTGRES_DB: ${DB_NAME:?missing DB name}
POSTGRES_USER: ${DB_NAME:?err}
POSTGRES_PASSWORD: "${DB_SECRET:?missing DB secret (long random string)}"
hostname: db
environment:
POSTGRES_DB: ${DB_NAME:?missing DB name}
POSTGRES_USER: ${DB_NAME:?err}
POSTGRES_PASSWORD: "${DB_SECRET:?missing DB secret (long random string)}"
user: "${UID}:${GID}"
# Must be run once, pre deploy.
# Built image is reused by "web" and "celery".
web-precheck:
deploy:
restart_policy:
# Restart, typically if DB is not ready to accept connections yet
condition: on-failure
delay: 2s
max_attempts: 4
build:
context: .
dockerfile: Dockerfile
args:
SNAPSHOT: placeholder
image: local/web-precheck:latest
command:
- /bin/sh
- -c
- |
python manage.py migrate &&
python manage.py check --deploy
environment:
PRIMARY_HOSTNAME: ${HOST_NAME?err}
DATASET_TMP_ROOT: "/data/datasets"
DEBUG: ${DEBUG:-0}
DJANGO_SECRET: "${DJANGO_SECRET:?err}"
DB_HOST: db
DB_PORT: 5432
DB_USER: ${DB_NAME:?err}
DB_NAME: ${DB_NAME:?err}
DB_SECRET: ${DB_SECRET:?err}
CELERY_BROKER_URL: "redis://redis:6379"
CELERY_RESULT_BACKEND: "redis://redis:6379"
REDIS_HOST: redis
REDIS_PORT: 6379
SERVICE_NAME: ${SERVICE_NAME:?missing service name}
CONTACT_EMAIL: ${CONTACT_EMAIL:?missing service name}
PYTHONUNBUFFERED: 1
depends_on:
- db
- redis
# Can be run in multiple instances.
web:
restart: unless-stopped
image: local/web-precheck:latest
hostname: ${HOST_NAME?err}
command:
- /bin/sh
- -c
- |
export SNAPSHOT=$$(git describe --abbrev=0) &&
./wait-for-migrations.sh &&
if [ "$DEBUG" = "1" ]; then
python manage.py runserver 0.0.0.0:8000
else
python manage.py clear_cache &&
hypercorn -b '0.0.0.0:8000' -w 1 bibxml.asgi:application
fi
ports:
- "${PORT:?missing port to expose web service under}:8000"
environment:
PRIMARY_HOSTNAME: ${HOST_NAME?missing main hostname (e.g., localhost for development)}
INTERNAL_HOSTNAMES: "web"
DEBUG: ${DEBUG:-0}
SOURCE_REPO_URL: ${SOURCE_REPO_URL:?missing source repository URL}
DJANGO_SECRET: "${DJANGO_SECRET:?missing Django secret (long random string)}"
API_SECRET: "${API_SECRET:?missing API secret}"
EXTRA_API_SECRETS: "${EXTRA_API_SECRETS}"
DB_HOST: db
DB_PORT: 5432
DB_USER: ${DB_NAME:?err}
DB_NAME: ${DB_NAME:?err}
DB_SECRET: "${DB_SECRET:?err}"
SERVICE_NAME: ${SERVICE_NAME:?missing service name}
CONTACT_EMAIL: ${CONTACT_EMAIL:?missing service name}
SERVER_EMAIL: ${SERVER_EMAIL}
SENTRY_DSN: ${SENTRY_DSN}
MATOMO_URL: ${MATOMO_URL}
MATOMO_SITE_ID: ${MATOMO_SITE_ID}
MATOMO_TAG_MANAGER_CONTAINER: ${MATOMO_TAG_MANAGER_CONTAINER}
REQUIRE_DATATRACKER_AUTH: ${REQUIRE_DATATRACKER_AUTH:-0}
DATATRACKER_CLIENT_ID: ${DATATRACKER_CLIENT_ID}
DATATRACKER_CLIENT_SECRET: ${DATATRACKER_CLIENT_SECRET}
PYTHONUNBUFFERED: 1
# TODO: Some environment variables could be removed from web container, and only made available to celery
DATASET_TMP_ROOT: "/data/datasets"
CELERY_BROKER_URL: "redis://redis:6379"
CELERY_RESULT_BACKEND: "redis://redis:6379"
REDIS_HOST: redis
REDIS_PORT: 6379
depends_on:
- web-precheck
# Single instance only.
celery:
restart: unless-stopped
image: local/web-precheck:latest
command:
- /bin/sh
- -c
- |
export SNAPSHOT=$$(git describe --abbrev=0) &&
./wait-for-migrations.sh &&
celery -A sources.celery:app worker -B -l info -c 1
environment:
PRIMARY_HOSTNAME: ${HOST_NAME?err}
INTERNAL_HOSTNAMES: "celery"
DATASET_TMP_ROOT: "/data/datasets"
DEBUG: ${DEBUG:-0}
DJANGO_SECRET: "${DJANGO_SECRET:?err}"
API_SECRET: "${API_SECRET:?missing API secret}"
EXTRA_API_SECRETS: "${EXTRA_API_SECRETS}"
DB_HOST: db
DB_PORT: 5432
DB_USER: ${DB_NAME:?err}
DB_NAME: ${DB_NAME:?err}
DB_SECRET: ${DB_SECRET:?err}
CELERY_BROKER_URL: "redis://redis:6379"
CELERY_RESULT_BACKEND: "redis://redis:6379"
REDIS_HOST: redis
REDIS_PORT: 6379
SERVICE_NAME: ${SERVICE_NAME:?missing service name}
CONTACT_EMAIL: ${CONTACT_EMAIL:?missing service name}
SENTRY_DSN: ${SENTRY_DSN}
PYTHONUNBUFFERED: 1
AUTO_REINDEX_INTERVAL: ${AUTO_REINDEX_INTERVAL}
depends_on:
- web-precheck
- redis
ports:
- "9080:9080"
celery-exporter:
restart: unless-stopped
image: danihodovic/celery-exporter
command: "--broker-url=redis://redis:6379"
depends_on:
- redis
ports:
- "9081:9808"