feat(controller): intial build functions setup in go and service building

This commit is contained in:
2025-09-05 09:14:34 -05:00
parent 8a07c8afe4
commit 87aafef350
13 changed files with 510 additions and 8 deletions

26
controller/builds.go Normal file
View File

@@ -0,0 +1,26 @@
package main
import (
"os"
"path/filepath"
)
// ensureBuildDir creates dir if missing
func ensureBuildDir(dir string) (string, error) {
if _, err := os.Stat(dir); os.IsNotExist(err) {
if err := os.MkdirAll(dir, 0755); err != nil {
return "", err
}
}
return filepath.Clean(dir), nil
}
func getBuildDir() (string, error) {
if os.Getenv("RUNNING_IN_DOCKER") == "true" {
// In Docker: workdir is usually /app/controller, so .. points to /app (repo root)
return ensureBuildDir(filepath.Join("..", "builds"))
}
// Local dev: still want builds in repo root relative to controller/
return ensureBuildDir(filepath.Join("..", "builds"))
}