#!/bin/bash # Build and push Portainer MCP Docker images to GitLab container registry set -e # Configuration REGISTRY="git.oe74.net/adelorenzo/portainer-mcp" VERSION="${1:-latest}" # Colors for output GREEN='\033[0;32m' BLUE='\033[0;34m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' # No Color echo -e "${BLUE}Building and pushing Portainer MCP Docker images to GitLab registry${NC}" echo -e "${BLUE}Registry: ${REGISTRY}${NC}" echo -e "${BLUE}Version: ${VERSION}${NC}" echo "" # Check if logged in to registry echo -e "${YELLOW}Checking GitLab registry login...${NC}" if ! docker login git.oe74.net 2>/dev/null; then echo -e "${RED}Please login to GitLab registry first:${NC}" echo "docker login git.oe74.net" exit 1 fi # Function to build and push a single image build_and_push() { local service=$1 local image_name="${REGISTRY}/portainer-${service}" echo -e "${BLUE}Building portainer-${service}...${NC}" docker build -f docker/Dockerfile.${service} -t ${image_name}:${VERSION} . if [ "${VERSION}" != "latest" ]; then docker tag ${image_name}:${VERSION} ${image_name}:latest fi echo -e "${BLUE}Pushing portainer-${service} to registry...${NC}" docker push ${image_name}:${VERSION} if [ "${VERSION}" != "latest" ]; then docker push ${image_name}:latest fi echo -e "${GREEN}✓ portainer-${service} pushed successfully${NC}" echo "" } # Build and push all services services=("core" "environments" "docker" "kubernetes" "stacks" "edge" "gitops") for service in "${services[@]}"; do build_and_push "${service}" done echo -e "${GREEN}All images built and pushed successfully!${NC}" echo "" echo "Images available at:" for service in "${services[@]}"; do echo " ${REGISTRY}/portainer-${service}:${VERSION}" done echo "" echo "To use these images, update your docker-compose.yml:" echo " image: ${REGISTRY}/portainer-core:${VERSION}" echo " # instead of build: ..."