diff --git a/.env.example b/.env.example index 75512638..70534603 100644 --- a/.env.example +++ b/.env.example @@ -4,6 +4,6 @@ BACKEND_PORT=62318 LSFX_MOCK_PORT=62320 # Spring Boot 运行配置 -SPRING_PROFILES_ACTIVE=local +SPRING_PROFILES_ACTIVE=nas RUOYI_PROFILE=/app/data/ruoyi JAVA_OPTS=-Xms512m -Xmx1024m diff --git a/deploy/deploy.ps1 b/deploy/deploy.ps1 index a17be30b..39177c6c 100644 --- a/deploy/deploy.ps1 +++ b/deploy/deploy.ps1 @@ -33,7 +33,18 @@ function Ensure-Command { function Reset-Directory { param([string]$Path) if (Test-Path $Path) { - [System.IO.Directory]::Delete($Path, $true) + Get-ChildItem -LiteralPath $Path -Recurse -Force -ErrorAction SilentlyContinue | ForEach-Object { + $_.Attributes = $_.Attributes ` + -band (-bnot [System.IO.FileAttributes]::ReadOnly) ` + -band (-bnot [System.IO.FileAttributes]::Hidden) ` + -band (-bnot [System.IO.FileAttributes]::System) + } + $rootItem = Get-Item -LiteralPath $Path -Force + $rootItem.Attributes = $rootItem.Attributes ` + -band (-bnot [System.IO.FileAttributes]::ReadOnly) ` + -band (-bnot [System.IO.FileAttributes]::Hidden) ` + -band (-bnot [System.IO.FileAttributes]::System) + Remove-Item -LiteralPath $Path -Recurse -Force } New-Item -ItemType Directory -Path $Path | Out-Null } diff --git a/docker-compose.yml b/docker-compose.yml index 4e3dfc44..35b2d36a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: container_name: ccdi-backend restart: unless-stopped environment: - SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-local} + SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-nas} RUOYI_PROFILE: ${RUOYI_PROFILE:-/app/data/ruoyi} JAVA_OPTS: ${JAVA_OPTS:--Xms512m -Xmx1024m} ports: diff --git a/lsfx-mock-server/docker-compose.yml b/lsfx-mock-server/docker-compose.yml index 5155c3b9..b0bdee11 100644 --- a/lsfx-mock-server/docker-compose.yml +++ b/lsfx-mock-server/docker-compose.yml @@ -5,7 +5,7 @@ services: build: . container_name: lsfx-mock-server ports: - - "8000:8000" + - "62320:8000" environment: - APP_NAME=流水分析Mock服务 - APP_VERSION=1.0.0 diff --git a/tests/deploy/test_deploy_to_nas.py b/tests/deploy/test_deploy_to_nas.py index 50f12f8a..8a3918ac 100644 --- a/tests/deploy/test_deploy_to_nas.py +++ b/tests/deploy/test_deploy_to_nas.py @@ -6,6 +6,8 @@ REPO_ROOT = Path(__file__).resolve().parents[2] DEPLOY_PS1 = REPO_ROOT / "deploy" / "deploy.ps1" DEPLOY_BAT = REPO_ROOT / "deploy" / "deploy-to-nas.bat" DOCKER_COMPOSE = REPO_ROOT / "docker-compose.yml" +ENV_EXAMPLE = REPO_ROOT / ".env.example" +LSFX_MOCK_COMPOSE = REPO_ROOT / "lsfx-mock-server" / "docker-compose.yml" def run_powershell(*args): @@ -79,3 +81,17 @@ def test_compose_exposes_lsfx_mock_port_via_backend_namespace(): assert '${LSFX_MOCK_PORT:-62320}:8000' in compose_text assert 'network_mode: "service:backend"' in compose_text + + +def test_compose_defaults_backend_profile_to_nas(): + compose_text = DOCKER_COMPOSE.read_text(encoding="utf-8") + env_text = ENV_EXAMPLE.read_text(encoding="utf-8") + + assert '${SPRING_PROFILES_ACTIVE:-nas}' in compose_text + assert 'SPRING_PROFILES_ACTIVE=nas' in env_text + + +def test_lsfx_mock_standalone_compose_exposes_62320(): + compose_text = LSFX_MOCK_COMPOSE.read_text(encoding="utf-8") + + assert '"62320:8000"' in compose_text