@echo off
cd /d "%~dp0"
setlocal enabledelayedexpansion

REM === 載入 .env 變數（忽略註解與空行） ===
for /f "usebackq tokens=1,* delims==" %%a in (".env") do (
    if "%%a" neq "" (
        if not "%%a"=="REM" (
            set "%%a=%%b"
        )
    )
)

REM === 檢查變數 ========================
echo -----------------------------------
echo Check: IMAGE_NAME=!IMAGE_NAME!
echo Check: TAG_VERSION=!TAG_VERSION!
echo -----------------------------------
echo.

REM === 流程 ============================

:: 0. 移除舊 Image
docker rmi !IMAGE_NAME!:!TAG_VERSION!

:: 1. 打包 映像檔 ( -f: 文件位置(注:是相對於目錄) -t: 標簽 ..: 上一層作爲根目錄(.: 表示當前當作根目錄))
docker build -f Dockerfile -t !IMAGE_NAME!:!TAG_VERSION! ../../
