#!/bin/bash

# CHORUS Blog - Build and Push Docker Image
# Builds the Docker image and pushes to the private registry

set -e

REGISTRY="registry.home.deepblack.cloud"
IMAGE_NAME="tony/chorus-blog"
TAG=${1:-latest}
FULL_IMAGE="${REGISTRY}/${IMAGE_NAME}:${TAG}"

echo "🎵 Building CHORUS Blog Docker image..."
echo "📦 Image: ${FULL_IMAGE}"
echo ""

# Build the Docker image
echo "🔨 Building Docker image..."
docker build -t "${FULL_IMAGE}" .

echo "✅ Build complete!"
echo ""

# Push to registry
echo "📤 Pushing to registry..."
docker push "${FULL_IMAGE}"

echo "✅ Push complete!"
echo ""
echo "🚀 Image ready for deployment:"
echo "   ${FULL_IMAGE}"
echo ""
echo "To deploy to Docker Swarm:"
echo "   docker stack deploy -c ../../../docker/docker-compose.swarm.yml chorus"