Skip to content

Instantly share code, notes, and snippets.

@Glideh
Created September 17, 2012 14:26
Show Gist options
  • Save Glideh/3737658 to your computer and use it in GitHub Desktop.
Save Glideh/3737658 to your computer and use it in GitHub Desktop.
A pretty fabfile to deploy a symfony2 project
from fabric.api import *
from fabric.colors import green
env.hosts = ['my_user@my_host']
env.password = 'my_password'
env.app_path = 'my/app/path'
def commit():
print(green("Commit last modifs..."))
local('git add -A && git commit')
def pushpull():
with cd(env.app_path):
print(green("Pushing to the ref..."))
local('git push')
print(green("Pulling to the Prod..."))
run('git pull')
def colstat():
print(green("Prod Collecting Static Files..."))
with cd(env.app_path):
run('php app/console assets:install web --symlink')
def cacheclear():
print(green("Prod Clearing Cache..."))
with cd(env.app_path):
sudo('php app/console cache:clear --env=prod', user='www-data')
def httpdrst():
print(green("Prod Restarting Apache..."))
sudo('apache2ctl restart')
def deploy():
pushpull()
colstat()
cacheclear()
# syncdb()
# httpdrst()
@Glideh
Copy link
Author

Glideh commented Sep 17, 2012

Simply run $ fab deploy from your SF2 project root and you'll get it deployed

@Glideh
Copy link
Author

Glideh commented May 7, 2014

Assuming that we should use ssh key instead of plain password set here and ACLs for www-data instead of using sudos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment