#!/usr/bin/env bash
# Publie l’image sur Docker Hub (compte par défaut : foufure/gauffre).
# Prérequis : docker login (une fois)
# Usage :
#   ./scripts/docker-hub-push.sh           # tag latest
#   ./scripts/docker-hub-push.sh v1.0.0    # tag personnalisé
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"

DOCKER_USER="${DOCKER_USER:-foufure}"
IMAGE_NAME="${IMAGE_NAME:-gauffre}"
TAG="${1:-latest}"
FULL_IMAGE="${DOCKER_USER}/${IMAGE_NAME}:${TAG}"

echo "Build : ${FULL_IMAGE}"
docker build -t "${FULL_IMAGE}" .

echo "Push : ${FULL_IMAGE}"
docker push "${FULL_IMAGE}"

echo "Terminé : ${FULL_IMAGE}"
