#!/bin/bash
# Build script for PISCAL Docker image with automatic versioning

set -e

# Generate version tag: YYYYMMDD-gitsha
DATE_TAG=$(date +%Y%m%d)
GIT_SHA=$(git rev-parse --short HEAD)
VERSION="${DATE_TAG}-${GIT_SHA}"

echo "Building PISCAL Docker image..."
echo "Version: ${VERSION}"
echo ""

# Build with version tag and latest tag (using default ARGs for dev)
docker build \
  -t piscal:${VERSION} \
  -t piscal:latest \
  -t piscal:dev \
  .

echo ""
echo "Successfully built:"
echo "  - piscal:${VERSION}"
echo "  - piscal:latest"
echo "  - piscal:dev"
echo ""
echo "Default credentials:"
echo "  Username: piscaladmin"
echo "  Password: piscaladmin"
echo "  Storage:  /home/piscaladmin/LeafWeb_storage"
echo ""
echo "To run: docker run -d -p 2222:22 --name piscal-server piscal:latest"
echo "To SSH: ssh -p 2222 piscaladmin@localhost (password: piscaladmin)"
