Build builds a Docker image with the specified name and context. Additional build arguments can be provided (e.g., "--platform", "linux/amd64").
(imageName, context string, extraArgs ...string)
| 72 | // Build builds a Docker image with the specified name and context. |
| 73 | // Additional build arguments can be provided (e.g., "--platform", "linux/amd64"). |
| 74 | func (d *DockerExecutor) Build(imageName, context string, extraArgs ...string) error { |
| 75 | args := []string{"build", "-t", imageName} |
| 76 | args = append(args, extraArgs...) |
| 77 | args = append(args, context) |
| 78 | |
| 79 | if err := d.Run(args...); err != nil { |
| 80 | return fmt.Errorf("docker build failed: %w", err) |
| 81 | } |
| 82 | |
| 83 | fmt.Printf("✅ Successfully built Docker image: %s\n", imageName) |
| 84 | return nil |
| 85 | } |
| 86 | |
| 87 | // Push pushes a Docker image to a registry. |
| 88 | func (d *DockerExecutor) Push(imageName string) error { |
no test coverage detected