@@ -72,17 +72,13 @@ def compose_up(
7272 "Check ENVIRONMENT setting in .env file."
7373 )
7474
75- version = helpers .get_latest_local_version_tag ()
76- if not helpers .is_production ():
77- version += "-dev"
78-
79- cmd = f"{ helpers .build_compose_cmd (profile )} up"
80-
81- if not build :
82- cmd += " --no-build"
75+ if build :
76+ cmd = f"{ helpers .build_compose_cmd ()} build"
77+ cmd += f" --build-arg PROJECT_VERSION={ helpers .get_project_version ()} -cli"
78+ helpers .execute_cmd (cmd )
8379
84- cmd += " --detach"
85- helpers .execute_cmd (cmd , env = { "PROJECT_VERSION" : version } )
80+ cmd = f" { helpers . build_compose_cmd ( profile ) } up --no-build --detach"
81+ helpers .execute_cmd (cmd )
8682
8783
8884def compose_down (
@@ -104,27 +100,21 @@ def stack_deploy(build: Annotated[bool, typer.Option(help="Build images")] = Fal
104100
105101 helpers .prepare_environment ()
106102
107- config = helpers .load_config_from_env_file ()
108- if config .get ("ENVIRONMENT" ) != "production" :
103+ if not helpers .is_production ():
109104 sys .exit (
110105 "stack-deploy task can only be used in production environment. "
111106 "Check ENVIRONMENT setting in .env file."
112107 )
113108
114109 if build :
115110 cmd = f"{ helpers .build_compose_cmd ()} build"
111+ cmd += f" --build-arg PROJECT_VERSION={ helpers .get_project_version ()} -cli"
116112 helpers .execute_cmd (cmd )
117113
118- version = helpers .get_latest_local_version_tag ()
119- if not helpers .is_production ():
120- version += "-dev"
121-
122114 # Docker Swarm Mode does not support .env files so we load the .env file manually
123115 # and pass the content as an environment variables.
124116 env = helpers .load_config_from_env_file ()
125117
126- env ["PROJECT_VERSION" ] = version
127-
128118 cmd = "docker stack deploy --detach "
129119 cmd += f" -c { helpers .get_compose_base_file ()} "
130120 cmd += f" -c { helpers .get_compose_env_file ()} "
0 commit comments