-
Notifications
You must be signed in to change notification settings - Fork 5
/
obico.yml
153 lines (136 loc) · 4.91 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
---
- 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: "False"
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"
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"