Files
fn_registry/functions/infra/deploy_app.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.4 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
deploy_app pipeline go infra 1.0.0 impure func DeployApp(appDir string, imageName string, port int, envVars map[string]string) (string, error) Orquesta el deploy completo de una app Go en Docker. Pasos: genera Dockerfile, lo escribe a disco, construye la imagen y lanza el contenedor en modo detach con port mapping. Retorna el container ID.
docker
deploy
go
pipeline
infra
container
generate_dockerfile_go_infra
write_dockerfile_go_infra
docker_build_image_go_infra
docker_run_container_go_infra
false error_go_core
fmt
false
functions/infra/deploy_app.go

Ejemplo

containerID, err := DeployApp(
    "/home/user/apps/myapp",
    "myapp",
    8080,
    map[string]string{
        "DB_HOST": "postgres",
        "PORT":    "8080",
    },
)
if err != nil {
    log.Fatal(err)
}
fmt.Println("Contenedor lanzado:", containerID)

Notas

Pipeline de 4 pasos: generate_dockerfile (pura) → write_dockerfile → docker_build_image → docker_run_container. El nombre del contenedor e imagen coinciden con imageName. El port mapping es simetrico (hostPort == containerPort). Si cualquier paso falla, el pipeline retorna error con contexto del paso fallido. No hace rollback automatico — para limpiar usar stop_app.