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")) }