You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
2.3 KiB
108 lines
2.3 KiB
# -*- coding: utf-8 -*-
|
|
# flake8: noqa
|
|
|
|
from fabric.api import *
|
|
from conf.deploy.common import BRANCH_DEVELOP, BRANCH_PROD, PROJECT_NAME, PROJECT_NAME_DEVELOP
|
|
from conf.deploy.prod import HOSTS, USER, PASS
|
|
from conf.deploy.develop import HOSTS as HOSTS_DEVELOP, USER as USER_DEVELOP, PASS as PASS_DEVELOP
|
|
|
|
PROJECT_DIR = f'opt/app/{PROJECT_NAME}'
|
|
PROJECT_DIR_DEVELOP = f'projects/{PROJECT_NAME_DEVELOP}'
|
|
|
|
env.user = USER
|
|
env.password = PASS
|
|
env.hosts = HOSTS
|
|
|
|
|
|
@task
|
|
def pull_prod():
|
|
with cd(PROJECT_DIR):
|
|
run(f'git pull origin {BRANCH_PROD}')
|
|
|
|
|
|
@task
|
|
def docker_rebuild_prod():
|
|
with cd(PROJECT_DIR):
|
|
run('docker-compose build')
|
|
run('docker-compose down')
|
|
run('docker-compose up -d')
|
|
|
|
|
|
@task
|
|
def docker_restart_prod():
|
|
with cd(PROJECT_DIR):
|
|
run('docker-compose restart web')
|
|
|
|
|
|
@task
|
|
def upgrade_prod():
|
|
pull_prod()
|
|
docker_rebuild_prod()
|
|
|
|
|
|
@task
|
|
def update_prod():
|
|
pull_prod()
|
|
docker_restart_prod()
|
|
|
|
|
|
@task
|
|
def pull_develop():
|
|
env.user = USER_DEVELOP
|
|
env.password = PASS_DEVELOP
|
|
env.hosts = HOSTS_DEVELOP
|
|
|
|
with cd(PROJECT_DIR):
|
|
run(f'git pull origin {BRANCH_DEVELOP}')
|
|
|
|
|
|
@task
|
|
def docker_rebuild_develop():
|
|
env.user = USER_DEVELOP
|
|
env.password = PASS_DEVELOP
|
|
env.hosts = HOSTS_DEVELOP
|
|
|
|
with cd(PROJECT_DIR_DEVELOP):
|
|
run('docker-compose -f docker-compose.develop.conf build')
|
|
run('docker-compose -f docker-compose.develop.conf down')
|
|
run('docker-compose -f docker-compose.develop.conf up -d')
|
|
|
|
|
|
@task
|
|
def docker_restart_develop():
|
|
env.user = USER_DEVELOP
|
|
env.password = PASS_DEVELOP
|
|
env.hosts = HOSTS_DEVELOP
|
|
|
|
with cd(PROJECT_DIR_DEVELOP):
|
|
run('docker-compose -f docker-compose.develop.conf restart web')
|
|
|
|
|
|
@task
|
|
def docker_bash_develop():
|
|
env.user = USER_DEVELOP
|
|
env.password = PASS_DEVELOP
|
|
env.hosts = HOSTS_DEVELOP
|
|
|
|
with cd(PROJECT_DIR_DEVELOP):
|
|
run('docker-compose -f docker-compose.develop.conf exec web bash')
|
|
|
|
|
|
@task
|
|
def upgrade_develop():
|
|
env.user = USER_DEVELOP
|
|
env.password = PASS_DEVELOP
|
|
env.hosts = HOSTS_DEVELOP
|
|
|
|
pull_develop()
|
|
docker_rebuild_develop()
|
|
|
|
|
|
@task
|
|
def update_prod():
|
|
env.user = USER
|
|
env.password = PASS
|
|
env.hosts = HOSTS_DEVELOP
|
|
|
|
pull_develop()
|
|
docker_restart_develop()
|
|
|