From ecc7ec0de8799de2fc7a27e754586d5bc67bef49 Mon Sep 17 00:00:00 2001 From: Nikolai R Kristiansen Date: Sun, 5 Jan 2020 21:54:27 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Add=20fabfile=20for=20easier=20d?= =?UTF-8?q?eployment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fabfile.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 fabfile.py diff --git a/fabfile.py b/fabfile.py new file mode 100644 index 0000000..0885576 --- /dev/null +++ b/fabfile.py @@ -0,0 +1,23 @@ +import os + +from fabric import Connection +from invoke import task + + +@task() +def deploy(c): + """Make sure proxy_user is set to your neuf username.""" + project_path = '/opt/mdb' + proxy_user = os.getenv('DEPLOY_USER', os.getenv('USER')) + + c = Connection(host='gitdeploy@sega.neuf.no', gateway=Connection('login.neuf.no', user=proxy_user)) + + with c.cd(project_path), c.prefix('source {}/venv/bin/activate'.format(project_path)): + c.run('git pull') # Get source + c.run('pip install -U pip') + c.run('pip install -r requirements.txt') # install deps in virtualenv + c.run('python manage.py collectstatic --noinput') # Collect static + c.run('python manage.py migrate') # Run DB migrations + + # Reload gunicorn + c.sudo('/usr/bin/supervisorctl pid mdb.neuf.no | xargs kill -HUP', shell=False)