MCPcopy Create free account
hub / github.com/FastLED/FastLED / _build_docker_image

Function _build_docker_image

ci/runners/docker_runner.py:106–163  ·  view source on GitHub ↗

Build the Docker image for unit tests. Args: project_root: Path to FastLED project root rebuild: If True, force rebuild even if image exists Returns: True if build succeeded, False otherwise

(project_root: Path, rebuild: bool = False)

Source from the content-addressed store, hash-verified

104
105
106def _build_docker_image(project_root: Path, rebuild: bool = False) -> bool:
107 """Build the Docker image for unit tests.
108
109 Args:
110 project_root: Path to FastLED project root
111 rebuild: If True, force rebuild even if image exists
112
113 Returns:
114 True if build succeeded, False otherwise
115 """
116 image_name = "fastled-unit-tests"
117 dockerfile_path = project_root / "docker" / "unit-tests" / "Dockerfile"
118
119 if not dockerfile_path.exists():
120 ts_print(f"Error: Dockerfile not found at {dockerfile_path}")
121 return False
122
123 # Check if image already exists (skip build if not rebuilding)
124 if not rebuild:
125 result = subprocess.run(
126 ["docker", "images", "-q", image_name],
127 capture_output=True,
128 text=True,
129 )
130 if result.stdout.strip():
131 ts_print(f"Using existing Docker image: {image_name}")
132 return True
133
134 ts_print(f"Building Docker image: {image_name}")
135 ts_print("This may take a few minutes on first run...")
136 ts_print("")
137
138 try:
139 result = subprocess.run(
140 [
141 "docker",
142 "build",
143 "--progress=plain", # Show full build output (not BuildKit compact mode)
144 "-f",
145 str(dockerfile_path),
146 "-t",
147 image_name,
148 str(project_root), # Build context is project root (for pyproject.toml)
149 ],
150 cwd=project_root,
151 timeout=600, # 10 minute timeout for build
152 )
153 if result.returncode != 0:
154 ts_print("Error: Docker build failed")
155 return False
156 ts_print("Docker image built successfully")
157 return True
158 except subprocess.TimeoutExpired:
159 ts_print("Error: Docker build timed out")
160 return False
161 except KeyboardInterrupt as ki:
162 handle_keyboard_interrupt(ki)
163 raise

Callers 1

run_docker_testsFunction · 0.85

Calls 3

ts_printFunction · 0.90
runMethod · 0.45

Tested by

no test coverage detected