-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
executable file
·45 lines (39 loc) · 1 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author: Kun Jia
# date: 05/02/17
# email: [email protected]
from fabric.api import run, roles, cd, local
from fabric.context_managers import env
from fabric.contrib.project import rsync_project
code_dir = '/backhend'
exclude = (
'.DS_Store',
'*pyc',
'.git',
'.idea',
'*sqlite3',
'migrations',
'node_modules',
'readme_files',
'__pycache__',
'.travis'
)
env.roledefs = {
'vps': ['[email protected]']
}
@roles('vps')
def rebuild(container=''):
rsync_project(local_dir='.', remote_dir=code_dir, exclude=exclude)
with cd(code_dir):
if container:
run('docker-compose down {0}; docker-compose build {1}'.format(container, container))
else:
run('docker-compose down; docker-compose build')
@roles('vps')
def up(container=''):
with cd(code_dir):
if container:
run('docker-compose up -d {0}'.format(container))
else:
run('docker-compose up -d')