File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from dataclasses import dataclass
22
3- from fabric import task
3+ from fabric import Connection , task
44from 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
136147def pypi_build (c ):
137148 c .run ("python -m pip install -U -r requirements.d/pypi.txt" )
You can’t perform that action at this time.
0 commit comments