-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose-prod.yml
175 lines (161 loc) · 4.99 KB
/
docker-compose-prod.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
name: alert-hub # NOTE: Define COMPOSE_PROJECT_NAME in .env to use custom name
x-logging:
logging: &base_logging
driver: syslog
options: &base_logging_options
"syslog-facility": "daemon"
x-server: &base_server_setup
build:
context: ./backend/
# To attach to container with stdin `docker attach <container_name>`
# Used for python debugging.
stdin_open: true
tty: true
extra_hosts:
- 'host.docker.internal:host-gateway'
env_file:
- .env
environment: &base_server_setup_environment
DJANGO_APP_TYPE: web
DJANGO_APP_ENVIRONMENT: ${DJANGO_APP_ENVIRONMENT:-prod}
DJANGO_DEBUG: ${DJANGO_DEBUG:-false}
DJANGO_SECRET_KEY: ${DJANGO_SECRET_KEY?error},
# -- Domain configurations
APP_DOMAIN: ${APP_DOMAIN?error}
DJANGO_ALLOWED_HOSTS: ${DJANGO_ALLOWED_HOSTS?error}
APP_HTTP_PROTOCOL: ${APP_HTTP_PROTOCOL:-https}
APP_FRONTEND_HOST: ${APP_FRONTEND_HOST?error}
SESSION_COOKIE_DOMAIN: ${SESSION_COOKIE_DOMAIN?error}
CSRF_COOKIE_DOMAIN: ${CSRF_COOKIE_DOMAIN?error}
# Database config
DB_HOST: ${DB_HOST?error}
DB_PORT: ${DB_PORT?error}
DB_NAME: ${DB_NAME?error}
DB_USER: ${DB_USER?error}
DB_PASSWORD: ${DB_PASSWORD?error}
# Redis config
CELERY_BROKER_URL: ${CELERY_BROKER_URL?error}
CACHE_REDIS_URL: ${CACHE_REDIS_URL?error}
# Email config (TODO: Configure this.. for now this is not used)
EMAIL_HOST: ${EMAIL_HOST:-mailpit}
EMAIL_PORT: ${EMAIL_PORT:-1025}
EMAIL_HOST_USER: ${EMAIL_HOST_USER:-mailpit}
EMAIL_HOST_PASSWORD: ${EMAIL_HOST_PASSWORD:-mailpit}
DEFAULT_FROM_EMAIL: ${DEFAULT_FROM_EMAIL:-alert-hub-dev <info@alert-hub.ifrc.org>}
# Static, Media configs
DJANGO_STATIC_URL: ${DJANGO_STATIC_URL:-/dj-static/}
DJANGO_MEDIA_URL: ${DJANGO_MEDIA_URL-/dj-media/}
# Misc
HCAPTCHA_SECRET: ${HCAPTCHA_SECRET?error}
HCAPTCHA_SITEKEY: ${HCAPTCHA_SITEKEY?error}
volumes:
- ./geographical_data/:/code/apps/cap_feed/geographical/ifrc-go-admin1-geojson/
- backend_data:/data/
- ipython_data_local:/root/.ipython/profile_default # persist ipython data, including ipython history
x-worker: &base_worker_setup
<<: *base_server_setup
environment:
<<: *base_server_setup_environment
DJANGO_APP_TYPE: worker
healthcheck:
test: ["CMD-SHELL", "celery -A main inspect ping -d celery@$$HOSTNAME || exit 1"]
interval: 30s
timeout: 5s
retries: 3
start_period: 30s
services:
mailpit:
image: axllent/mailpit
ports:
- 127.0.0.1:8025:8025 # HTTP
environment:
MP_MAX_MESSAGES: 5000
MP_DATA_FILE: /data/mailpit.db
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1
volumes:
- mailpit-data:/data
logging:
<<: *base_logging
options:
<<: *base_logging_options
tag: mailpit
frontend:
tty: true
build:
context: .
target: builder
environment:
NODE_OPTIONS: "--max_old_space_size=1024"
APP_GOOGLE_ANALYTICS_ID: ${FRONTEND_APP_GOOGLE_ANALYTICS_ID?error}
APP_TITLE: ${FRONTEND_APP_TITLE:-IFRC Alert Hub}
APP_ENVIRONMENT: ${FRONTEND_APP_ENVIRONMENT:-prod}
APP_GRAPHQL_API_ENDPOINT: ${FRONTEND_APP_GRAPHQL_API_ENDPOINT?error}
APP_MAPBOX_ACCESS_TOKEN: ${FRONTEND_APP_MAPBOX_ACCESS_TOKEN?error}
APP_GRAPHQL_CODEGEN_ENDPOINT: ${FRONTEND_APP_GRAPHQL_CODEGEN_ENDPOINT?error}
env_file:
- .env
command: |
sh -c 'pnpm generate && pnpm build && rm -rf /client-build/* ; cp -r build/* /client-build/'
volumes:
- client_static:/client-build/
profiles: [frontend]
web:
<<: *base_server_setup
command: bash -c 'wait-for-it $$DB_HOST:$$DB_PORT && ./deploy/run_web.sh'
logging:
<<: *base_logging
options:
<<: *base_logging_options
tag: web
worker:
<<: *base_worker_setup
# TODO: Use run_celery_dev
command: bash -c './deploy/run_worker.sh'
logging:
<<: *base_logging
options:
<<: *base_logging_options
tag: worker
worker-beat:
<<: *base_worker_setup
command: bash -c './deploy/run_worker_beat.sh'
logging:
<<: *base_logging
options:
<<: *base_logging_options
tag: worker-beat
caddy:
image: caddy:2
restart: always
volumes:
# Caddy config
- ./deploy/Caddyfile:/etc/caddy/Caddyfile:ro
- ./data/certs/:/etc/ssl/caddy/:ro
# Static files
- client_static:/app-assests/client-static:ro
- backend_data:/app-assests/server-static:ro
# Caddy data volumes
- caddy_data:/data
- caddy_config:/config
environment:
CADDY_EMAIL: ${CADDY_EMAIL?err}
CADDY_FRONTEND_HOST: ${CADDY_FRONTEND_HOST?err}
CADDY_BACKEND_HOST: ${CADDY_BACKEND_HOST?err}
ports:
- 80:80
- 443:443
depends_on:
- web
logging:
<<: *base_logging
options:
<<: *base_logging_options
tag: caddy
volumes:
ipython_data_local:
mailpit-data:
backend_data:
client_static:
caddy_data:
caddy_config: