feat: initial commit of mini-paas engine and documentation

This commit is contained in:
2026-10-23 13:57:39 -03:00
commit e0e2201230
17 changed files with 2263 additions and 0 deletions

67
internal/config/config.go Normal file
View File

@@ -0,0 +1,67 @@
package config
import (
"os"
"strconv"
"time"
)
type Config struct {
Port string
AppsDir string
PortRangeStart int
PortRangeEnd int
ScanInterval time.Duration
Domain string
}
func Load() *Config {
port := os.Getenv("PAAS_PORT")
if port == "" {
port = "8080"
}
appsDir := os.Getenv("PAAS_APPS_DIR")
if appsDir == "" {
// Se existir /apps (dentro do container), usa ele; senão usa ./apps local para testes
if _, err := os.Stat("/apps"); err == nil {
appsDir = "/apps"
} else {
appsDir = "./apps"
}
}
startPort := getEnvInt("PAAS_PORT_START", 8001)
endPort := getEnvInt("PAAS_PORT_END", 8999)
scanSeconds := getEnvInt("PAAS_SCAN_INTERVAL", 3)
if scanSeconds < 1 {
scanSeconds = 3
}
domain := os.Getenv("PAAS_DOMAIN")
if domain == "" {
domain = "paas.weltonmoura.com.br"
}
return &Config{
Port: port,
AppsDir: appsDir,
PortRangeStart: startPort,
PortRangeEnd: endPort,
ScanInterval: time.Duration(scanSeconds) * time.Second,
Domain: domain,
}
}
func getEnvInt(key string, defaultVal int) int {
v := os.Getenv(key)
if v == "" {
return defaultVal
}
n, err := strconv.Atoi(v)
if err != nil {
return defaultVal
}
return n
}