-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
fabfile.py
64 lines (52 loc) · 1.69 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
from fabric import Connection, Config, task
from invoke import Exit
import getpass
# Name of the git repository
GIT_REPO = 'stembureaus'
# Path of the directory
DIR = '/home/projects/%s' % (GIT_REPO)
# Container used to compile the assets
NODE_CONTAINER = 'stm_nodejs_1'
# Server name
SERVER = 'Neon'
@task
def deploy(c):
sudo_pass = getpass.getpass("Enter your sudo password on %s: " % SERVER)
config = Config(overrides={'sudo': {'password': sudo_pass}})
c = Connection(SERVER, config=config)
# Pull from GitHub
c.run(
'bash -c "cd %s && git pull [email protected]:openstate/%s.git"' % (
DIR,
GIT_REPO
)
)
# Compile assets
output = c.sudo(
'docker inspect --format="{{.State.Status}}" %s' % (NODE_CONTAINER)
)
if output.stdout.strip() != 'running':
raise Exit(
'\n*** ERROR: The %s container, used to compile the assets, is '
'not running. Please build/run/start the container.' % (
NODE_CONTAINER
)
)
c.sudo('docker exec %s yarn' % (NODE_CONTAINER))
c.sudo('docker exec %s yarn prod' % (NODE_CONTAINER))
# Reload app
c.run('bash -c "cd %s && touch uwsgi-touch-reload"' % (DIR))
@task
def deploy_without_compile(c):
sudo_pass = getpass.getpass("Enter your sudo password on %s: " % SERVER)
config = Config(overrides={'sudo': {'password': sudo_pass}})
c = Connection(SERVER, config=config)
# Pull from GitHub
c.run(
'bash -c "cd %s && git pull [email protected]:openstate/%s.git"' % (
DIR,
GIT_REPO
)
)
# Reload app
c.run('bash -c "cd %s && touch uwsgi-touch-reload"' % (DIR))