Перенес запуск скриптов деплоя в общий файл
This commit is contained in:
18
app/wiki/deploy.py
Normal file
18
app/wiki/deploy.py
Normal file
@ -0,0 +1,18 @@
|
||||
from fabric import Connection
|
||||
import os
|
||||
import shlex
|
||||
|
||||
|
||||
def deploy(context, app_name, ssh_host):
|
||||
docker_compose = os.path.join(os.path.dirname(__file__), "docker-compose.yml")
|
||||
print("Deploy app from", docker_compose)
|
||||
print("Start setup remote host", ssh_host)
|
||||
with Connection(ssh_host) as c:
|
||||
c.put(
|
||||
local=docker_compose,
|
||||
remote=f"/home/{app_name}/docker-compose.yml",
|
||||
)
|
||||
c.run("cp .env .env.prod")
|
||||
c.run(
|
||||
f"docker-compose --project-name {shlex.quote(app_name)} --env-file=.env.prod up --detach --remove-orphans"
|
||||
)
|
@ -1,26 +0,0 @@
|
||||
from fabric import Connection
|
||||
from invoke import task
|
||||
import subprocess
|
||||
import shlex
|
||||
|
||||
APP_NAME = "wiki"
|
||||
SSH_HOST = f"{APP_NAME}@158.160.115.150"
|
||||
DOCKER_REGISTRY = "cr.yandex/crplfk0168i4o8kd7ade"
|
||||
|
||||
|
||||
def run(args):
|
||||
return subprocess.run(args, check=True, capture_output=True).stdout
|
||||
|
||||
|
||||
@task
|
||||
def deploy(c):
|
||||
print("Ready to setup remote host")
|
||||
with Connection(SSH_HOST) as c:
|
||||
c.put(
|
||||
"docker-compose.yml",
|
||||
remote=f"/home/{APP_NAME}/docker-compose.yml",
|
||||
)
|
||||
c.run("cp .env .env.prod")
|
||||
c.run(
|
||||
f"docker-compose --project-name {shlex.quote(APP_NAME)} --env-file=.env.prod up --detach --remove-orphans"
|
||||
)
|
Reference in New Issue
Block a user