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

101
core.just
View File

@@ -183,10 +183,34 @@ _detect_runtime:
fi fi
# Auto-detect available runtime # Auto-detect available runtime
if command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then # Priority: real Docker daemon > podman > docker symlink to podman
echo "docker"
elif command -v podman >/dev/null 2>&1; then # 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" echo "podman"
exit 0
else else
echo "Error: No container runtime available (docker or podman)" >&2 echo "Error: No container runtime available (docker or podman)" >&2
exit 1 exit 1
@@ -195,27 +219,33 @@ _detect_runtime:
# Detect compose command based on available and working container runtime # Detect compose command based on available and working container runtime
_detect_compose: _detect_compose:
#!/usr/bin/env bash #!/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 # Detect which runtime we're using
# Docker daemon is running, check for compose runtime=$(just _detect_runtime 2>/dev/null || echo "none")
if docker compose version >/dev/null 2>&1; then
echo "docker compose" if [ "$runtime" = "podman" ]; then
elif command -v docker-compose >/dev/null 2>&1; then # Use podman-compose for podman
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
if command -v podman-compose >/dev/null 2>&1; then if command -v podman-compose >/dev/null 2>&1; then
echo "podman-compose" echo "podman-compose"
exit 0
else 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 exit 1
fi fi
else else
echo "Error: No container runtime (Docker or Podman) found" >&2 echo "Error: No container runtime detected" >&2
exit 1 exit 1
fi fi
@@ -256,8 +286,13 @@ env-check:
echo "" echo ""
# Check Docker # Check Docker
docker_is_symlink=false
if command -v docker >/dev/null 2>&1; then 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}}" echo -e "{{GREEN}}✓ Docker Engine detected and running{{NORMAL}}"
docker_available=true docker_available=true
else else
@@ -278,6 +313,32 @@ env-check:
podman_available=false podman_available=false
fi 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 "================================================" echo "================================================"
echo " SUMMARY" echo " SUMMARY"
@@ -296,4 +357,4 @@ env-check:
echo "Please install Docker or Podman:" echo "Please install Docker or Podman:"
echo " • Docker: https://docs.docker.com/get-docker/" echo " • Docker: https://docs.docker.com/get-docker/"
echo " • Podman: https://podman.io/getting-started/installation" echo " • Podman: https://podman.io/getting-started/installation"
fi fi