feat: replace docker.py with service.py for improved Docker service management
Some checks failed
Nix Format Check / check-format (push) Failing after 37s
Some checks failed
Nix Format Check / check-format (push) Failing after 37s
This commit is contained in:
parent
f239dd1a46
commit
f31e77a2f3
@ -72,6 +72,20 @@ def cmd_logs(args):
|
||||
|
||||
return run_docker_compose(cmd, service_name=args.service)
|
||||
|
||||
def check_service_running(service_name):
|
||||
"""Check if service has running containers"""
|
||||
compose_file = get_service_path(service_name)
|
||||
if not compose_file:
|
||||
return False
|
||||
|
||||
result = subprocess.run(
|
||||
["docker", "compose", "-f", compose_file, "ps", "--quiet"],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
|
||||
return bool(result.stdout.strip())
|
||||
|
||||
def cmd_list(args):
|
||||
"""List available Docker services"""
|
||||
if not os.path.exists(SERVICES_DIR):
|
||||
@ -86,9 +100,12 @@ def cmd_list(args):
|
||||
printfe("yellow", "No Docker services found")
|
||||
return 0
|
||||
|
||||
println("Available Docker services:")
|
||||
println("Available Docker services:", 'blue')
|
||||
for service in sorted(services):
|
||||
println(f" - {service}")
|
||||
is_running = check_service_running(service)
|
||||
status = "[RUNNING]" if is_running else "[STOPPED]"
|
||||
color = "green" if is_running else "red"
|
||||
printfe(color, f" - {service:<20} {status}")
|
||||
|
||||
return 0
|
||||
|
8
bin/dotf
8
bin/dotf
@ -45,9 +45,9 @@ def auto_start(args):
|
||||
"""Run the auto-start action"""
|
||||
return run_script(f"{DOTFILES_BIN}/actions/auto-start.py", args)
|
||||
|
||||
def docker(args):
|
||||
"""Run the docker action"""
|
||||
return run_script(f"{DOTFILES_BIN}/actions/docker.py", args)
|
||||
def service(args):
|
||||
"""Run the service/docker action"""
|
||||
return run_script(f"{DOTFILES_BIN}/actions/service.py", args)
|
||||
|
||||
def ensure_git_hooks():
|
||||
"""Ensure git hooks are correctly set up"""
|
||||
@ -103,7 +103,7 @@ def main():
|
||||
"hello": hello,
|
||||
"secrets": secrets,
|
||||
"auto-start": auto_start,
|
||||
"docker": docker
|
||||
"service": service
|
||||
}
|
||||
|
||||
if command in commands:
|
||||
|
Loading…
x
Reference in New Issue
Block a user