41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
"""Validate Compose on a named SSH host, in a fresh temporary directory.
|
|||
|
|
|
||
|
|
No Docker daemon access, project deployment or existing container mutation.
|
||
|
|
"""
|
||
|
|
|
||
|
|
import os
|
||
|
|
import shlex
|
||
|
|
import subprocess
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
root = Path(__file__).resolve().parents[1]
|
||
|
|
host = os.getenv("FRAME_FLOW_SSH_HOST", "nas-example")
|
||
|
|
args = ["ssh", "-o", "BatchMode=yes", "-o", "ConnectTimeout=8", host]
|
||
|
|
remote = subprocess.check_output(
|
||
|
|
args + ["mktemp -d /tmp/pigway-frame-flow-compose.XXXXXX"], text=True
|
||
|
|
).strip()
|
||
|
|
if not remote.startswith("/tmp/pigway-frame-flow-compose.") or any(
|
||
|
|
c in remote for c in " \n\r"
|
||
|
|
):
|
||
|
|
raise RuntimeError("Invalid temporary path")
|
||
|
|
subprocess.run(
|
||
|
|
[
|
||
|
|
"scp",
|
||
|
|
"-O",
|
||
|
|
str(root / "docker-compose.yml"),
|
||
|
|
host + ":" + remote + "/docker-compose.yml",
|
||
|
|
],
|
||
|
|
check=True,
|
||
|
|
)
|
||
|
|
subprocess.run(
|
||
|
|
["scp", "-O", str(root / ".env.example"), host + ":" + remote + "/.env"], check=True
|
||
|
|
)
|
||
|
|
subprocess.run(
|
||
|
|
args
|
||
|
|
+ [
|
||
|
|
"cd " + shlex.quote(remote) + " && /usr/local/bin/docker compose config --quiet"
|
||
|
|
],
|
||
|
|
check=True,
|
||
|
|
)
|
||
|
|
print("docker compose config: PASS (remote CLI only; not a Docker build)")
|