Build Docker image from Dockerfile
(self)
| 221 | return False |
| 222 | |
| 223 | def build_image(self) -> bool: |
| 224 | """Build Docker image from Dockerfile""" |
| 225 | try: |
| 226 | dockerfile_path = Path(__file__).parent / "Dockerfile.avr8js" |
| 227 | |
| 228 | if not dockerfile_path.exists(): |
| 229 | print(f"❌ Dockerfile not found: {dockerfile_path}") |
| 230 | return False |
| 231 | |
| 232 | # Build context must be project root to match COPY paths in Dockerfile |
| 233 | project_root = dockerfile_path.parent.parent.parent |
| 234 | build_cmd = [ |
| 235 | "docker", |
| 236 | "build", |
| 237 | "-f", |
| 238 | str(dockerfile_path), |
| 239 | "-t", |
| 240 | self.docker_image, |
| 241 | str(project_root), |
| 242 | ] |
| 243 | |
| 244 | print(f"Building Docker image: {self.docker_image}") |
| 245 | print(f"Dockerfile: {dockerfile_path}") |
| 246 | print() |
| 247 | |
| 248 | result = subprocess.run(build_cmd) |
| 249 | return result.returncode == 0 |
| 250 | except KeyboardInterrupt as ki: |
| 251 | handle_keyboard_interrupt(ki) |
| 252 | raise |
| 253 | except Exception as e: |
| 254 | print(f"❌ Error building Docker image: {e}") |
| 255 | return False |
| 256 | |
| 257 | |
| 258 | def main() -> None: |
no test coverage detected