#!/bin/bash
# Helper script to build and push base image locally

set -e

echo "=== Building Peikarband Base Image ==="
echo ""

# Variables
REGISTRY="hub.peikarband.ir"
IMAGE="$REGISTRY/peikarband/base"

# Build
echo "1. Building base image..."
docker build \
  -f docker/Dockerfile.base \
  -t "$IMAGE:latest" \
  -t "$IMAGE:python3.11-node20" \
  --build-arg PYTHON_VERSION=3.11 \
  --build-arg NODE_VERSION=20 \
  .

echo ""
echo "2. Testing base image..."
docker run --rm "$IMAGE:latest" bash -c "python --version && node --version && bun --version"

echo ""
echo "3. Login to Harbor registry..."
docker login "$REGISTRY"

echo ""
echo "4. Pushing base image..."
docker push "$IMAGE:latest"
docker push "$IMAGE:python3.11-node20"

echo ""
echo "=== ✅ Base Image Built and Pushed Successfully! ==="
echo ""
echo "Base image is now available at:"
echo "  - $IMAGE:latest"
echo "  - $IMAGE:python3.11-node20"
echo ""
echo "You can now run the application pipeline."
