forked from unicef/etools-partner-reporting-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
126 lines (93 loc) · 2.99 KB
/
fabfile.py
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
from __future__ import unicode_literals
from fabric.api import local
def ssh(service):
"""
ssh into running service container
:param service: ['django_api', 'polymer', 'proxy', 'db']
"""
assert service in ['django_api', 'polymer', 'proxy', 'db'], "%s is unrecognized service"
if service == 'polymer':
local('docker-compose exec polymer ash')
else:
local('docker-compose exec %s bash' % service)
def up_recreate():
"""
Recreate containers even if their configuration and image haven't changed.
"""
local('docker-compose down && docker-compose up')
def up(quick=False):
"""
Create and start containers.
"""
if quick:
command = 'docker-compose up'
else:
command = 'docker-compose up --force-recreate --build'
local(command)
def up_with_bundle(quick=True):
"""
Create and start containers with polymer bundle served.
"""
local('docker-compose -f docker-compose.polymer-bundle.yml up %s' % '' if quick else '--build')
def restart(service):
"""
restart a service container
:param service: ['django_api', 'polymer', 'proxy', 'db']
"""
assert service in ['django_api', 'polymer', 'proxy', 'db'], "%s is unrecognized service"
local('docker-compose restart %s' % service)
def down():
"""
Stop all containers.
"""
local('docker-compose down')
def rebuild():
"""
Re-build docker images for containers.
"""
local('docker-compose build')
def ps():
"""
Display all containers.
"""
local('docker-compose ps')
def stop():
"""
Stop services.
"""
local('docker-compose stop')
def fixtures(quantity=2):
"""
Load example data from generate_fake_data management command.
"""
local('docker-compose exec django_api python manage.py generate_fake_data --quantity %d --clean_before' % (int(quantity)))
def real_fixtures(area=False):
"""
Uses real sync with PMP API to get all data.
"""
local('docker-compose exec django_api python manage.py generate_real_data --clean_before %s' % ("--area %s --fast" % area if area else ""))
def tests(test_path=''):
"""
Run django_api tests.
"""
local('docker-compose exec django_api python manage.py test {} --parallel --noinput'.format(test_path))
def fake_users(fast=False):
"""
Uses real sync with PMP API to get all data.
"""
local('docker-compose exec django_api python manage.py generate_fake_users --clean_before')
def update_real_fixtures(area=False):
"""
Uses real sync with PMP API to get all data.
"""
local('docker-compose exec django_api python manage.py generate_real_data %s --update' % ("--area %s --fast" % area if area else ""))
def remove_untagged_images():
"""
Delete all untagged (<none>) images
"""
local('docker rmi $(docker images | grep "^<none>" | awk "{print $3}")')
def backend_lint():
"""
Run python code linter
"""
local('docker-compose exec django_api flake8 ./ --count')