--- name: docker_build_image kind: function lang: go domain: infra version: "1.0.0" purity: impure signature: "func DockerBuildImage(contextDir, tag string, buildArgs map[string]string) (string, error)" description: "Construye una imagen Docker desde un directorio con Dockerfile. Soporta build args opcionales. Retorna el image ID de la imagen construida." tags: [docker, image, build, infra] uses_functions: [] uses_types: [] returns: [] returns_optional: false error_type: "error_go_core" imports: [fmt, os/exec, strings] params: - name: contextDir desc: "ruta del directorio que contiene el Dockerfile" - name: tag desc: "nombre y tag de la imagen a construir (ej: myapp:latest)" - name: buildArgs desc: "mapa de argumentos de construccion (--build-arg key=val)" output: "ID de la imagen Docker construida" tested: true tests: ["build sin build args retorna image ID", "build con build args incluye --build-arg", "error si contextDir no existe"] test_file_path: "functions/infra/docker_build_image_test.go" file_path: "functions/infra/docker_build_image.go" --- ## Ejemplo ```go imageID, err := DockerBuildImage("./myapp", "myapp:latest", map[string]string{ "VERSION": "1.2.3", "ENV": "production", }) if err != nil { log.Fatal(err) } fmt.Println("Built:", imageID) ``` ## Notas Ejecuta `docker build -t tag contextDir --build-arg key=val ...`. Parsea el image ID del output de docker build, compatible con el builder clasico (mensajes "Successfully built") y BuildKit (sha256). Si no puede parsear el ID del output, hace un `docker inspect` por tag como fallback.