Compare commits

..

3 Commits

2 changed files with 89 additions and 23 deletions

View File

@@ -235,7 +235,7 @@ status service="" compose-file="":
# View logs for specific service or all services
[no-cd]
logs service="" compose-file="":
logs service="" compose-file="" follow="true":
#!/usr/bin/env bash
set -euo pipefail
@@ -254,12 +254,17 @@ logs service="" compose-file="":
file_arg="-f $compose_file"
fi
follow_flag=""
if [ "{{follow}}" = "true" ]; then
follow_flag="-f"
fi
if [ -n "$service" ]; then
echo -e "{{BLUE}}Showing logs for: $service{{NORMAL}}"
$compose_cmd $file_arg logs -f "$service"
$compose_cmd $file_arg logs $follow_flag "$service"
else
echo -e "{{BLUE}}Showing logs for all services{{NORMAL}}"
$compose_cmd $file_arg logs -f
$compose_cmd $file_arg logs $follow_flag
fi
# Open shell in specific container

View File

@@ -183,10 +183,34 @@ _detect_runtime:
fi
# Auto-detect available runtime
if command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then
echo "docker"
elif command -v podman >/dev/null 2>&1; then
# Priority: real Docker daemon > podman > docker symlink to podman
# Check if docker command exists and is NOT a symlink to podman
if command -v docker >/dev/null 2>&1; then
docker_path=$(command -v docker)
# Check if it's a symlink pointing to podman
if [ -L "$docker_path" ]; then
docker_target=$(readlink "$docker_path")
if echo "$docker_target" | grep -q podman; then
# Docker is symlinked to podman, use podman directly
if command -v podman >/dev/null 2>&1; then
echo "podman"
exit 0
fi
fi
else
# Real docker binary, check if daemon is running
if docker info >/dev/null 2>&1; then
echo "docker"
exit 0
fi
fi
fi
# Check Podman as fallback
if command -v podman >/dev/null 2>&1; then
echo "podman"
exit 0
else
echo "Error: No container runtime available (docker or podman)" >&2
exit 1
@@ -195,27 +219,33 @@ _detect_runtime:
# Detect compose command based on available and working container runtime
_detect_compose:
#!/usr/bin/env bash
# Check Docker first - but make sure daemon is actually running
if command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then
# Docker daemon is running, check for compose
if docker compose version >/dev/null 2>&1; then
echo "docker compose"
elif command -v docker-compose >/dev/null 2>&1; then
echo "docker-compose"
else
echo "Error: Docker is running but no compose tool found" >&2
exit 1
fi
# Check Podman if Docker is not available or not running
elif command -v podman >/dev/null 2>&1; then
# Detect which runtime we're using
runtime=$(just _detect_runtime 2>/dev/null || echo "none")
if [ "$runtime" = "podman" ]; then
# Use podman-compose for podman
if command -v podman-compose >/dev/null 2>&1; then
echo "podman-compose"
exit 0
else
echo "Error: Podman found but podman-compose not available" >&2
echo "Error: Podman detected but podman-compose not available" >&2
exit 1
fi
elif [ "$runtime" = "docker" ]; then
# Use docker compose for docker
if docker compose version >/dev/null 2>&1; then
echo "docker compose"
exit 0
elif command -v docker-compose >/dev/null 2>&1; then
echo "docker-compose"
exit 0
else
echo "Error: Docker is available but no compose tool found" >&2
exit 1
fi
else
echo "Error: No container runtime (Docker or Podman) found" >&2
echo "Error: No container runtime detected" >&2
exit 1
fi
@@ -256,8 +286,13 @@ env-check:
echo ""
# Check Docker
docker_is_symlink=false
if command -v docker >/dev/null 2>&1; then
if docker info >/dev/null 2>&1; then
if [ -L "$(command -v docker)" ] && readlink "$(command -v docker)" | grep -q podman; then
docker_is_symlink=true
echo -e "{{YELLOW}}⚠ Docker command is symlinked to Podman{{NORMAL}}"
docker_available=false # Don't count symlink as real docker
elif docker info >/dev/null 2>&1; then
echo -e "{{GREEN}}✓ Docker Engine detected and running{{NORMAL}}"
docker_available=true
else
@@ -278,6 +313,32 @@ env-check:
podman_available=false
fi
echo ""
echo "================================================"
echo " RUNTIME SELECTION"
echo "================================================"
# Determine which runtime will be used
detected_runtime=$(just _detect_runtime 2>/dev/null || echo "none")
detected_compose=$(just _detect_compose 2>/dev/null || echo "none")
if [ "$detected_runtime" = "podman" ]; then
echo -e "{{GREEN}}🎯 Using Podman as container runtime{{NORMAL}}"
if [ "$docker_is_symlink" = true ]; then
echo -e "{{BLUE}} (Docker symlink detected, using Podman backend){{NORMAL}}"
fi
elif [ "$detected_runtime" = "docker" ]; then
echo -e "{{GREEN}}🎯 Using Docker as container runtime{{NORMAL}}"
else
echo -e "{{RED}}❌ No container runtime available{{NORMAL}}"
fi
if [ "$detected_compose" != "none" ]; then
echo -e "{{GREEN}}✓ Compose tool: $detected_compose{{NORMAL}}"
else
echo -e "{{RED}}✗ No compose tool available{{NORMAL}}"
fi
echo ""
echo "================================================"
echo " SUMMARY"