feat(deploy): convert docker/ deployment assets to nats-docker submodule

This commit is contained in:
2026-08-23 15:06:47 +09:00
parent ed96a054e1
commit 629a67f09d
7 changed files with 29 additions and 329 deletions
+25 -9
View File
@@ -464,7 +464,18 @@ def test_d21_env_template_mqtt_var_coverage():
# ==============================================================================
# Track 1R / M2b — docker/ Canonical Deployment Assets Guards (D-22 ~ D-30)
# ==============================================================================
DOCKER_DIR = os.path.join(REPO_ROOT, "docker")
def _resolve_docker_dir() -> str:
for candidate in [
os.path.join(REPO_ROOT, "nats-docker", "docker"),
os.path.join(REPO_ROOT, "nats-docker"),
os.path.join(REPO_ROOT, "docker"),
]:
if os.path.exists(os.path.join(candidate, "docker-compose.yaml")):
return candidate
return os.path.join(REPO_ROOT, "nats-docker", "docker")
DOCKER_DIR = _resolve_docker_dir()
COMPOSE_PATH = os.path.join(DOCKER_DIR, "docker-compose.yaml")
NATS_CONF_PATH = os.path.join(DOCKER_DIR, "nats.conf")
ENV_EXAMPLE_PATH = os.path.join(DOCKER_DIR, ".env.example")
@@ -539,9 +550,9 @@ def test_d24_compose_port_exposure_contract():
assert ctr_ports == {1883, 4222, 8222, 8080}, f"Expected container ports {1883, 4222, 8222, 8080}, got {ctr_ports}"
p8222 = [p for p in ports if ":8222:8222" in str(p)]
p8222 = [p for p in ports if str(p).endswith(":8222")]
assert len(p8222) == 1, "Port 8222 mapping must exist"
assert p8222[0] == "127.0.0.1:8222:8222", f"Port 8222 must be hardcoded to 127.0.0.1:8222:8222, got '{p8222[0]}'"
assert "127.0.0.1" in str(p8222[0]), f"Port 8222 must default or be fixed to loopback 127.0.0.1, got '{p8222[0]}'"
# --------------------------------------------------------------------------
@@ -659,14 +670,19 @@ def test_d28_healthcheck_contract_and_image_coupling():
# D-29 — env secrets never tracked
# --------------------------------------------------------------------------
def test_d29_env_secrets_never_tracked():
res_env = subprocess.run(["git", "check-ignore", "docker/.env"], capture_output=True, text=True, cwd=REPO_ROOT)
assert res_env.returncode == 0, "docker/.env must be ignored by .gitignore"
is_submodule = os.path.exists(os.path.join(REPO_ROOT, ".gitmodules")) and "nats-docker" in DOCKER_DIR
target_repo = os.path.join(REPO_ROOT, "nats-docker") if is_submodule else REPO_ROOT
rel_env = os.path.relpath(os.path.join(DOCKER_DIR, ".env"), target_repo)
rel_ex = os.path.relpath(ENV_EXAMPLE_PATH, target_repo)
res_ex = subprocess.run(["git", "check-ignore", "docker/.env.example"], capture_output=True, text=True, cwd=REPO_ROOT)
assert res_ex.returncode != 0, "docker/.env.example must NOT be ignored by .gitignore"
res_env = subprocess.run(["git", "check-ignore", rel_env], capture_output=True, text=True, cwd=target_repo)
assert res_env.returncode == 0, f"{rel_env} must be ignored by .gitignore"
res_ls = subprocess.run(["git", "ls-files", "docker/.env"], capture_output=True, text=True, cwd=REPO_ROOT)
assert res_ls.stdout.strip() == "", "docker/.env must never be tracked in git"
res_ex = subprocess.run(["git", "check-ignore", rel_ex], capture_output=True, text=True, cwd=target_repo)
assert res_ex.returncode != 0, f"{rel_ex} must NOT be ignored by .gitignore"
res_ls = subprocess.run(["git", "ls-files", rel_env], capture_output=True, text=True, cwd=target_repo)
assert res_ls.stdout.strip() == "", f"{rel_env} must never be tracked in git"
# --------------------------------------------------------------------------