forked from Tecnativa/doodba-copier-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prod.yaml.jinja
179 lines (172 loc) · 6.28 KB
/
prod.yaml.jinja
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
{% set _key = '%s-%.1f-prod'|format(project_name, odoo_version)|replace('.', '-') -%}
version: "2.4"
services:
odoo:
extends:
file: common.yaml
service: odoo
restart: unless-stopped
env_file:
- .docker/odoo.env
- .docker/db-access.env
environment:
DOODBA_ENVIRONMENT: "${DOODBA_ENVIRONMENT-prod}"
INITIAL_LANG: "$INITIAL_LANG"
{%- if smtp_relay_host %}
SMTP_SERVER: smtplocal
{%- endif %}
depends_on:
- db
{%- if smtp_relay_host %}
- smtp
{%- endif %}
networks:
default:
{%- if odoo_proxy == "traefik" %}
inverseproxy_shared:
labels:
traefik.longpolling.frontend.rule: "Host:${DOMAIN_PROD};PathPrefix:/longpolling/"
traefik.www.frontend.rule: "Host:${DOMAIN_PROD}"
{%- if paths_without_crawlers %}
traefik.forbid-crawlers.frontend.rule: "Host:${DOMAIN_PROD};PathPrefix:
{%- for path in paths_without_crawlers -%}
{{ path }},{{ path }}/{anything:.*}
{%- if not loop.last %},{% endif %}
{%- endfor %}"
{%- endif %}
{%- if domain_prod_alternatives %}
{%- for domain in domain_prod_alternatives %}
traefik.alt-{{ loop.index0 }}.frontend.redirect.regex: "^(.*)://${DOMAIN_PROD_ALT_{{ loop.index0 }}}/(.*)$$"
traefik.alt-{{ loop.index0 }}.frontend.redirect.replacement: "$$1://${DOMAIN_PROD}/$$2"
traefik.alt-{{ loop.index0 }}.frontend.rule: "Host:${DOMAIN_PROD_ALT_{{ loop.index0 }}}"
{%- endfor %}
{%- endif %}
# Main service
traefik.http.middlewares.{{ _key }}-buffering.buffering.retryExpression:
IsNetworkError() && Attempts() < 5
traefik.http.middlewares.{{ _key }}-compress.compress: "true"
{%- if cidr_whitelist %}
? traefik.http.middlewares.{{ _key }}-whitelist.IPWhiteList.sourceRange
: {% for cidr in cidr_whitelist -%}
{{ cidr }}{% if not loop.last %}, {% endif %}
{%- endfor %}
{%- endif %}
traefik.http.routers.{{ _key }}-main.entrypoints: "web-main"
traefik.http.routers.{{ _key }}-main.middlewares:
{{ _key }}-buffering,
{{ _key }}-compress
{%- if cidr_whitelist %}, {{ _key }}-whitelist{% endif %}
traefik.http.routers.{{ _key }}-main.rule: "host(`${DOMAIN_PROD}`)"
traefik.http.routers.{{ _key }}-main.service: "{{ _key }}-main"
traefik.http.routers.{{ _key }}-main.tls: "true"
traefik.http.routers.{{ _key }}-main.tls.certresolver: "letsencrypt"
traefik.http.services.{{ _key }}-main.loadbalancer.server.port: 8069
{%- if domain_prod_alternatives %}
# Redirect alternative domains to main domain
traefik.http.middlewares.{{ _key }}-redirect2main.redirectregex.regex: "^https://([^/]+)/(.*)$$"
traefik.http.middlewares.{{ _key }}-redirect2main.redirectregex.replacement: "https://${DOMAIN_PROD}/$${2}"
traefik.http.routers.{{ _key }}-altdomains.entrypoints: "web-main"
traefik.http.routers.{{ _key }}-altdomains.middlewares:
{{ _key }}-compress,
{{ _key }}-redirect2main
{%- if cidr_whitelist %}, {{ _key }}-whitelist{% endif %}
traefik.http.routers.{{ _key }}-altdomains.rule:
Host(
{%- for domain in domain_prod_alternatives -%}
`${DOMAIN_PROD_ALT_{{ loop.index0 }}}`
{%- if not loop.last %}, {% endif %}
{%- endfor -%}
)
traefik.http.routers.{{ _key }}-altdomains.service: "{{ _key }}-main"
traefik.http.routers.{{ _key }}-altdomains.tls: "true"
traefik.http.routers.{{ _key }}-altdomains.tls.certresolver: "letsencrypt"
{%- endif %}
# Longpolling service
traefik.http.routers.{{ _key }}-longpolling.entrypoints: "web-main"
{%- if cidr_whitelist %}
traefik.http.routers.{{ _key }}-longpolling.middlewares: {{ _key }}-whitelist
{%- endif %}
traefik.http.routers.{{ _key }}-longpolling.rule:
"host(`${DOMAIN_PROD}`) && pathprefix(`/longpolling/`)"
traefik.http.routers.{{ _key }}-longpolling.service: "{{ _key }}-longpolling"
traefik.http.services.{{ _key }}-longpolling.loadbalancer.server.port: 8072
traefik.http.routers.{{ _key }}-longpolling.tls: "true"
traefik.http.routers.{{ _key }}-longpolling.tls.certresolver: "letsencrypt"
{%- if paths_without_crawlers %}
# Forbid crawlers
? traefik.http.middlewares.{{ _key }}-forbid-crawlers.headers.customResponseHeaders.X-Robots-Tag
: "noindex, nofollow"
traefik.http.routers.{{ _key }}-forbidden-crawlers.entrypoints: "web-main"
traefik.http.routers.{{ _key }}-forbidden-crawlers.middlewares:
{{ _key }}-buffering,
{{ _key }}-compress,
{{ _key }}-forbid-crawlers
{%- if cidr_whitelist %}, {{ _key }}-whitelist{% endif %}
traefik.http.routers.{{ _key }}-forbidden-crawlers.rule:
Host(`${DOMAIN_PROD}`) && Path(
{%- for path in paths_without_crawlers -%}
`{{ path }}`, `{{ path }}/{anything:.*}`
{%- if not loop.last %}, {% endif %}
{%- endfor -%}
)
traefik.http.routers.{{ _key }}-forbidden-crawlers.service: "{{ _key }}-main"
traefik.http.routers.{{ _key }}-forbidden-crawlers.tls: "true"
traefik.http.routers.{{ _key }}-forbidden-crawlers.tls.certresolver: "letsencrypt"
{%- endif %}
{%- endif %}
db:
extends:
file: common.yaml
service: db
env_file:
- .docker/db-creation.env
restart: unless-stopped
{%- if smtp_relay_host %}
smtp:
extends:
file: common.yaml
service: smtpreal
env_file:
- .docker/smtp.env
networks:
default:
aliases:
- smtplocal
restart: unless-stopped
{%- endif %}
{%- if backup_dst %}
backup:
extends:
file: common.yaml
service: backup
env_file:
- .docker/backup.env
- .docker/db-access.env
restart: unless-stopped
depends_on:
- db
{%- if smtp_relay_host %}
- smtp
{%- endif %}
{%- endif %}
networks:
default:
driver_opts:
encrypted: 1
{%- if odoo_proxy == "traefik" %}
inverseproxy_shared:
external: true
{%- endif %}
volumes:
{%- if backup_dst %}
backup_cache:
{%- endif %}
filestore:
db:
{%- if smtp_relay_host %}
mailconfig:
maildata:
maillogs:
maillogssupervisord:
mailstate:
{%- endif %}