fix: Makefile supports docker compose v2 plugin and v1 standalone

DC variable auto-detects available command at build time.
Also fixes backup and dev targets that incorrectly used $(DC).yml.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-22 07:45:56 -04:00
parent 4ed2a6cbae
commit f78a99bbd4
+19 -16
View File
@@ -3,6 +3,9 @@
.PHONY: help start stop restart status logs clean setup init-peers build build-api build-webui .PHONY: help start stop restart status logs clean setup init-peers build build-api build-webui
# Detect docker compose command (v2 plugin preferred, fallback to v1 standalone)
DC := $(shell docker compose version >/dev/null 2>&1 && echo "docker compose" || echo "docker-compose")
# Default target # Default target
help: help:
@echo "Personal Internet Cell - Management Commands" @echo "Personal Internet Cell - Management Commands"
@@ -51,52 +54,52 @@ init-peers:
# Management commands # Management commands
start: start:
@echo "Starting Personal Internet Cell..." @echo "Starting Personal Internet Cell..."
docker-compose up -d $(DC) up -d
@echo "Services started. Check status with 'make status'" @echo "Services started. Check status with 'make status'"
stop: stop:
@echo "Stopping Personal Internet Cell..." @echo "Stopping Personal Internet Cell..."
docker-compose down $(DC) down
@echo "Services stopped." @echo "Services stopped."
restart: restart:
@echo "Restarting Personal Internet Cell..." @echo "Restarting Personal Internet Cell..."
docker-compose restart $(DC) restart
@echo "Services restarted." @echo "Services restarted."
status: status:
@echo "Personal Internet Cell Status:" @echo "Personal Internet Cell Status:"
@echo "================================" @echo "================================"
docker-compose ps $(DC) ps
@echo "" @echo ""
@echo "API Status:" @echo "API Status:"
@curl -s http://localhost:3000/health || echo "API not responding" @curl -s http://localhost:3000/health || echo "API not responding"
logs: logs:
@echo "Showing logs from all services..." @echo "Showing logs from all services..."
docker-compose logs -f $(DC) logs -f
# Individual service commands # Individual service commands
start-dns: start-dns:
@echo "Starting DNS service..." @echo "Starting DNS service..."
docker-compose up -d dns $(DC) up -d dns
start-api: start-api:
@echo "Starting API service..." @echo "Starting API service..."
docker-compose up -d api $(DC) up -d api
start-wg: start-wg:
@echo "Starting WireGuard service..." @echo "Starting WireGuard service..."
docker-compose up -d wireguard $(DC) up -d wireguard
start-webui: start-webui:
@echo "Starting WebUi service..." @echo "Starting WebUi service..."
docker-compose up -d webui $(DC) up -d webui
# Maintenance commands # Maintenance commands
clean: clean:
@echo "Cleaning up containers and volumes..." @echo "Cleaning up containers and volumes..."
docker-compose down -v $(DC) down -v
docker system prune -f docker system prune -f
@echo "Cleanup complete." @echo "Cleanup complete."
@@ -116,21 +119,21 @@ restore:
# Development commands # Development commands
dev: dev:
@echo "Starting development environment..." @echo "Starting development environment..."
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d $(DC) -f docker-compose.yml -f docker-compose.dev.yml up -d
build: build:
@echo "Building API service..." @echo "Building API service..."
docker-compose build api $(DC) build api
build-api: build-api:
@echo "Rebuilding API (no cache)..." @echo "Rebuilding API (no cache)..."
docker-compose build --no-cache api $(DC) build --no-cache api
docker-compose up -d api $(DC) up -d api
build-webui: build-webui:
@echo "Rebuilding Web UI (no cache)..." @echo "Rebuilding Web UI (no cache)..."
docker-compose build --no-cache webui $(DC) build --no-cache webui
docker-compose up -d webui $(DC) up -d webui
# Testing commands # Testing commands
test: test: