forked from gbozee/pyconng
-
Notifications
You must be signed in to change notification settings - Fork 9
/
fabfile.py
66 lines (55 loc) · 2.11 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
import os
from fabric.api import local, run, cd, env, sudo, settings, lcd
from fabric.decorators import hosts
username = os.getenv('PYCON_USERNAME')
# env.hosts = [f'{username}@www.pycon.ng']
password = os.getenv('PYCON_PRODUCTION_PASSWORD', '')
def common_code(code_dir):
with settings(user=username, password=password):
with cd(code_dir):
run("pwd")
run("git pull")
sudo("docker-compose build")
sudo("docker-compose kill django")
sudo("docker-compose rm -f django")
sudo("docker-compose up -d")
# sudo("docker-compose run django python manage.py collectstatic --noinput")
# sudo("docker-compose run django python manage.py migrate --noinput")
def deploy_staging():
with settings(user="root", password=password):
with cd("/root/pyconng"):
run("pwd")
run("git checkout cfp")
run("git pull")
sudo("docker-compose -f dev.yml build django2")
sudo("docker-compose -f dev.yml up -d django2")
def deploy_current():
print("hello World")
run("pwd")
code_dir = '/home/{}/pyconng'.format(username)
common_code(code_dir)
def display_logs():
with settings(user="pycon", password=password):
cd("/home/pycon/pyconng")
sudo("docker-compose logs --follow django")
def start():
local('docker-compose -f dev.yml kill django')
local('docker-compose -f dev.yml up -d django')
def logs():
local('docker-compose -f dev.yml logs --follow --tail=10 django')
def console():
local('docker exec -i -t pyconng_django_1 bash')
@hosts("sama@app-dev.beeola.me")
def deploy_current(branch="master",username='',r_password=''):
print("hello World")
run("pwd")
code_dir = "/home/sama/app_code/pyconng"
with settings(user="sama", password=password):
with cd(code_dir):
run("pwd")
run("git checkout -f %s" % branch)
if "code" in code_dir:
run("git pull -f")
else:
run("git pull -f")
run('./boot_app.sh {} {}'.format(username,r_password))