#!/bin/bash # Build script for Portainer MCP Docker containers set -e echo "Building Portainer MCP Docker containers..." # Colors for output GREEN='\033[0;32m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Check if .env file exists if [ ! -f .env ]; then echo "Creating .env file from template..." cat > .env << EOF # Required PORTAINER_URL=https://your-portainer-instance.com PORTAINER_API_KEY=your-api-key-here # Optional PORTAINER_INSECURE=false HTTP_TIMEOUT=30 MAX_RETRIES=3 EOF echo -e "${BLUE}Please edit .env file with your Portainer credentials${NC}" exit 1 fi # Build individual containers build_container() { local name=$1 echo -e "${BLUE}Building portainer-${name}...${NC}" docker build -f docker/Dockerfile.${name} -t portainer-mcp-${name}:latest . echo -e "${GREEN}✓ portainer-${name} built successfully${NC}" } # Build all containers if [ "$1" == "all" ] || [ -z "$1" ]; then for server in core environments docker kubernetes stacks edge gitops; do build_container $server done else # Build specific container build_container $1 fi echo -e "${GREEN}Build complete!${NC}" echo "" echo "To run all containers:" echo " docker-compose up -d" echo "" echo "To run a specific container:" echo " docker-compose up -d portainer-" echo "" echo "Available services: core, environments, docker, kubernetes, stacks, edge, gitops"