Files
metabuilder/deployment/cli/nexus_populate.py
T
git 03d07635a2 feat(deployment): add modular Python CLI, fix node-deps registry routing, bump to Node 24
- Dockerfile.node-deps: upgrade FROM node:22 to node:24
- Dockerfile.node-deps: rewrite main registry= line to Nexus when detected
  (was only rewriting scoped @esbuild-kit registry, leaving registry.npmjs.org
  unreachable inside Docker)
- Dockerfile.node-deps: fix sed ordering so cleanup of old auth lines runs
  before registry rewrite (prevents new registry= line from being deleted)
- Add deployment/cli/ modular Python CLI powered by JSON config, replacing
  12 shell scripts (build-base-images.sh, build-apps.sh, deploy.sh,
  start-stack.sh, release.sh, nexus-init.sh, nexus-ci-init.sh,
  push-to-nexus.sh, populate-nexus.sh, publish-npm-patches.sh,
  build-testcontainers.sh, artifactory-init.sh)
- Bump rocksdict 0.3.23 -> 0.3.29 (old version removed from PyPI)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 01:13:47 +00:00

69 lines
2.3 KiB
Python

"""Push all locally-built images to Nexus with :main + :latest tags."""
import argparse
from cli.helpers import (
BLUE, GREEN, NC,
docker_image_exists, log_err, log_info, log_ok, log_warn, run,
)
def run_cmd(args: argparse.Namespace, config: dict) -> int:
nexus = "localhost:5050"
slug = "johndoe6345789/metabuilder-small"
nexus_user, nexus_pass = "admin", "nexus"
log_info(f"Logging in to {nexus}...")
run(["docker", "login", nexus, "-u", nexus_user, "--password-stdin"],
input=nexus_pass.encode())
images_def = config["definitions"]["nexus_images"]
pushed = skipped = failed = 0
def push_image(src: str, name: str, size: str) -> None:
nonlocal pushed, skipped, failed
if not docker_image_exists(src):
log_warn(f"SKIP {name}{src} not found locally")
skipped += 1
return
dst_main = f"{nexus}/{slug}/{name}:main"
dst_latest = f"{nexus}/{slug}/{name}:latest"
log_info(f"Pushing {name} ({size})...")
run(["docker", "tag", src, dst_main])
run(["docker", "tag", src, dst_latest])
r1 = run(["docker", "push", dst_main])
r2 = run(["docker", "push", dst_latest])
if r1.returncode == 0 and r2.returncode == 0:
log_ok(f" {name} -> :main + :latest")
pushed += 1
else:
log_err(f" {name} FAILED")
failed += 1
print(f"\n{BLUE}Registry : {nexus}{NC}")
print(f"{BLUE}Slug : {slug}{NC}")
print(f"{BLUE}Skip heavy: {args.skip_heavy}{NC}\n")
for entry in images_def["base"] + images_def["apps"]:
push_image(entry["local"], entry["name"], entry["size"])
if args.skip_heavy:
log_warn("Skipping heavy images (--skip-heavy set):")
for entry in images_def["heavy"] + images_def["heavy_apps"]:
log_warn(f" {entry['name']} ({entry['size']})")
else:
log_info("--- Heavy images (this will take a while) ---")
for entry in images_def["heavy_apps"] + images_def["heavy"]:
push_image(entry["local"], entry["name"], entry["size"])
print(f"\n{GREEN}{'=' * 46}{NC}")
print(f"{GREEN} Done. pushed={pushed} skipped={skipped} failed={failed}{NC}")
print(f"{GREEN}{'=' * 46}{NC}")
return 1 if failed else 0
run = run_cmd