@@ -97,6 +97,22 @@ def _is_interactive() -> bool:
9797 return sys.stdin.isatty() and os.environ.get("CI", "").lower() != "true"
9898
9999
100+ def _wait_for_dev_containers_start(ctx: Context) -> None:
101+ """Start the dev containers and wait until they are fully up.
102+
103+ This function triggers the `docker_start` duty with the `dev` profile,
104+ then continuously checks the containers status until `{{ project_name }}-dev`
105+ is running.
106+ """
107+ docker_start.run(env="dev")
108+ while True:
109+ output = ctx.run(
110+ ["docker", "compose", "top"], silent=True, allow_overrides=False, capture=True
111+ )
112+ if "{{ project_name }}-dev" in output:
113+ break
114+
115+
100116@contextmanager
101117def _setup_container(ctx: Context) -> Iterator[None]:
102118 """Ensure the dev Docker container is running for the duration of a context block.
@@ -112,19 +128,13 @@ def _setup_container(ctx: Context) -> Iterator[None]:
112128 )
113129 if build_docker_images:
114130 docker_build.run(env="dev")
115- docker_start.run(env="dev" )
131+ _wait_for_dev_containers_start(ctx )
116132 else:
117133 output = ctx.run(
118134 ["docker", "compose", "top"], silent=True, allow_overrides=False, capture=True
119135 )
120136 if "{{ project_name }}-dev" not in output:
121- docker_start.run(env="dev")
122- while True:
123- output = ctx.run(
124- ["docker", "compose", "top"], silent=True, allow_overrides=False, capture=True
125- )
126- if "{{ project_name }}-dev" in output:
127- break
137+ _wait_for_dev_containers_start(ctx)
128138 try:
129139 yield
130140 finally:
0 commit comments