-
-
Save phpdude/9bf03ce475457373102a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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