forked from ballPointPenguin/polis-playbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolis-playbook.yml
188 lines (168 loc) · 4.46 KB
/
polis-playbook.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
176
177
178
179
180
181
182
183
184
185
186
187
188
---
# docker containers:
# x server
# x math
# x postgres
# x file-server
# x client-participation
# x client-admin
# x client-report
# docker volumes
# x postgres data
- name: polis deploy
gather_facts: False
hosts: webservers
vars_files:
- vars.yml
tasks:
- name: ensure workdir is present
file:
path: "{{ workdir }}"
state: directory
- name: clone or update polisServer repository
git:
dest: "{{ workdir }}"
repo: "https://github.com/{{ org }}/polisServer.git"
update: yes
version: "{{ branch }}"
- name: register the current git hash
command: git rev-parse --short HEAD
register: git_hash
args:
chdir: "{{ workdir }}"
- name: copy .env file to remote folder
copy:
src: .env
dest: "{{ workdir }}/.env"
# DATABASE
- name: ensure postgres data volume
docker_container:
image: postgres:9.5
name: polis-db-data
state: stopped
- name: build polis postgres image
docker_image:
name: polisdemo/postgres
source: build
tag: "{{ buildtag }}"
build:
dockerfile: Dockerfile-db
path: "{{ workdir }}/server"
pull: no
- name: run polis postgres
docker_container:
image: "polisdemo/postgres:{{ buildtag }}"
name: polis-postgres
restart_policy: always
env_file: "{{ workdir }}/.env"
volumes_from:
- polis-db-data
# CLIENT COMPONENTS
- name: build client-admin image
docker_image:
# force_source: yes
name: polisdemo/client-admin
source: build
tag: "{{ buildtag }}"
build:
path: "{{ workdir }}/client-admin"
pull: no
args:
GIT_HASH: "{{ git_hash }}"
- name: build client-participation image
docker_image:
# force_source: yes
name: polisdemo/client-participation
source: build
tag: "{{ buildtag }}"
build:
path: "{{ workdir }}/client-participation"
pull: no
args:
GIT_HASH: "{{ git_hash }}"
- name: build client-report image
docker_image:
# force_source: yes
name: polisdemo/client-report
source: build
tag: "{{ buildtag }}"
build:
path: "{{ workdir }}/client-report"
pull: no
args:
GIT_HASH: "{{ git_hash }}"
# FILE SERVER
# Depends On:
# - polisdemo/client-admin
# - polisdemo/client-participation
# - polisdemo/client-report
- name: build file-server image
docker_image:
force_source: yes # keep this yes
name: polisdemo/file-server
source: build
tag: "{{ buildtag }}"
build:
path: "{{ workdir }}/file-server"
pull: no
args:
TAG: "{{ buildtag }}"
- name: run file-server
docker_container:
image: "polisdemo/file-server:{{ buildtag }}"
name: polis-file-server
# recreate: yes
restart_policy: always
# API SERVER
# depends_on:
# - postgres
# - file-server
- name: build polis api server image
docker_image:
# force_source: yes
name: polisdemo/server
source: build
tag: "{{ buildtag }}"
build:
path: "{{ workdir }}/server"
pull: no
- name: run polis api server
docker_container:
env_file: "{{ workdir }}/.env"
image: "polisdemo/server:{{ buildtag }}"
name: polis-server
# recreate: yes
restart_policy: always
env:
PORT: "5000"
HSTS: "off"
LETSENCRYPT_HOST: "{{ hosts }}"
VIRTUAL_HOST: "{{ hosts }}"
VIRTUAL_PORT: "5000"
links:
- "polis-file-server:file-server"
- "polis-postgres:postgres"
# MATH
# depends_on:
# - postgres
- name: build polis math image
docker_image:
# force_source: yes
name: polisdemo/math
source: build
tag: "{{ buildtag }}"
build:
path: "{{ workdir }}/math"
pull: no
- name: run polis math
docker_container:
env_file: "{{ workdir }}/.env"
image: "polisdemo/math:{{ buildtag }}"
name: polis-math
restart_policy: always
env:
SERVER_PORT: "3123"
exposed_ports:
- "3123"
links:
- "polis-postgres:postgres"