diff --git a/Makefile b/Makefile index c9624dc..2beffd2 100644 --- a/Makefile +++ b/Makefile @@ -75,9 +75,13 @@ setup-sandbox: fi; \ if command -v docker >/dev/null 2>&1; then \ echo "Pulling image using Docker..."; \ - docker pull "$$IMAGE"; \ - echo ""; \ - echo "✓ Sandbox image pulled successfully"; \ + if docker pull "$$IMAGE"; then \ + echo ""; \ + echo "✓ Sandbox image pulled successfully"; \ + else \ + echo ""; \ + echo "⚠ Failed to pull sandbox image (this is OK for local sandbox mode)"; \ + fi; \ else \ echo "✗ Neither Docker nor Apple Container is available"; \ echo " Please install Docker: https://docs.docker.com/get-docker/"; \ diff --git a/scripts/docker.sh b/scripts/docker.sh index 79fe5f3..bc20d41 100755 --- a/scripts/docker.sh +++ b/scripts/docker.sh @@ -70,6 +70,20 @@ cleanup() { # Set up trap for Ctrl+C trap cleanup INT TERM +docker_available() { + # Check that the docker CLI exists + if ! command -v docker >/dev/null 2>&1; then + return 1 + fi + + # Check that the Docker daemon is reachable + if ! docker info >/dev/null 2>&1; then + return 1 + fi + + return 0 +} + # Initialize: pre-pull the sandbox image so first Pod startup is fast init() { echo "==========================================" @@ -79,9 +93,50 @@ init() { SANDBOX_IMAGE="enterprise-public-cn-beijing.cr.volces.com/vefaas-public/all-in-one-sandbox:latest" + # Detect sandbox mode from config.yaml + local sandbox_mode + sandbox_mode="$(detect_sandbox_mode)" + + # Skip image pull for local sandbox mode (no container image needed) + if [ "$sandbox_mode" = "local" ]; then + echo -e "${GREEN}Detected local sandbox mode — no Docker image required.${NC}" + echo "" + + if docker_available; then + echo -e "${GREEN}✓ Docker environment is ready.${NC}" + echo "" + echo -e "${YELLOW}Next step: make docker-start${NC}" + else + echo -e "${YELLOW}Docker does not appear to be installed, or the Docker daemon is not reachable.${NC}" + echo "Local sandbox mode itself does not require Docker, but Docker-based workflows (e.g., docker-start) will fail until Docker is available." + echo "" + echo -e "${YELLOW}Install and start Docker, then run: make docker-init && make docker-start${NC}" + fi + + return 0 + fi + if ! docker images --format '{{.Repository}}:{{.Tag}}' | grep -q "^${SANDBOX_IMAGE}$"; then echo -e "${BLUE}Pulling sandbox image: $SANDBOX_IMAGE ...${NC}" - docker pull "$SANDBOX_IMAGE" + echo "" + + if ! docker pull "$SANDBOX_IMAGE" 2>&1; then + echo "" + echo -e "${YELLOW}⚠ Failed to pull sandbox image.${NC}" + echo "" + echo "This is expected if:" + echo " 1. You are using local sandbox mode (default — no image needed)" + echo " 2. You are behind a corporate proxy or firewall" + echo " 3. The registry requires authentication" + echo "" + echo -e "${GREEN}The Docker development environment can still be started.${NC}" + echo "If you need AIO sandbox (container-based execution):" + echo " - Ensure you have network access to the registry" + echo " - Or configure a custom sandbox image in config.yaml" + echo "" + echo -e "${YELLOW}Next step: make docker-start${NC}" + return 0 + fi else echo -e "${GREEN}Sandbox image already exists locally: $SANDBOX_IMAGE${NC}" fi