Class: Aidp::Utils::DevcontainerDetector
- Inherits:
-
Object
- Object
- Aidp::Utils::DevcontainerDetector
- Defined in:
- lib/aidp/utils/devcontainer_detector.rb
Overview
Detects if AIDP is running inside a devcontainer
Uses multiple heuristics to determine container environment:
-
Environment variables (REMOTE_CONTAINERS, CODESPACES)
-
Filesystem markers (/.dockerenv, /run/.containerenv)
-
Hostname patterns
-
cgroup information
Class Method Summary collapse
-
.container_info ⇒ Hash
Get detailed container information.
-
.container_type ⇒ Symbol
Get container type (docker, podman, codespaces, vscode, unknown).
-
.in_codespaces? ⇒ Boolean
Check if running in GitHub Codespaces.
-
.in_container? ⇒ Boolean
Check if running inside any container (Docker, Podman, etc.).
-
.in_devcontainer? ⇒ Boolean
Check if running inside a devcontainer.
-
.in_vscode_remote? ⇒ Boolean
Check if running in VS Code Remote Containers.
-
.reset! ⇒ Object
Reset cached detection (useful for testing).
Class Method Details
.container_info ⇒ Hash
Get detailed container information
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/aidp/utils/devcontainer_detector.rb', line 62 def container_info { in_devcontainer: in_devcontainer?, in_container: in_container?, container_type: container_type, hostname: hostname, docker_env: File.exist?("/.dockerenv"), container_env: File.exist?("/run/.containerenv"), cgroup_docker: cgroup_contains?("docker"), cgroup_containerd: cgroup_contains?("containerd"), remote_containers_env: ENV["REMOTE_CONTAINERS"], codespaces_env: ENV["CODESPACES"] } end |
.container_type ⇒ Symbol
Get container type (docker, podman, codespaces, vscode, unknown)
50 51 52 53 54 55 56 57 |
# File 'lib/aidp/utils/devcontainer_detector.rb', line 50 def container_type return :codespaces if in_codespaces? return :vscode if in_vscode_remote? return :docker if docker_container? return :podman if podman_container? return :unknown if in_container? :none end |
.in_codespaces? ⇒ Boolean
Check if running in GitHub Codespaces
36 37 38 |
# File 'lib/aidp/utils/devcontainer_detector.rb', line 36 def in_codespaces? ENV["CODESPACES"] == "true" end |
.in_container? ⇒ Boolean
Check if running inside any container (Docker, Podman, etc.)
29 30 31 |
# File 'lib/aidp/utils/devcontainer_detector.rb', line 29 def in_container? @in_container ||= detect_container end |
.in_devcontainer? ⇒ Boolean
Check if running inside a devcontainer
22 23 24 |
# File 'lib/aidp/utils/devcontainer_detector.rb', line 22 def in_devcontainer? @in_devcontainer ||= detect_devcontainer end |
.in_vscode_remote? ⇒ Boolean
Check if running in VS Code Remote Containers
43 44 45 |
# File 'lib/aidp/utils/devcontainer_detector.rb', line 43 def in_vscode_remote? ENV["REMOTE_CONTAINERS"] == "true" || ENV["VSCODE_REMOTE_CONTAINERS"] == "true" end |
.reset! ⇒ Object
Reset cached detection (useful for testing)
78 79 80 81 |
# File 'lib/aidp/utils/devcontainer_detector.rb', line 78 def reset! @in_devcontainer = nil @in_container = nil end |