-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml.j2
79 lines (66 loc) · 2.23 KB
/
docker-compose.yml.j2
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
# this is a Jinja2 template file used during the Ansible deployment
# environment specific configuration can be found in our Ansble scripts
---
name: {{ compose_stack_name }}
services:
{% set service = 'app' %}
app:
image: ghcr.io/{{ template.git.package.image_name }}:{{ template.git.package.tag }}
restart: unless-stopped
ports:
- "{{ template.env.host_app_port }}:8000"
environment:
- DEBUG={{ template.env.debug_flag }}
- DJANGO_SECRET_KEY={{ template.env.secret_key }}
- DJANGO_ALLOWED_HOSTS={{ template.env.allowed_hosts }}
- DJANGO_CSRF_TRUSTED_ORIGINS={{ template.env.trusted_origins }}
- DB_HOST=db
- DB_PORT={{ template.env.host_db_port }}
- DB_NAME={{ template.env.db_name }}
- DB_USER={{ template.env.db_user }}
- DB_PASS={{ template.env.db_pass }}
command: >
sh -c "poetry run python3 manage.py migrate &&
poetry run python3 manage.py runserver 0.0.0.0:8000"
{% if template.volumes is defined %}
{% set vols = (template.volumes | selectattr('service', 'eq', service)) %}
{% if vols is iterable and vols | length > 0 %}
volumes:
{% for vol in vols %}
- {{ vol.name }}:{{ vol.container_path }}
{% endfor %}
{% endif %}
{% endif %}
depends_on:
db:
condition: service_healthy
{% set service = 'db' %}
db:
image: postgres:12
restart: unless-stopped
environment:
- POSTGRES_DB={{ template.env.db_name }}
- POSTGRES_USER={{ template.env.db_user }}
- POSTGRES_PASSWORD={{ template.env.db_pass }}
- POSTGRES_HOST=db
{% if template.volumes is defined %}
{% set vols = (template.volumes | selectattr('service', 'eq', service)) %}
{% if vols is iterable and vols | length > 0 %}
volumes:
{% for vol in vols %}
- {{ vol.name }}:{{ vol.container_path }}
{% endfor %}
{% endif %}
{% endif %}
healthcheck:
test: ["CMD-SHELL", "pg_isready -U {{ template.env.db_user }}"]
interval: 5s
timeout: 5s
retries: 5
# external volumes managed and defined by ansible
volumes:
{% for vol in template.volumes %}
{{ vol.name }}:
name: "{{ compose_stack_name }}--{{ vol.name }}"
external: true
{% endfor %}