.PHONY: help setup start stop clean test test-frontend logs shell-backend shell-frontend migrate rebuild traefik-dashboard traefik-logs service-discovery network-inspect health-check-all mobile-setup db-shell-app db-shell-platform db-shell-vehicles help: @echo "MotoVaultPro - Kubernetes-Ready Docker Compose Architecture" @echo "Commands:" @echo " make setup - Initial project setup (K8s-ready environment)" @echo " make start - Start all services (production mode)" @echo " make rebuild - Rebuild and restart containers (production)" @echo " make stop - Stop all services" @echo " make clean - Clean all data and volumes" @echo " make test - Run backend + frontend tests" @echo " make test-frontend - Run frontend tests in container" @echo " make logs - View logs from all services" @echo " make logs-backend - View backend logs only" @echo " make logs-frontend - View frontend logs only" @echo " make shell-backend - Open shell in backend container" @echo " make shell-frontend - Open shell in frontend container" @echo " make migrate - Run database migrations" @echo "" @echo "K8s-Ready Architecture Commands:" @echo " make traefik-dashboard - Access Traefik service discovery dashboard" @echo " make traefik-logs - View Traefik access and error logs" @echo " make service-discovery - Show discovered services and routes" @echo " make network-inspect - Inspect 4-tier network topology" @echo " make health-check-all - Check health of all services" @echo " make mobile-setup - Setup instructions for mobile testing" @echo "" @echo "Database Access (Container-Only):" @echo " make db-shell-app - Application database shell" @echo " make db-shell-platform - Platform database shell" @echo " make db-shell-vehicles - Vehicles database shell" setup: @echo "Setting up MotoVaultPro K8s-ready development environment..." @echo "1. Checking if .env file exists..." @if [ ! -f .env ]; then \ echo "WARNING: .env file not found. Using defaults for development."; \ echo "Create .env file for custom configuration."; \ fi @echo "2. Checking SSL certificates..." @if [ ! -f certs/motovaultpro.com.crt ]; then \ echo "Generating multi-domain SSL certificate..."; \ $(MAKE) generate-certs; \ fi @echo "3. Building and starting all containers with 4-tier network isolation..." @docker compose up -d --build --remove-orphans @echo "4. Running database migrations..." @sleep 15 # Wait for databases to be ready @docker compose exec admin-backend node dist/_system/migrations/run-all.js @echo "" @echo "K8s-ready setup complete!" @echo "Access application at: https://admin.motovaultpro.com" @echo "Access platform landing at: https://motovaultpro.com" @echo "Traefik dashboard at: http://localhost:8080" @echo "" @echo "Network Architecture:" @echo " - 4-tier isolation: frontend, backend, database, platform" @echo " - All traffic routed through Traefik (no direct service access)" @echo " - Development database access: ports 5432, 5433, 5434, 6379, 6380, 6381" @echo "" @echo "Mobile setup: make mobile-setup" @echo "Remember to add to /etc/hosts:" @echo "127.0.0.1 motovaultpro.com admin.motovaultpro.com" start: @echo "Starting application services..." @docker compose up -d --build --remove-orphans @echo "Application running!" stop: @docker compose down clean: @echo "Cleaning up all containers, volumes, and images..." @docker compose down -v --rmi all @docker system prune -f logs: @docker compose logs -f logs-backend: @docker compose logs -f admin-backend logs-frontend: @docker compose logs -f admin-frontend shell-backend: @docker compose exec admin-backend sh shell-frontend: @docker compose exec admin-frontend sh migrate: @echo "Running application database migrations..." @docker compose exec admin-backend node dist/_system/migrations/run-all.js @echo "Migrations completed." rebuild: @echo "Rebuilding containers with latest code changes..." @docker compose up -d --build --remove-orphans @echo "Containers rebuilt and restarted!" # Database Shell Access (K8s-equivalent: kubectl exec) db-shell-app: @echo "Opening application database shell..." @docker compose exec admin-postgres psql -U postgres -d motovaultpro db-shell-platform: @echo "Opening platform database shell..." @docker compose exec platform-postgres psql -U platform_user -d platform db-shell-vehicles: @echo "Opening vehicles database shell..." @docker compose exec mvp-platform-vehicles-db psql -U mvp_platform_user -d vehicles # K8s-Ready Architecture Commands traefik-dashboard: @echo "Traefik Service Discovery Dashboard:" @echo " Dashboard: http://localhost:8080" @echo " API: http://localhost:8080/api" @echo "" @echo "Available routes:" @curl -s http://localhost:8080/api/http/routers 2>/dev/null | jq -r '.[].name' | grep -v internal | sed 's/^/ - /' || echo " (Traefik not ready yet)" traefik-logs: @echo "Traefik access and error logs:" @docker compose logs -f traefik service-discovery: @echo "Service Discovery Status:" @echo "" @echo "Discovered Services:" @curl -s http://localhost:8080/api/http/services 2>/dev/null | jq -r '.[].name' | grep -v internal | sed 's/^/ - /' || echo " Traefik not ready yet" @echo "" @echo "Active Routes:" @curl -s http://localhost:8080/api/http/routers 2>/dev/null | jq -r '.[].name' | grep -v internal | sed 's/^/ -> /' || echo " No routes discovered yet" network-inspect: @echo "K8s-Ready Network Architecture:" @echo "" @echo "Created Networks:" @docker network ls --filter name=motovaultpro --format "table {{.Name}}\t{{.Driver}}\t{{.Scope}}" | grep -v default || echo "Networks not created yet" @echo "" @echo "Network Isolation Details:" @echo " - frontend - Public-facing (Traefik + frontend services)" @echo " - backend - API services (internal isolation)" @echo " - database - Data persistence (internal isolation)" @echo " - platform - Platform microservices (internal isolation)" health-check-all: @echo "Service Health Status:" @docker compose ps --format "table {{.Service}}\t{{.Status}}\t{{.Health}}" @echo "" @echo "Network Connectivity Test:" @echo " Traefik API: $$(curl -s -o /dev/null -w '%{http_code}' http://localhost:8080/api/http/services 2>/dev/null || echo 'FAIL')" @echo "" @echo "Service Discovery Status:" @echo " Discovered Services: $$(curl -s http://localhost:8080/api/http/services 2>/dev/null | jq '. | length' || echo '0')" @echo " Active Routes: $$(curl -s http://localhost:8080/api/http/routers 2>/dev/null | jq '. | length' || echo '0')" # SSL Certificate Generation generate-certs: @echo "Generating multi-domain SSL certificate for mobile compatibility..." @mkdir -p certs @openssl req -x509 -nodes -days 365 -newkey rsa:2048 \ -keyout certs/motovaultpro.com.key \ -out certs/motovaultpro.com.crt \ -config <(echo '[dn]'; echo 'CN=motovaultpro.com'; echo '[req]'; echo 'distinguished_name = dn'; echo '[SAN]'; echo 'subjectAltName=DNS:motovaultpro.com,DNS:admin.motovaultpro.com,DNS:*.motovaultpro.com,IP:127.0.0.1,IP:172.30.1.64') \ -extensions SAN @echo "Certificate generated with SAN for mobile compatibility (includes $(shell hostname -I | awk '{print $$1}'))" # Enhanced log commands with filtering logs-traefik: @docker compose logs -f traefik logs-platform: @docker compose logs -f mvp-platform-vehicles-api mvp-platform-tenants mvp-platform-landing logs-backend-full: @docker compose logs -f admin-backend admin-postgres admin-redis admin-minio logs-clear: @sudo sh -c "truncate -s 0 /var/lib/docker/containers/**/*-json.log"