feat: 用户入口改用自有账号,管理入口只从应用托管进入
This commit is contained in:
+11
-12
@@ -44,26 +44,25 @@ def version() -> str:
|
||||
return f"{base}-{commit}-dirty" if dirty else f"{base}-{commit}"
|
||||
|
||||
|
||||
def manifest(image: str) -> dict:
|
||||
def manifest(image: str, release: str) -> dict:
|
||||
return {
|
||||
"schema": 1,
|
||||
"schema": 2,
|
||||
"slug": SLUG,
|
||||
"name": NAME,
|
||||
"type": "container",
|
||||
"image": image,
|
||||
"image_file": "image.tar",
|
||||
"version": release,
|
||||
"user_auth": "app",
|
||||
"admin_auth": "metrix",
|
||||
"admin_path": "/admin",
|
||||
"services": [
|
||||
{"name": "web", "command": "", "port": WEB_PORT},
|
||||
{"name": "worker", "command": "python -m worker.main"},
|
||||
{"name": "web", "image": image, "image_file": "image.tar", "command": "", "port": WEB_PORT},
|
||||
{"name": "worker", "image": image, "image_file": "image.tar", "command": "python -m worker.main"},
|
||||
],
|
||||
"postgres": {"enabled": False, "image": "postgres:16"},
|
||||
"data_dir": DATA_DIR,
|
||||
"env": {
|
||||
"DECOM_DATA_DIR": DATA_DIR,
|
||||
"DECOM_INLINE_WORKER": "0",
|
||||
"DECOM_DB_WAIT_SECONDS": "180",
|
||||
},
|
||||
"access": "public",
|
||||
}
|
||||
|
||||
|
||||
@@ -86,14 +85,14 @@ def build_image(image: str, args: argparse.Namespace) -> None:
|
||||
_run(command)
|
||||
|
||||
|
||||
def write_bundle(image: str, target: Path) -> None:
|
||||
def write_bundle(image: str, release: str, target: Path) -> None:
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
partial = target.with_name(target.name + ".partial")
|
||||
with tempfile.TemporaryDirectory(prefix="decomeval-pack-", dir=target.parent) as work:
|
||||
tar = Path(work) / "image.tar"
|
||||
_run(["docker", "save", "-o", str(tar), image])
|
||||
with zipfile.ZipFile(partial, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=6) as bundle:
|
||||
bundle.writestr("metrix-app.json", json.dumps(manifest(image), ensure_ascii=False, indent=2) + "\n")
|
||||
bundle.writestr("metrix-app.json", json.dumps(manifest(image, release), ensure_ascii=False, indent=2) + "\n")
|
||||
bundle.write(tar, "image.tar")
|
||||
os.replace(partial, target)
|
||||
|
||||
@@ -116,7 +115,7 @@ def main() -> int:
|
||||
if not args.skip_build:
|
||||
build_image(image, args)
|
||||
target = Path(args.output).resolve() / f"{SLUG}-{current}.zip"
|
||||
write_bundle(image, target)
|
||||
write_bundle(image, current, target)
|
||||
size = target.stat().st_size
|
||||
print(f"应用包:{target}")
|
||||
print(f"大小:{size / 1024 / 1024:.1f} MB({size} 字节)")
|
||||
|
||||
Reference in New Issue
Block a user