QGIS的docker管理
This commit is contained in:
@@ -175,10 +175,15 @@ def _build_qgis_config(batch_folder: str) -> dict:
|
||||
is_docker = False
|
||||
|
||||
if is_docker:
|
||||
# GPKG 目录:容器内路径 = 项目挂载目录 + GPKG 子目录
|
||||
project_dir = get_docker_project_dir()
|
||||
gpkg_subdir = getattr(settings, "QGIS_GPKG_DIR", "app/data/gpkg")
|
||||
gpkg_dir = f"{project_dir}/{gpkg_subdir}"
|
||||
# GPKG 目录:优先使用容器内本地路径(预拷贝后绕过 WSL2 9P)
|
||||
# 需先执行 python script/copy_gpkg_to_container.py
|
||||
gpkg_dir = getattr(settings, "QGIS_DOCKER_GPKG_DIR", "") or ""
|
||||
if not gpkg_dir:
|
||||
# fallback: 使用挂载路径(性能差)
|
||||
project_dir = get_docker_project_dir()
|
||||
gpkg_subdir = getattr(settings, "QGIS_GPKG_DIR", "app/data/gpkg")
|
||||
gpkg_dir = f"{project_dir}/{gpkg_subdir}"
|
||||
logger.warning(f"GPKG 将从挂载目录读取(慢),建议执行 copy_gpkg_to_container.py")
|
||||
# batch_folder:主机路径 → 容器路径
|
||||
host_fs = get_host_file_store().rstrip("/")
|
||||
container_fs = get_container_file_store().rstrip("/")
|
||||
@@ -365,7 +370,7 @@ def _generate_batch_maps(models: list, config: dict, batch_key: str,
|
||||
import json, math, concurrent.futures, subprocess, tempfile, threading
|
||||
from app.services.qgis.qgis_env import (
|
||||
get_docker_project_dir, get_container_python_path, build_docker_exec_cmd,
|
||||
map_host_to_container, map_container_to_host,
|
||||
map_host_to_container, map_container_to_host, map_template_to_container,
|
||||
)
|
||||
|
||||
max_workers = getattr(settings, "QGIS_PARALLEL_WORKERS", 4)
|
||||
@@ -397,9 +402,9 @@ def _generate_batch_maps(models: list, config: dict, batch_key: str,
|
||||
cm = dict(m)
|
||||
if "outFile" in cm:
|
||||
cm["outFile"] = map_host_to_container(cm["outFile"])
|
||||
# 模板 path 也需要映射:Windows主机路径 → 容器内路径
|
||||
# 模板 path 映射到容器本地路径(预拷贝后绕过 9P)
|
||||
if "path" in cm:
|
||||
cm["path"] = map_host_to_container(cm["path"])
|
||||
cm["path"] = map_template_to_container(cm["path"])
|
||||
container_models.append(cm)
|
||||
|
||||
request = json.dumps({"config": config, "models": container_models}, ensure_ascii=False)
|
||||
|
||||
Reference in New Issue
Block a user