32 lines
1.4 KiB
Python
32 lines
1.4 KiB
Python
"""Build a source deployment archive; private config files and SQL dumps are excluded."""
|
|
from pathlib import Path
|
|
import tarfile
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
DIRECTORIES = ["api", "dao", "model", "schema", "service", "frontend", "knowledge", "deploy"]
|
|
FILES = [
|
|
"Dockerfile", ".dockerignore", "requirements.txt", "compose.cloud.yaml",
|
|
"main.py", "database.py", "init_db.py", "seed_data.py", "云端部署说明.md",
|
|
"scripts/prepare_cloud_env.py", "scripts/restore_cloud_database.py", "scripts/verify_cloud_https.py",
|
|
"scripts/configure_cloud_ai.py",
|
|
]
|
|
|
|
|
|
def main():
|
|
output = ROOT / "artifacts" / "wolin-cloud-deployment.tar.gz"
|
|
output.parent.mkdir(parents=True, exist_ok=True)
|
|
if not (ROOT / "deploy/site/blackjack/index.html").is_file():
|
|
raise SystemExit("The preserved game build is missing; package it before deploying.")
|
|
paths = [ROOT / name for name in FILES]
|
|
for directory in DIRECTORIES:
|
|
paths.extend(path for path in (ROOT / directory).rglob("*") if path.is_file()
|
|
and "__pycache__" not in path.parts and path.suffix != ".pyc")
|
|
with tarfile.open(output, "w:gz") as archive:
|
|
for path in sorted(paths):
|
|
archive.add(path, arcname=path.relative_to(ROOT).as_posix(), recursive=False)
|
|
print("Deployment archive (private configuration files and SQL dumps excluded):", output)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|