fix: 兼容脚本管理未解压上传包
This commit is contained in:
@@ -14,6 +14,7 @@ DEFAULT_IMAGE = "interference-etl-runtime:1.1"
|
||||
DEFAULT_BASE_IMAGE = "python:3.13.11-slim"
|
||||
DEFAULT_OUTPUT = PROJECT_ROOT / "dist" / "InterferenceETL-offline-1.1.zip"
|
||||
PACKAGE_FILES = ("main.py", "requirements.txt", "README.md")
|
||||
PACKAGE_ENTRYPOINT = "from main import main\nraise SystemExit(main())\n"
|
||||
|
||||
COPY_DEPENDENCIES = r"""
|
||||
from importlib.metadata import distribution
|
||||
@@ -56,6 +57,7 @@ def build(output: Path, runtime_image: str, base_image: str) -> Path:
|
||||
)
|
||||
for name in PACKAGE_FILES:
|
||||
shutil.copy2(PROJECT_ROOT / name, staging / name)
|
||||
(staging / "__main__.py").write_text(PACKAGE_ENTRYPOINT, encoding="utf-8")
|
||||
subprocess.run(
|
||||
[
|
||||
"docker",
|
||||
@@ -74,6 +76,24 @@ def build(output: Path, runtime_image: str, base_image: str) -> Path:
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
subprocess.run(
|
||||
[
|
||||
"docker",
|
||||
"run",
|
||||
"--rm",
|
||||
"-e",
|
||||
"PYTHONDONTWRITEBYTECODE=1",
|
||||
"-v",
|
||||
f"{staging}:/workspace:ro",
|
||||
"-w",
|
||||
"/workspace",
|
||||
base_image,
|
||||
"python",
|
||||
"__main__.py",
|
||||
"--help",
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
if output.exists():
|
||||
output.unlink()
|
||||
with zipfile.ZipFile(output, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as archive:
|
||||
|
||||
Reference in New Issue
Block a user