diff options
| author | zwlucas <lucas.fariamo08@gmail.com> | 2026-05-29 21:24:59 +0000 |
|---|---|---|
| committer | zwlucas <lucas.fariamo08@gmail.com> | 2026-05-29 21:24:59 +0000 |
| commit | bf8b1d0d49703e82cf8162399405984bd0b3fe88 (patch) | |
| tree | af4ed5fb7feae49cb3ebe1c8c3f87831e53b8273 /backend/internal/static/static.go | |
| parent | 17b159c563278c3b3b8b3884be37f8d5025ce0c7 (diff) | |
| download | yaum-bf8b1d0d49703e82cf8162399405984bd0b3fe88.tar.gz yaum-bf8b1d0d49703e82cf8162399405984bd0b3fe88.zip | |
feat: implement static file serving and Docker support, update frontend build process
Signed-off-by: zwlucas <lucas.fariamo08@gmail.com>
Diffstat (limited to 'backend/internal/static/static.go')
| -rw-r--r-- | backend/internal/static/static.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/backend/internal/static/static.go b/backend/internal/static/static.go new file mode 100644 index 0000000..53523a3 --- /dev/null +++ b/backend/internal/static/static.go @@ -0,0 +1,43 @@ +package static + +import ( + "embed" + "io/fs" + "log" + "os" + "path/filepath" +) + +//go:embed build +var embeddedBuild embed.FS + +func BuildFS() fs.FS { + sub, err := fs.Sub(embeddedBuild, "build") + if err != nil { + log.Printf("[static] embed nao disponivel, tentando filesystem: %v", err) + // Fallback: look for build directory relative to the backend binary + dir := os.Getenv("YAUM_STATIC_DIR") + if dir == "" { + // Try common locations + candidates := []string{ + "../frontend/build", + "frontend/build", + "./build", + } + for _, c := range candidates { + if info, e := os.Stat(c); e == nil && info.IsDir() { + dir = c + break + } + } + } + if dir != "" { + abs, _ := filepath.Abs(dir) + log.Printf("[static] servindo de %s", abs) + return os.DirFS(dir) + } + return nil + } + log.Println("[static] servindo de embed") + return sub +} |