Rebuild docker image as part of setting up
This commit is contained in:
@@ -32,14 +32,56 @@ if exist .env (
|
||||
echo Created .env file
|
||||
echo.
|
||||
)
|
||||
|
||||
REM Check if Docker is installed and running
|
||||
where docker >nul 2>nul
|
||||
if %errorlevel% neq 0 (
|
||||
echo Warning: Docker is not installed. Please install Docker first.
|
||||
echo Visit: https://docs.docker.com/get-docker/
|
||||
) else (
|
||||
REM Check if Docker daemon is running
|
||||
docker info >nul 2>nul
|
||||
if %errorlevel% neq 0 (
|
||||
echo Warning: Docker daemon is not running. Please start Docker.
|
||||
) else (
|
||||
REM Clean up and build Docker image
|
||||
echo.
|
||||
echo Building Docker image...
|
||||
|
||||
REM Stop running containers
|
||||
echo - Checking for running containers...
|
||||
for /f "tokens=*" %%i in ('docker ps -q --filter ancestor^=gemini-mcp-server 2^>nul') do (
|
||||
docker stop %%i >nul 2>&1
|
||||
)
|
||||
|
||||
REM Remove containers
|
||||
echo - Removing old containers...
|
||||
for /f "tokens=*" %%i in ('docker ps -aq --filter ancestor^=gemini-mcp-server 2^>nul') do (
|
||||
docker rm %%i >nul 2>&1
|
||||
)
|
||||
|
||||
REM Remove existing image
|
||||
echo - Removing old image...
|
||||
docker rmi gemini-mcp-server:latest >nul 2>&1
|
||||
|
||||
REM Build fresh image
|
||||
echo - Building fresh image with --no-cache...
|
||||
docker build -t gemini-mcp-server:latest . --no-cache >nul 2>&1
|
||||
if %errorlevel% equ 0 (
|
||||
echo Docker image built successfully!
|
||||
) else (
|
||||
echo Failed to build Docker image. Run 'docker build -t gemini-mcp-server:latest .' manually to see errors.
|
||||
)
|
||||
echo.
|
||||
)
|
||||
)
|
||||
|
||||
echo Next steps:
|
||||
if "%API_KEY_VALUE%"=="your-gemini-api-key-here" (
|
||||
echo 1. Edit .env and replace 'your-gemini-api-key-here' with your actual Gemini API key
|
||||
echo 2. Run 'docker build -t gemini-mcp-server .' to build the Docker image
|
||||
echo 3. Copy this configuration to your Claude Desktop config:
|
||||
) else (
|
||||
echo 1. Run 'docker build -t gemini-mcp-server .' to build the Docker image
|
||||
echo 2. Copy this configuration to your Claude Desktop config:
|
||||
) else (
|
||||
echo 1. Copy this configuration to your Claude Desktop config:
|
||||
)
|
||||
echo.
|
||||
echo ===== COPY BELOW THIS LINE =====
|
||||
|
||||
@@ -32,14 +32,59 @@ GEMINI_API_KEY=$ApiKeyValue
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
# Check if Docker is installed and running
|
||||
if (!(Get-Command docker -ErrorAction SilentlyContinue)) {
|
||||
Write-Host "⚠️ Docker is not installed. Please install Docker first." -ForegroundColor Yellow
|
||||
Write-Host " Visit: https://docs.docker.com/get-docker/"
|
||||
} else {
|
||||
# Check if Docker daemon is running
|
||||
try {
|
||||
docker info 2>&1 | Out-Null
|
||||
|
||||
# Clean up and build Docker image
|
||||
Write-Host ""
|
||||
Write-Host "🐳 Building Docker image..." -ForegroundColor Blue
|
||||
|
||||
# Stop running containers
|
||||
$runningContainers = docker ps -q --filter ancestor=gemini-mcp-server 2>$null
|
||||
if ($runningContainers) {
|
||||
Write-Host " - Stopping running containers..."
|
||||
docker stop $runningContainers | Out-Null
|
||||
}
|
||||
|
||||
# Remove containers
|
||||
$allContainers = docker ps -aq --filter ancestor=gemini-mcp-server 2>$null
|
||||
if ($allContainers) {
|
||||
Write-Host " - Removing old containers..."
|
||||
docker rm $allContainers | Out-Null
|
||||
}
|
||||
|
||||
# Remove existing image
|
||||
if (docker images | Select-String "gemini-mcp-server") {
|
||||
Write-Host " - Removing old image..."
|
||||
docker rmi gemini-mcp-server:latest 2>&1 | Out-Null
|
||||
}
|
||||
|
||||
# Build fresh image
|
||||
Write-Host " - Building fresh image with --no-cache..."
|
||||
$result = docker build -t gemini-mcp-server:latest . --no-cache 2>&1
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "✅ Docker image built successfully!" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "❌ Failed to build Docker image. Run 'docker build -t gemini-mcp-server:latest .' manually to see errors." -ForegroundColor Red
|
||||
}
|
||||
Write-Host ""
|
||||
} catch {
|
||||
Write-Host "⚠️ Docker daemon is not running. Please start Docker." -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Next steps:"
|
||||
if ($ApiKeyValue -eq "your-gemini-api-key-here") {
|
||||
Write-Host "1. Edit .env and replace 'your-gemini-api-key-here' with your actual Gemini API key"
|
||||
Write-Host "2. Run 'docker build -t gemini-mcp-server .' to build the Docker image"
|
||||
Write-Host "3. Copy this configuration to your Claude Desktop config:"
|
||||
} else {
|
||||
Write-Host "1. Run 'docker build -t gemini-mcp-server .' to build the Docker image"
|
||||
Write-Host "2. Copy this configuration to your Claude Desktop config:"
|
||||
} else {
|
||||
Write-Host "1. Copy this configuration to your Claude Desktop config:"
|
||||
}
|
||||
Write-Host ""
|
||||
Write-Host "===== COPY BELOW THIS LINE =====" -ForegroundColor Cyan
|
||||
|
||||
@@ -32,14 +32,56 @@ EOF
|
||||
echo "✅ Created .env file"
|
||||
echo ""
|
||||
fi
|
||||
# Check if Docker is installed and running
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo "⚠️ Docker is not installed. Please install Docker first."
|
||||
echo " Visit: https://docs.docker.com/get-docker/"
|
||||
else
|
||||
# Check if Docker daemon is running
|
||||
if ! docker info &> /dev/null; then
|
||||
echo "⚠️ Docker daemon is not running. Please start Docker."
|
||||
else
|
||||
# Clean up and build Docker image
|
||||
echo ""
|
||||
echo "🐳 Building Docker image..."
|
||||
|
||||
# Stop running containers
|
||||
RUNNING_CONTAINERS=$(docker ps -q --filter ancestor=gemini-mcp-server 2>/dev/null)
|
||||
if [ ! -z "$RUNNING_CONTAINERS" ]; then
|
||||
echo " - Stopping running containers..."
|
||||
docker stop $RUNNING_CONTAINERS >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# Remove containers
|
||||
ALL_CONTAINERS=$(docker ps -aq --filter ancestor=gemini-mcp-server 2>/dev/null)
|
||||
if [ ! -z "$ALL_CONTAINERS" ]; then
|
||||
echo " - Removing old containers..."
|
||||
docker rm $ALL_CONTAINERS >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# Remove existing image
|
||||
if docker images | grep -q "gemini-mcp-server"; then
|
||||
echo " - Removing old image..."
|
||||
docker rmi gemini-mcp-server:latest >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# Build fresh image
|
||||
echo " - Building fresh image with --no-cache..."
|
||||
if docker build -t gemini-mcp-server:latest . --no-cache >/dev/null 2>&1; then
|
||||
echo "✅ Docker image built successfully!"
|
||||
else
|
||||
echo "❌ Failed to build Docker image. Run 'docker build -t gemini-mcp-server:latest .' manually to see errors."
|
||||
fi
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Next steps:"
|
||||
if [ "$API_KEY_VALUE" = "your-gemini-api-key-here" ]; then
|
||||
echo "1. Edit .env and replace 'your-gemini-api-key-here' with your actual Gemini API key"
|
||||
echo "2. Run 'docker build -t gemini-mcp-server .' to build the Docker image"
|
||||
echo "3. Copy this configuration to your Claude Desktop config:"
|
||||
else
|
||||
echo "1. Run 'docker build -t gemini-mcp-server .' to build the Docker image"
|
||||
echo "2. Copy this configuration to your Claude Desktop config:"
|
||||
else
|
||||
echo "1. Copy this configuration to your Claude Desktop config:"
|
||||
fi
|
||||
echo ""
|
||||
echo "===== COPY BELOW THIS LINE ====="
|
||||
|
||||
@@ -52,11 +52,22 @@ def find_git_repositories(start_path: str, max_depth: int = 5) -> list[str]:
|
||||
List of absolute paths to git repositories, sorted alphabetically
|
||||
"""
|
||||
repositories = []
|
||||
# Use strict=False to handle paths that might not exist (e.g., in Docker container)
|
||||
start_path = Path(start_path).resolve(strict=False)
|
||||
|
||||
try:
|
||||
# Create Path object - no need to resolve yet since the path might be
|
||||
# a translated Docker path that doesn't exist on the host
|
||||
start_path = Path(start_path)
|
||||
|
||||
# If the path doesn't exist, return empty list
|
||||
if not start_path.exists():
|
||||
# Basic validation - must be absolute
|
||||
if not start_path.is_absolute():
|
||||
return []
|
||||
|
||||
# Check if the path exists before trying to walk it
|
||||
if not start_path.exists():
|
||||
return []
|
||||
|
||||
except Exception as e:
|
||||
# If there's any issue with the path, return empty list
|
||||
return []
|
||||
|
||||
def _find_repos(current_path: Path, current_depth: int):
|
||||
@@ -108,6 +119,10 @@ def run_git_command(repo_path: str, command: list[str]) -> tuple[bool, str]:
|
||||
- success: True if command returned 0, False otherwise
|
||||
- output/error: stdout if successful, stderr or error message if failed
|
||||
"""
|
||||
# Verify the repository path exists before trying to use it
|
||||
if not Path(repo_path).exists():
|
||||
return False, f"Repository path does not exist: {repo_path}"
|
||||
|
||||
try:
|
||||
# Execute git command with safety measures
|
||||
result = subprocess.run(
|
||||
@@ -125,6 +140,9 @@ def run_git_command(repo_path: str, command: list[str]) -> tuple[bool, str]:
|
||||
|
||||
except subprocess.TimeoutExpired:
|
||||
return False, "Command timed out after 30 seconds"
|
||||
except FileNotFoundError as e:
|
||||
# This can happen if git is not installed or repo_path issues
|
||||
return False, f"Git command failed - path not found: {str(e)}"
|
||||
except Exception as e:
|
||||
return False, f"Git command failed: {str(e)}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user