#!/usr/bin/env bash
# Build the vibn-dev image on the Coolify host so every project's
# docker-compose can reference `vibn-dev:latest` with pull_policy: never.
#
# Run this ONCE per Coolify host before the first chat session uses
# Path B. Re-run whenever you bump the Dockerfile.
#
# Usage (from a workstation):
#   scp -r vibn-dev/ root@<coolify-host>:/tmp/
#   ssh root@<coolify-host> 'bash /tmp/vibn-dev/setup-on-coolify.sh'
#
# Or run via the Coolify SSH backbone (vibn-logs user has docker access):
#   ssh -i ~/.ssh/coolify_logs vibn-logs@<host> \
#     "cd /tmp/vibn-dev && docker build -t vibn-dev:latest ."

set -euo pipefail

cd "$(dirname "$0")"

echo "Building vibn-dev:latest on $(hostname)..."
docker build -t vibn-dev:latest .

echo
echo "Done. Image:"
docker images vibn-dev:latest --format 'table {{.Repository}}:{{.Tag}}\t{{.Size}}\t{{.CreatedSince}}'

echo
echo "Smoke test (should print 'ok'):"
docker run --rm vibn-dev:latest bash -c 'rg --version > /dev/null && git --version > /dev/null && echo ok'

echo
echo "vibn-dev is ready. New AI dev containers will reference this image"
echo "via 'image: vibn-dev:latest' + 'pull_policy: never' in their compose."
