#!/bin/bash
# build-base-image.sh - Build base image with all dependencies cached
# Run this once when dependencies change (not on every build!)

set -e

REGISTRY="registry.nxtgauge.com"
DATE_TAG=$(date +%Y%m%d)

echo "🔨 Building base image with all dependencies..."

# Build base image with cargo-chef
docker build   -f Dockerfile.base   -t ${REGISTRY}/nxtgauge-rust-base:latest   -t ${REGISTRY}/nxtgauge-rust-base:${DATE_TAG}   .

echo "📤 Pushing base image..."
docker push ${REGISTRY}/nxtgauge-rust-base:latest
docker push ${REGISTRY}/nxtgauge-rust-base:${DATE_TAG}

echo "✅ Base image built and pushed!"
echo ""
echo "Now builds will use cached dependencies!"
echo "Build time: 15-20 min -> 30-60 seconds"
