From f2094784b4efc46fc9c3117eb292fb753643c59f Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 3 Jan 2017 23:33:21 +0000 Subject: [PATCH] Add fabfile --- .gitignore | 1 + fabfile.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 fabfile.py diff --git a/.gitignore b/.gitignore index f0663304..179c7aa3 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ /vendor/ .sass-cache/ publish.sh +*.pyc diff --git a/fabfile.py b/fabfile.py new file mode 100644 index 00000000..de84f573 --- /dev/null +++ b/fabfile.py @@ -0,0 +1,37 @@ +from fabric.api import * +from fabric.contrib.project import rsync_project + +env.hosts = ['production'] +env.use_ssh_config = True + +project_root = '/var/www/oliverdavies' + +@task +def deploy(): + build_assets() + build_site() + deploy_site() + fix_file_permissions() + +def build_site(): + local('composer install --no-dev') + local('bin/sculpin generate -e prod --clean --no-interaction --quiet') + local('echo %s > output_prod/version' % env.build_number) + +def build_assets(): + local('yarn --pure-lockfile') + local('./node_modules/.bin/bower install') + local('./node_modules/.bin/gulp build --production --silent') + +def deploy_site(): + rsync_project( + remote_dir='%s/web/' % project_root, + local_dir='output_prod/', + default_opts='-vzcrSLh', + delete=True + ) + run('sudo service nginx configtest && sudo service nginx reload') + +def fix_file_permissions(): + run('sudo chown -R jarvis:www-data %s/web' % project_root) + run('sudo chmod -R 750 %s/web' % project_root)