| 85 | // --------------------------------------------------------------------------- |
| 86 | |
| 87 | function detectDocker(): boolean { |
| 88 | // Standard detection: /.dockerenv file or "docker" in /proc/1/cgroup |
| 89 | try { |
| 90 | if (existsSync("/.dockerenv")) return true; |
| 91 | if (platform() === "linux") { |
| 92 | const cgroup = readFileSync("/proc/1/cgroup", "utf-8"); |
| 93 | if (cgroup.includes("docker") || cgroup.includes("containerd")) return true; |
| 94 | } |
| 95 | } catch { |
| 96 | // Ignore — not in Docker |
| 97 | } |
| 98 | return false; |
| 99 | } |
| 100 | |
| 101 | // Named providers come first so getCIName() picks the most specific match. |
| 102 | // `truthy` accepts 'true' or '1'; `presence` matches any non-null value. |