优化 Docker 镜像打包脚本并修复管理端赛事操作列布局

- 打包脚本默认 tag 改为 latest,支持 --service 单服务构建/导出
- 新增 api/player/admin 三个独立 bat,更新文档与 manifest
- 联赛赛事面板操作列加宽、横向滚动与按钮换行,避免操作按钮被裁切

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-15 16:35:49 +08:00
parent bb868e0ea5
commit be5b4a4921
8 changed files with 263 additions and 101 deletions

View File

@@ -4,6 +4,7 @@ setlocal EnableDelayedExpansion
REM Build api/player/admin images and export as tar (Windows CMD).
REM Usage:
REM docs\docker\build-and-export-images.bat
REM docs\docker\build-and-export-images.bat --service admin
REM docs\docker\build-and-export-images.bat --tag v1.2.3
REM docs\docker\build-and-export-images.bat --use-cache
REM docs\docker\build-and-export-images.bat --export-only
@@ -15,11 +16,13 @@ set "ENV_FILE=.env.docker"
set "OUTPUT="
set "NO_CACHE=1"
set "EXPORT_ONLY=0"
set "SERVICE=all"
if defined IMAGE_TAG (set "TAG=%IMAGE_TAG%") else (set "TAG=")
:parse_args
if "%~1"=="" goto args_done
if /i "%~1"=="--tag" goto parse_tag
if /i "%~1"=="--service" goto parse_service
if /i "%~1"=="--use-cache" set "NO_CACHE=0" & shift & goto parse_args
if /i "%~1"=="--export-only" set "EXPORT_ONLY=1" & shift & goto parse_args
if /i "%~1"=="--output" goto parse_output
@@ -39,6 +42,16 @@ shift
shift
goto parse_args
:parse_service
if "%~2"=="" (
echo ERROR: missing value for --service
exit /b 1
)
set "SERVICE=%~2"
shift
shift
goto parse_args
:parse_output
if "%~2"=="" (
echo ERROR: missing value for --output
@@ -53,12 +66,18 @@ goto parse_args
echo.
echo Usage: docs\docker\build-and-export-images.bat [options]
echo.
echo --tag TAG Image tag (default: git short commit)
echo --service SVC api ^| player ^| admin ^| all (default: all)
echo --tag TAG Image tag (default: latest)
echo --use-cache Use Docker build cache
echo --export-only Skip build, export existing images only
echo --output PATH Output tar path
echo -h, --help Show help
echo.
echo Examples:
echo docs\docker\build-and-export-images.bat --service admin
echo docs\docker\build-and-export-admin.bat
echo docs\docker\build-and-export-admin.bat --export-only
echo.
exit /b 0
:args_done
@@ -77,6 +96,9 @@ if not exist "%ENV_FILE%" (
)
)
call :validate_service
if errorlevel 1 exit /b 1
if not defined TAG call :default_tag
if not defined TAG (
echo ERROR: unable to determine image tag
@@ -86,7 +108,7 @@ if not defined TAG (
call :validate_tag
if errorlevel 1 exit /b 1
if not defined OUTPUT set "OUTPUT=thebet365-images-%TAG%.tar"
if not defined OUTPUT call :default_output
set "OUTPUT_PATH=%OUTPUT%"
echo %OUTPUT_PATH%| findstr /r "^[A-Za-z]:\\" >nul
@@ -102,14 +124,22 @@ if "%EXPORT_ONLY%"=="0" goto do_build
goto do_export
:do_build
echo ==^> Building api, player, admin (tag: %TAG%)
echo ==^> Building %SERVICE% (tag: %TAG%)
set "IMAGE_TAG=%TAG%"
if "%NO_CACHE%"=="1" goto build_no_cache
docker compose -f "%COMPOSE_FILE%" --env-file "%ENV_FILE%" build api player admin
if /i "%SERVICE%"=="all" (
docker compose -f "%COMPOSE_FILE%" --env-file "%ENV_FILE%" build api player admin
) else (
docker compose -f "%COMPOSE_FILE%" --env-file "%ENV_FILE%" build %SERVICE%
)
goto build_done
:build_no_cache
docker compose -f "%COMPOSE_FILE%" --env-file "%ENV_FILE%" build --no-cache api player admin
if /i "%SERVICE%"=="all" (
docker compose -f "%COMPOSE_FILE%" --env-file "%ENV_FILE%" build --no-cache api player admin
) else (
docker compose -f "%COMPOSE_FILE%" --env-file "%ENV_FILE%" build --no-cache %SERVICE%
)
:build_done
if errorlevel 1 (
@@ -118,8 +148,12 @@ if errorlevel 1 (
)
:do_export
echo ==^> Exporting images to %OUTPUT_PATH%
docker save thebet365-api:%TAG% thebet365-player:%TAG% thebet365-admin:%TAG% -o "%OUTPUT_PATH%"
echo ==^> Exporting %SERVICE% to %OUTPUT_PATH%
if /i "%SERVICE%"=="all" (
docker save thebet365-api:%TAG% thebet365-player:%TAG% thebet365-admin:%TAG% -o "%OUTPUT_PATH%"
) else (
docker save thebet365-%SERVICE%:%TAG% -o "%OUTPUT_PATH%"
)
if errorlevel 1 (
echo ERROR: docker save failed
exit /b 1
@@ -141,38 +175,61 @@ for %%F in ("%OUTPUT_PATH%") do set /a SIZE_MB=%%~zF/1048576
> "%MANIFEST_PATH%" (
echo tag=%TAG%
echo service=%SERVICE%
echo built_at=!BUILT_AT!
echo git_commit=!GIT_COMMIT!
echo git_dirty=!GIT_DIRTY!
echo tar=!TAR_NAME!
echo tar_sha256=!TAR_SHA256!
echo api_image=thebet365-api:%TAG%
echo api_image_id=!API_IMAGE_ID!
echo player_image=thebet365-player:%TAG%
echo player_image_id=!PLAYER_IMAGE_ID!
echo admin_image=thebet365-admin:%TAG%
echo admin_image_id=!ADMIN_IMAGE_ID!
if /i not "!SERVICE!"=="all" (
echo image=thebet365-!SERVICE!:%TAG%
echo image_id=!SVC_IMAGE_ID!
) else (
echo api_image=thebet365-api:%TAG%
echo api_image_id=!API_IMAGE_ID!
echo player_image=thebet365-player:%TAG%
echo player_image_id=!PLAYER_IMAGE_ID!
echo admin_image=thebet365-admin:%TAG%
echo admin_image_id=!ADMIN_IMAGE_ID!
)
)
echo Done: %OUTPUT_PATH% ^(!SIZE_MB! MB^)
echo Manifest: %MANIFEST_PATH%
echo.
echo Server first deploy:
echo ./scripts/deploy-first.sh --images !TAR_NAME! --tag %TAG%
echo.
echo Server update:
echo ./scripts/deploy-update.sh --images !TAR_NAME! --tag %TAG%
echo Server load and recreate:
if /i "%SERVICE%"=="all" (
echo docker load -i !TAR_NAME!
echo docker compose -f docker-compose.prod.yml --env-file .env.docker up -d --force-recreate api player admin
) else (
echo docker load -i !TAR_NAME!
echo docker compose -f docker-compose.prod.yml --env-file .env.docker up -d --force-recreate %SERVICE%
)
echo.
endlocal
exit /b 0
:default_tag
for /f "delims=" %%T in ('git rev-parse --short HEAD 2^>nul') do set "TAG=%%T"
if defined TAG exit /b 0
for /f "delims=" %%T in ('powershell -NoProfile -Command "Get-Date -Format yyyyMMdd-HHmmss"') do set "TAG=%%T"
set "TAG=latest"
exit /b 0
:default_output
if /i "%SERVICE%"=="all" (
set "OUTPUT=thebet365-images-%TAG%.tar"
) else (
set "OUTPUT=thebet365-%SERVICE%-%TAG%.tar"
)
exit /b 0
:validate_service
if /i "%SERVICE%"=="all" exit /b 0
if /i "%SERVICE%"=="api" exit /b 0
if /i "%SERVICE%"=="player" exit /b 0
if /i "%SERVICE%"=="admin" exit /b 0
echo ERROR: invalid --service: %SERVICE% (use api, player, admin, or all)
exit /b 1
:validate_tag
echo %TAG%| findstr /r "^[A-Za-z0-9_][A-Za-z0-9_.-]*$" >nul
if errorlevel 1 (
@@ -208,7 +265,11 @@ exit /b 0
set "API_IMAGE_ID="
set "PLAYER_IMAGE_ID="
set "ADMIN_IMAGE_ID="
set "SVC_IMAGE_ID="
for /f "delims=" %%I in ('docker image inspect thebet365-api:%TAG% --format "{{.Id}}" 2^>nul') do set "API_IMAGE_ID=%%I"
for /f "delims=" %%I in ('docker image inspect thebet365-player:%TAG% --format "{{.Id}}" 2^>nul') do set "PLAYER_IMAGE_ID=%%I"
for /f "delims=" %%I in ('docker image inspect thebet365-admin:%TAG% --format "{{.Id}}" 2^>nul') do set "ADMIN_IMAGE_ID=%%I"
if /i not "%SERVICE%"=="all" (
for /f "delims=" %%I in ('docker image inspect thebet365-%SERVICE%:%TAG% --format "{{.Id}}" 2^>nul') do set "SVC_IMAGE_ID=%%I"
)
exit /b 0