#!/bin/sh set -eu cd "$(dirname "$0")/.." for service in api worker; do ids=$(docker compose ps -q "$service") [ -n "$ids" ] for id in $ids; do docker inspect "$id" | python3 -c ' import json, sys c = json.load(sys.stdin)[0] h = c["HostConfig"] assert c["Config"]["User"] == "node" assert h["ReadonlyRootfs"] and not h["Privileged"] and h["NetworkMode"] != "host" assert h["CapDrop"] == ["ALL"] and "no-new-privileges:true" in h["SecurityOpt"] assert h["Memory"] > 0 and h["NanoCpus"] > 0 and "/tmp" in h["Tmpfs"] assert not h["PortBindings"] assert all(m["Destination"] != "/var/run/docker.sock" for m in c["Mounts"]) print("PASS", c["Name"], "non-root, read-only, tmpfs, no capabilities, CPU/RAM limits, no published ports") ' done done