littleshop/deploy-to-registry.sh
2025-11-20 16:22:54 +00:00

94 lines
2.6 KiB
Bash

#!/bin/bash
set -e
# Docker Registry Configuration
REGISTRY="10.8.0.1:5000"
TELESHOP_IMAGE="teleshop"
TELEBOT_IMAGE="telebot"
VERSION_TAG="clean-slate"
echo "=================================="
echo "TeleShop & TeleBot Docker Deployment"
echo "Registry: $REGISTRY"
echo "=================================="
echo ""
# Check if Docker is available
if ! command -v docker &> /dev/null; then
echo "❌ Error: Docker is not installed or not in PATH"
exit 1
fi
# Check if registry is accessible
echo "🔍 Testing registry connectivity..."
if curl -s "http://$REGISTRY/v2/_catalog" > /dev/null 2>&1; then
echo "✅ Registry is accessible at http://$REGISTRY"
else
echo "❌ Error: Cannot connect to registry at $REGISTRY"
echo "Please ensure the registry is running and accessible"
exit 1
fi
echo ""
echo "📦 Building TeleShop image..."
docker build -f Dockerfile -t $TELESHOP_IMAGE:latest . || {
echo "❌ Failed to build TeleShop image"
exit 1
}
echo "✅ TeleShop image built successfully"
echo ""
echo "📦 Building TeleBot image..."
docker build -f Dockerfile.telebot -t $TELEBOT_IMAGE:latest . || {
echo "❌ Failed to build TeleBot image"
exit 1
}
echo "✅ TeleBot image built successfully"
echo ""
echo "🏷️ Tagging images for registry..."
docker tag $TELESHOP_IMAGE:latest $REGISTRY/$TELESHOP_IMAGE:latest
docker tag $TELESHOP_IMAGE:latest $REGISTRY/$TELESHOP_IMAGE:$VERSION_TAG
docker tag $TELEBOT_IMAGE:latest $REGISTRY/$TELEBOT_IMAGE:latest
docker tag $TELEBOT_IMAGE:latest $REGISTRY/$TELEBOT_IMAGE:$VERSION_TAG
echo "✅ Images tagged successfully"
echo ""
echo "🚀 Pushing TeleShop to registry..."
docker push $REGISTRY/$TELESHOP_IMAGE:latest || {
echo "❌ Failed to push TeleShop:latest"
exit 1
}
docker push $REGISTRY/$TELESHOP_IMAGE:$VERSION_TAG || {
echo "❌ Failed to push TeleShop:$VERSION_TAG"
exit 1
}
echo "✅ TeleShop pushed successfully"
echo ""
echo "🚀 Pushing TeleBot to registry..."
docker push $REGISTRY/$TELEBOT_IMAGE:latest || {
echo "❌ Failed to push TeleBot:latest"
exit 1
}
docker push $REGISTRY/$TELEBOT_IMAGE:$VERSION_TAG || {
echo "❌ Failed to push TeleBot:$VERSION_TAG"
exit 1
}
echo "✅ TeleBot pushed successfully"
echo ""
echo "=================================="
echo "✅ Deployment Complete!"
echo "=================================="
echo ""
echo "Images pushed to registry:"
echo " - $REGISTRY/$TELESHOP_IMAGE:latest"
echo " - $REGISTRY/$TELESHOP_IMAGE:$VERSION_TAG"
echo " - $REGISTRY/$TELEBOT_IMAGE:latest"
echo " - $REGISTRY/$TELEBOT_IMAGE:$VERSION_TAG"
echo ""
echo "Verify with:"
echo " curl http://$REGISTRY/v2/_catalog"
echo ""