@@ -357,16 +357,60 @@ def ensure_gitignore_has_env(project_root: Path):
357357 print_success ("Updated .gitignore" )
358358
359359
360+ def get_compose_command (runtime : str ) -> list [str ]:
361+ """Get the appropriate compose command for the runtime."""
362+ # Check if 'podman compose' (plugin) works
363+ if runtime == "podman" :
364+ try :
365+ result = subprocess .run (
366+ ["podman" , "compose" , "version" ],
367+ capture_output = True ,
368+ timeout = 10
369+ )
370+ if result .returncode == 0 :
371+ return ["podman" , "compose" ]
372+ except (subprocess .TimeoutExpired , OSError ):
373+ pass
374+
375+ # Fall back to podman-compose (standalone)
376+ if shutil .which ("podman-compose" ):
377+ return ["podman-compose" ]
378+
379+ # Docker uses 'docker compose'
380+ return [runtime , "compose" ]
381+
382+
360383def start_containers (runtime : str , project_root : Path ) -> bool :
361384 """Start the containers using the detected runtime."""
362- print_info ( "Starting containers (this may take a while on first run)..." )
385+ compose_cmd = get_compose_command ( runtime )
363386
387+ # Build the image first (required for podman with local images)
388+ print_info ("Building container image (this may take a while on first run)..." )
364389 try :
365390 result = subprocess .run (
366- [runtime , "compose" , "up" , "-d" , "-- build" ],
391+ [* compose_cmd , "build" ],
367392 cwd = project_root ,
368393 timeout = 600 # 10 minute timeout for build
369394 )
395+ if result .returncode != 0 :
396+ print_error ("Failed to build container image" )
397+ return False
398+ print_success ("Container image built successfully" )
399+ except subprocess .TimeoutExpired :
400+ print_error ("Container build timed out" )
401+ return False
402+ except OSError as e :
403+ print_error (f"Failed to build container: { e } " )
404+ return False
405+
406+ # Start the containers
407+ print_info ("Starting containers..." )
408+ try :
409+ result = subprocess .run (
410+ [* compose_cmd , "up" , "-d" ],
411+ cwd = project_root ,
412+ timeout = 120 # 2 minute timeout for start
413+ )
370414 return result .returncode == 0
371415 except subprocess .TimeoutExpired :
372416 print_error ("Container startup timed out" )
@@ -378,6 +422,8 @@ def start_containers(runtime: str, project_root: Path) -> bool:
378422
379423def print_next_steps (runtime : str , started : bool ):
380424 """Print next steps for the user."""
425+ compose_cmd = " " .join (get_compose_command (runtime ))
426+
381427 print ("\n " + "-" * 60 )
382428 print (" Next Steps" )
383429 print ("-" * 60 + "\n " )
@@ -387,13 +433,15 @@ def print_next_steps(runtime: str, started: bool):
387433 print_info ("Once ready, access Melodee at: http://localhost:8080" )
388434 print ()
389435 print_info (f"Useful commands:" )
390- print (f" { runtime } compose logs -f # View logs" )
391- print (f" { runtime } compose ps # Check status" )
392- print (f" { runtime } compose down # Stop containers" )
393- print (f" { runtime } compose up -d --build # Rebuild and start" )
436+ print (f" { compose_cmd } logs -f # View logs" )
437+ print (f" { compose_cmd } ps # Check status" )
438+ print (f" { compose_cmd } down # Stop containers" )
439+ print (f" { compose_cmd } build # Rebuild image" )
440+ print (f" { compose_cmd } up -d # Start containers" )
394441 else :
395442 print_info ("To start Melodee, run:" )
396- print (f" { runtime } compose up -d --build" )
443+ print (f" { compose_cmd } build" )
444+ print (f" { compose_cmd } up -d" )
397445 print ()
398446 print_info ("Then access Melodee at: http://localhost:8080" )
399447
0 commit comments