#!/bin/bash

set -e

REGISTRY="registry.digitalocean.com/thob-blr1"
SHA=$(git rev-parse --short=10 HEAD)

echo "Building commit: $SHA"

# Login
doctl registry login

# App
echo "Building AR App..."
docker buildx build \
  --platform linux/amd64 \
  --build-arg VITE_POCKETBASE_URL=$VITE_POCKETBASE_URL \
  --build-arg VITE_FRONTEND_URL=$VITE_FRONTEND_URL \
  -f Dockerfile \
  --load \
  -t $REGISTRY/ar:$SHA \
  -t $REGISTRY/ar:latest .
docker push $REGISTRY/ar:$SHA
docker push $REGISTRY/ar:latest

echo "✅ All images built and pushed successfully"
