3636from stack .constants import container_file_name , container_lock_file_name
3737from stack .opts import opts
3838from stack .repos .setup_repositories import fs_path_for_repo , process_repo
39- from stack .util import get_dev_root_path , include_exclude_check , stack_is_external , error_exit , get_yaml
40-
39+ from stack .util import get_dev_root_path , include_exclude_check , stack_is_external , error_exit , get_yaml , check_if_stack_exists
4140
4241docker = DockerClient ()
4342
@@ -143,27 +142,8 @@ def process_container(build_context: BuildContext) -> bool:
143142 return True
144143
145144
146- @click .command (hidden = True )
147- @click .option ("--include" , help = "only build these containers" )
148- @click .option ("--exclude" , help = "don't build these containers" )
149- @click .option ("--force-rebuild" , is_flag = True , default = False , help = "Override dependency checking -- always rebuild" )
150- @click .option ("--extra-build-args" , help = "Supply extra arguments to build" )
151- @click .option ("--publish-images" , is_flag = True , default = False , help = "Publish the built images in the specified image registry" )
152- @click .option ("--image-registry" , help = "Specify the image registry for --publish-images" )
153- @click .pass_context
154- def legacy_command (ctx , include , exclude , force_rebuild , extra_build_args , publish_images , image_registry ):
155- """build the set of containers required for a complete stack"""
156-
157- # Legacy support for build-containers command.
158-
159- build_policy = "build"
160- if force_rebuild :
161- build_policy = "build-force"
162-
163- _prepare_containers (ctx , include , exclude , False , build_policy , extra_build_args , True , publish_images , image_registry , None )
164-
165-
166145@click .command ()
146+ @click .option ("--stack" , help = "path to the stack" , required = True )
167147@click .option ("--include" , help = "only build these containers" )
168148@click .option ("--exclude" , help = "don't build these containers" )
169149@click .option ("--git-ssh" , is_flag = True , default = False )
@@ -174,14 +154,9 @@ def legacy_command(ctx, include, exclude, force_rebuild, extra_build_args, publi
174154@click .option ("--image-registry" , help = "Specify the remote image registry (default: auto-detect per-container)" )
175155@click .option ("--target-arch" , help = "Specify a target architecture (only for use with --no-pull)" )
176156@click .pass_context
177- def command (ctx , include , exclude , git_ssh , build_policy , extra_build_args , no_pull , publish_images , image_registry , target_arch ):
157+ def command (ctx , stack , include , exclude , git_ssh , build_policy , extra_build_args , no_pull , publish_images , image_registry , target_arch ):
178158 """build (or fetch pre-built) stack containers"""
179-
180- _prepare_containers (ctx , include , exclude , git_ssh , build_policy , extra_build_args , no_pull , publish_images , image_registry , target_arch )
181-
182-
183- def _prepare_containers (ctx , include , exclude , git_ssh , build_policy , extra_build_args , no_pull , publish_images , image_registry , target_arch ):
184- stack = ctx .obj .stack
159+ check_if_stack_exists (stack )
185160
186161 if build_policy not in BUILD_POLICIES :
187162 error_exit (f"{ build_policy } is not one of { BUILD_POLICIES } " )
0 commit comments