feat(controller): intial build functions setup in go and service building
This commit is contained in:
26
controller/builds.go
Normal file
26
controller/builds.go
Normal 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"))
|
||||
}
|
||||
Reference in New Issue
Block a user