Skip to content

Instantly share code, notes, and snippets.

@phpdude phpdude/fabfile.py Secret
Created Mar 3, 2016

Embed
What would you like to do?
# coding=utf-8
import os
from fabric.api import env
from fabric.context_managers import cd
from fabric.decorators import roles
from fabric.operations import run, local, put
env.roledefs['master'] = ['project@ip']
def _production_env():
# Speedup connection setup to server.
env.disable_known_hosts = True
env.key_filename = [os.path.join(os.environ['HOME'], '.ssh', 'id_rsa')]
env.project_root = '~/app/'
@roles('master')
def build():
local('docker build -f production/Dockerfile -t phpdude/project:app .')
local('docker push phpdude/project:app')
@roles('master')
def deploy():
_production_env()
with cd(env.project_root):
put('production/docker-compose.yml', '~/app/')
run('docker-compose pull')
run('docker-compose up -d')
@roles('master')
def clear_cache():
_production_env()
with cd(env.project_root):
run('docker-compose exec --rm manage clear_cache')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.