调整lsfx-mock默认数据库配置并更新NAS部署环境
This commit is contained in:
@@ -104,6 +104,9 @@ copy_path "${REPO_ROOT}/ruoyi-ui/dist" "${STAGE_ROOT}/frontend/dist"
|
||||
copy_path "${REPO_ROOT}/docker-compose.yml" "${STAGE_ROOT}/docker-compose.yml"
|
||||
copy_path "${REPO_ROOT}/.env.example" "${STAGE_ROOT}/.env.example"
|
||||
copy_path "${REPO_ROOT}/ruoyi-admin/target/ruoyi-admin.jar" "${STAGE_ROOT}/backend/ruoyi-admin.jar"
|
||||
python3 "${SCRIPT_DIR}/render_nas_env.py" \
|
||||
--template "${REPO_ROOT}/.env.example" \
|
||||
--output "${STAGE_ROOT}/.env"
|
||||
|
||||
echo "[5/5] 上传并远端部署"
|
||||
ensure_paramiko
|
||||
|
||||
@@ -95,6 +95,12 @@ Copy-ItemSafe (Join-Path $repoRoot "ruoyi-ui\\dist") (Join-Path $stageRoot "fron
|
||||
Copy-ItemSafe (Join-Path $repoRoot "docker-compose.yml") (Join-Path $stageRoot "docker-compose.yml")
|
||||
Copy-ItemSafe (Join-Path $repoRoot ".env.example") (Join-Path $stageRoot ".env.example")
|
||||
Copy-ItemSafe (Join-Path $repoRoot "ruoyi-admin\\target\\ruoyi-admin.jar") (Join-Path $stageRoot "backend\\ruoyi-admin.jar")
|
||||
python (Join-Path $scriptDir "render_nas_env.py") `
|
||||
--template (Join-Path $repoRoot ".env.example") `
|
||||
--output (Join-Path $stageRoot ".env")
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "生成 NAS 部署 .env 失败"
|
||||
}
|
||||
|
||||
Write-Host "[5/5] 上传并远端部署"
|
||||
$paramikoCheck = @'
|
||||
|
||||
47
deploy/render_nas_env.py
Normal file
47
deploy/render_nas_env.py
Normal file
@@ -0,0 +1,47 @@
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
NAS_ENV_OVERRIDES = {
|
||||
"CCDI_DB_HOST": "192.168.0.111",
|
||||
"CCDI_DB_PORT": "40628",
|
||||
}
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(description="Render NAS deployment .env for CCDI docker compose.")
|
||||
parser.add_argument("--template", required=True)
|
||||
parser.add_argument("--output", required=True)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def render_env_text(template_text: str) -> str:
|
||||
rendered_lines = []
|
||||
replaced_keys = set()
|
||||
|
||||
for line in template_text.splitlines():
|
||||
key, separator, value = line.partition("=")
|
||||
if separator and key in NAS_ENV_OVERRIDES:
|
||||
rendered_lines.append(f"{key}={NAS_ENV_OVERRIDES[key]}")
|
||||
replaced_keys.add(key)
|
||||
continue
|
||||
rendered_lines.append(line)
|
||||
|
||||
for key, value in NAS_ENV_OVERRIDES.items():
|
||||
if key not in replaced_keys:
|
||||
rendered_lines.append(f"{key}={value}")
|
||||
|
||||
return "\n".join(rendered_lines) + "\n"
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
template_path = Path(args.template)
|
||||
output_path = Path(args.output)
|
||||
|
||||
template_text = template_path.read_text(encoding="utf-8")
|
||||
output_path.write_text(render_env_text(template_text), encoding="utf-8")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user