Files
fn_registry/functions/infra/docker_build_image.md
T
egutierrez 1d45f232c6 feat: funciones infra — Docker, deploy, build y health check
Funciones impuras para gestión de contenedores: docker_build_image,
docker_compose_up/down, docker_volume_create/list/remove,
generate_dockerfile, write_dockerfile, go_build_binary, health_check_http,
deploy_app y stop_app. Todas con tests unitarios donde aplica.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 14:24:12 +02:00

1.3 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, tested, tests, test_file_path, file_path
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports tested tests test_file_path file_path
docker_build_image function go infra 1.0.0 impure func DockerBuildImage(contextDir, tag string, buildArgs map[string]string) (string, error) Construye una imagen Docker desde un directorio con Dockerfile. Soporta build args opcionales. Retorna el image ID de la imagen construida.
docker
image
build
infra
false error_go_core
fmt
os/exec
strings
true
build sin build args retorna image ID
build con build args incluye --build-arg
error si contextDir no existe
functions/infra/docker_build_image_test.go functions/infra/docker_build_image.go

Ejemplo

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.