-
Notifications
You must be signed in to change notification settings - Fork 5
/
obico.yml
168 lines (150 loc) · 5.79 KB
/
obico.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
---
- hosts: homelab
vars:
application: obico
docker_network: "{{ networks.iot }}"
tasks:
- name: Create config folder
ansible.builtin.file:
path: "{{ config_directory }}"
state: directory
owner: "{{ common_user }}"
group: "{{ common_group }}"
mode: "0771"
- name: Create redis container
ansible.builtin.include_role:
name: redis
vars:
redis_version: 7
redis_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
31653462326237343161383364613539386639343032383536386436303862323132343638393562
3662643233323937343736633533356237663863346637320a653831636537616665653332376665
36326538663830336566626262653437633339393561613931613361656361396562623265363866
6366643962303166320a646332666637306561343137363938343963303733633266333637383066
61326561363763646335643337623336366634643964666335616563636333353230383238383362
38373962613862616134613266656165636238343532653733643738313536336636383130666139
37343261393636636431316631656537306539373264316134643564333662623038353834343966
35633733653134653063
- name: Clone
ansible.builtin.git:
repo: "https://github.com/TheSpaghettiDetective/obico-server.git"
version: release
dest: "{{ config_directory }}/repo"
update: true
register: _obico_repo_updated
- name: Build ml_api image
community.docker.docker_image:
name: "{{ application }}-ml_api"
build:
path: "{{ config_directory }}/repo/ml_api"
dockerfile: Dockerfile
pull: true
source: build
state: present
force_source: "{{ true if _obico_repo_updated.changed else false }}"
- name: Create ml_api container
ansible.builtin.include_role:
name: docker_container
vars:
name: "{{ application }}-ml_api"
image: "{{ application }}-ml_api"
command:
- bash
- -c
- "gunicorn --bind 0.0.0.0:3333 --workers 1 wsgi"
env:
DEBUG: "False"
FLASK_APP: "server.py"
HAS_GPU: "True"
device_requests:
- driver: nvidia
count: -1
device_ids: []
options: {}
capabilities:
- - gpu
- video
- compute
- utility
labels:
com.centurylinklabs.watchtower.enable: "false"
- name: Build backend image
community.docker.docker_image:
name: "{{ application }}-backend"
build:
path: "{{ config_directory }}/repo/backend"
dockerfile: Dockerfile
pull: true
source: build
state: present
force_source: "{{ true if _obico_repo_updated.changed else false }}"
- name: Create web container
ansible.builtin.include_role:
name: docker_container
vars:
name: "{{ application }}-web"
image: "{{ application }}-backend"
command:
- sh
- -c
- "python manage.py migrate && python manage.py collectstatic -v 2 --noinput && daphne -b 0.0.0.0 -p 3334 config.routing:application"
traefik:
- port: 3334
rule: Host(`{{ application }}.{{ common_tld }}`)
homepage:
group: 3D Printing
weight: 600
description: "3D printing failure detection"
blackbox:
path: /hc/
volumes: &web_volumes
- "{{ config_directory }}/repo/backend:/app"
- "{{ config_directory }}/repo/frontend:/frontend"
env: &web_env
EMAIL_HOST: "{{ common_email_server }}"
EMAIL_HOST_USER: "{{ common_email_username }}"
EMAIL_HOST_PASSWORD: "{{ common_email_password }}"
EMAIL_PORT: "{{ common_email_port | string }}"
EMAIL_USE_TLS: "True"
DEFAULT_FROM_EMAIL: "{{ application }}{{ common_email_to }}"
DEBUG: "False"
SITE_USES_HTTPS: "True"
SITE_IS_PUBLIC: "False"
SOCIAL_LOGIN: "False"
REDIS_URL: "{{ _redis_url }}"
DATABASE_URL: "sqlite:////app/db.sqlite3"
INTERNAL_MEDIA_HOST: "http://{{ application }}-web.{{ docker_network.name }}:3334"
ML_API_HOST: "http://{{ application }}-ml_api.{{ docker_network.name }}:3333"
ACCOUNT_ALLOW_SIGN_UP: "False"
WEBPACK_LOADER_ENABLED: "False"
DJANGO_SECRET_KEY: !vault |
$ANSIBLE_VAULT;1.1;AES256
63346166666432343230313334626363366563653939393165373430386365353938373036623665
3964303736366161396661643135613936306462393233360a386136333930346466303964303637
65343632613436336431343535393232613434386334653736653136623038333362666365373864
6331663432366334380a623739636130366264343133313236323466313961613233356662623263
30343133326136633133303236613165303436333165373434353436393462323463626263356239
3266376561333337353632303564663966366466646666313335
labels:
com.centurylinklabs.watchtower.enable: "false"
- name: Create tasks container
ansible.builtin.include_role:
name: docker_container
vars:
name: "{{ application }}-tasks"
image: "{{ application }}-backend"
command:
- sh
- -c
- "celery -A config worker --beat -l info -c 2 -Q realtime,celery"
volumes: *web_volumes
env: *web_env
labels:
com.centurylinklabs.watchtower.enable: "false"
- name: Add site to django
community.docker.docker_container_exec:
container: "{{ application }}-web"
command: "./manage.py site --add {{ application }}.{{ common_tld }}"
register: _command_result
changed_when: "'already exists' not in _command_result.stdout"