Simplify fabfile

This commit is contained in:
Nikolai R Kristiansen committed 2018-03-17 12:32:02 +01:00
1 parent d5e494de83
commit f4e0865f67
1 file changed
+7 -8
Vendored
+7 -8
View File
@@ -1,24 +1,23 @@
from contextlib import contextmanager as _contextmanager from contextlib import contextmanager
from fabric.api import run, sudo, env, cd, prefix from fabric.api import run, sudo, env, cd, prefix
from fabric.context_managers import shell_env
env.use_ssh_config = True env.use_ssh_config = True
env.hosts = ['dreamcast.neuf.no'] env.hosts = ['dreamcast.neuf.no']
env.project_path = '/var/www/neuf.no/infoskjerm2' env.project_path = '/var/www/neuf.no/infoskjerm2'
env.user = 'gitdeploy' env.user = 'gitdeploy'
env.activate = 'source {}/.venv/bin/activate'.format(env.project_path)
@_contextmanager @contextmanager
def virtualenv(): def virtualenv():
with cd(env.project_path), prefix(env.activate): with cd(env.project_path), prefix('pipenv shell'):
yield yield
def deploy(): def deploy():
with shell_env(PIPENV_VENV_IN_PROJECT='yup'), virtualenv(): run('git pull') # Get source
run('git pull') # Get source run('pipenv install') # install deps in virtualenv
run('pipenv install') # install deps in virtualenv
with virtualenv():
run('umask 022; python manage.py collectstatic --noinput') # Collect static run('umask 022; python manage.py collectstatic --noinput') # Collect static
run('python manage.py migrate') # Run DB migrations run('python manage.py migrate') # Run DB migrations