#!/bin/bash # Configuration REGISTRY="hub.technobeesolutions.in" USERNAME="technobee_admin" PASSWORD='M@tr!x#149@dm!N' BACKEND_IMAGE="${REGISTRY}/stock-scanner-backend:latest" FRONTEND_IMAGE="${REGISTRY}/stock-scanner-frontend:latest" PLATFORM="linux/amd64" echo "==========================================" echo " Stock Scanner - Docker Build & Push " echo "==========================================" # 1. Login to Docker Registry echo "[1/4] Logging into Docker Registry ($REGISTRY)..." # Using --password-stdin is the secure way to pass passwords to docker login echo "$PASSWORD" | docker login "$REGISTRY" -u "$USERNAME" --password-stdin if [ $? -ne 0 ]; then echo "❌ Docker login failed! Please check your credentials and ensure Docker is running." exit 1 fi echo "✅ Login successful." echo "" # 2. Build and push backend echo "[2/4] Building and pushing Backend Image for $PLATFORM..." docker buildx build --platform "$PLATFORM" -t "$BACKEND_IMAGE" -f backend/Dockerfile.backend ./backend --push if [ $? -ne 0 ]; then echo "❌ Backend build/push failed!" exit 1 fi echo "✅ Backend image built and pushed successfully." echo "" # 3. Build and push frontend echo "[3/4] Building and pushing Frontend Image for $PLATFORM..." docker buildx build --platform "$PLATFORM" -t "$FRONTEND_IMAGE" -f Dockerfile.frontend . --push if [ $? -ne 0 ]; then echo "❌ Frontend build/push failed!" exit 1 fi echo "✅ Frontend image built and pushed successfully." echo "" echo "==========================================" echo "🎉 Build and Push Complete!" echo "You can now run 'docker compose pull && docker compose up -d' on your target server." echo "=========================================="