1d45f232c6
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>
1.6 KiB
1.6 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 | |||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| generate_dockerfile | function | go | infra | 1.0.0 | pure | func GenerateDockerfile(binaryName string, port int, envVars map[string]string) string | Genera el texto de un Dockerfile multi-stage para una app Go. Stage build con golang:1.23-alpine, stage final con alpine:latest. Incluye ENV vars del map con orden determinista. Funcion pura sin I/O. |
|
false |
|
true |
|
functions/infra/generate_dockerfile_test.go | functions/infra/generate_dockerfile.go |
Ejemplo
content := GenerateDockerfile("myapp", 8080, map[string]string{
"DB_HOST": "localhost",
"PORT": "8080",
})
fmt.Println(content)
// FROM golang:1.23-alpine AS builder
// ...
// EXPOSE 8080
// ENTRYPOINT ["./myapp"]
Notas
Funcion pura — no toca el sistema de archivos. Componer con WriteDockerfile para persistir el resultado. Las ENV vars se ordenan alfabeticamente para garantizar Dockerfiles deterministas (mismo input => mismo output exacto). El stage build usa CGO_ENABLED=0 para binarios estáticos compatibles con alpine. Si port <= 0, omite la instruccion EXPOSE.