Skip to content

Commit 7a2e675

Browse files
committed
build: update fabfile.py
1 parent 92978dc commit 7a2e675

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

fabfile.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from dataclasses import dataclass
22

3-
from fabric import task
3+
from fabric import Connection, task
44
from invoke.context import Context
55

66
_DOCKER_PULL = "docker pull --platform=linux/amd64"
@@ -115,23 +115,34 @@ def build(c):
115115
docker_build(c)
116116

117117

118-
@task
119-
def deploy(c):
120-
print("deploy container...")
121-
122-
_recreate_container(
123-
c=c,
124-
container_name=ev.get_container_name(),
125-
docker_run_cmd=f"""{_DOCKER_RUN} -dit --restart unless-stopped \
118+
def docker_deploy(c):
119+
docker_run_cmd = f"""{_DOCKER_RUN} -dit --restart unless-stopped \
126120
-p 0.0.0.0:8000:8000 \
127121
-v {ev.DEPLOY_WORK_PATH}:/data \
128122
-e GID={ev.CONTAINER_GID} -e UID={ev.CONTAINER_UID} \
129-
-e WEBDAV_LOGGING_LEVEL=DEBUG \
130123
--name {ev.get_container_name()} \
131-
{ev.DOCKER_IMAGE_FULL_NAME}""",
124+
{ev.DOCKER_IMAGE_FULL_NAME}"""
125+
126+
_recreate_container(
127+
c=c, container_name=ev.get_container_name(), docker_run_cmd=docker_run_cmd
132128
)
133129

134130

131+
@task
132+
def deploy(c):
133+
print("deploy container...")
134+
135+
if ev.DEPLOY_STAGE != "localhost":
136+
docker_push_image(c)
137+
138+
c = Connection(
139+
host=ev.DEPLOY_SSH_HOST, port=ev.DEPLOY_SSH_PORT, user=ev.DEPLOY_SSH_USER
140+
)
141+
docker_pull_image(c)
142+
143+
docker_deploy(c)
144+
145+
135146
@task
136147
def pypi_build(c):
137148
c.run("python -m pip install -U -r requirements.d/pypi.txt")

0 commit comments

Comments
 (0)