Add fabfile

This commit is contained in:
Oliver Davies 2017-01-03 23:33:21 +00:00
parent c41733d6e5
commit f2094784b4
2 changed files with 38 additions and 0 deletions

1
.gitignore vendored
View file

@ -8,3 +8,4 @@
/vendor/ /vendor/
.sass-cache/ .sass-cache/
publish.sh publish.sh
*.pyc

37
fabfile.py vendored Normal file
View file

@ -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)