P5-4836 deploy api to production (new hostname)
This commit is contained in:
Vendored
+18
-19
@@ -1,24 +1,23 @@
|
||||
from fabric.api import *
|
||||
from fabric.api import env, lcd, local, abort
|
||||
|
||||
env.user = 'ubuntu'
|
||||
env.key_filename = '~/.ssh/ukad.pem'
|
||||
def basic_environment_settings():
|
||||
env.stack_name = 'api'
|
||||
|
||||
env.hosts = (
|
||||
'ec2-52-50-174-196.eu-west-1.compute.amazonaws.com', #api2-dev
|
||||
)
|
||||
def staging():
|
||||
basic_environment_settings()
|
||||
env.environment = 'staging'
|
||||
|
||||
def production():
|
||||
basic_environment_settings()
|
||||
env.environment = 'production'
|
||||
|
||||
def cloudformation_update():
|
||||
if env.environment != 'staging':
|
||||
abort('Only staging is deployed soo far')
|
||||
with lcd('./cloudformation/'):
|
||||
local('make update-stack ENVIRONMENT_NAME={0} STACK_NAME={1}'.format(env.environment, env.stack_name))
|
||||
|
||||
def deploy():
|
||||
branch = local('git rev-parse --abbrev-ref HEAD', capture=True)
|
||||
local('git archive --format tar.gz -o /tmp/api.tar.gz {0}'.format(branch), capture=False)
|
||||
put('/tmp/api.tar.gz', '/tmp/api.tar.gz')
|
||||
with warn_only():
|
||||
sudo('service nginx stop')
|
||||
sudo('service api-uwsgi stop')
|
||||
with cd('/srv/api'):
|
||||
run('tar xzf /tmp/api.tar.gz')
|
||||
run('rm /tmp/api.tar.gz')
|
||||
with warn_only():
|
||||
sudo('service api-uwsgi start')
|
||||
sudo('service nginx start')
|
||||
local('rm /tmp/api.tar.gz')
|
||||
if env.environment != 'staging':
|
||||
abort('Local deploy to staging only. Production deploy is automatic when merging to master.')
|
||||
local('make publish-to-staging')
|
||||
|
||||
Reference in New Issue
Block a user