feat(build): embed static assets into Go binary
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Embed frontend build output directly into Go binary using //go:embed. This removes runtime dependency on ../frontend/public/ path and simplifies Docker builds by serving assets from embedded filesystem. - Add backend/web/embed.go with embed.FS directive - Update server to serve from embedded static assets - Update Makefile to copy frontend build to web/static/ - Update Dockerfile for simplified multi-stage build - Update frontend package.json output paths - Remove custom 'oc' command from flake.nix dev shell
This commit is contained in:
@@ -2,6 +2,7 @@ package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"path"
|
||||
"time"
|
||||
@@ -9,6 +10,7 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"reichard.io/aethera/internal/api"
|
||||
"reichard.io/aethera/internal/store"
|
||||
"reichard.io/aethera/web"
|
||||
)
|
||||
|
||||
func StartServer(settingsStore store.Store, dataDir, listenAddress string, listenPort int) {
|
||||
@@ -17,12 +19,13 @@ func StartServer(settingsStore store.Store, dataDir, listenAddress string, liste
|
||||
// Create API Instance - use settingsStore as the unified store for both settings and chat
|
||||
logger := logrus.New()
|
||||
api := api.New(settingsStore, dataDir, logger)
|
||||
feFS := http.FileServer(http.Dir("../frontend/public/"))
|
||||
mux.Handle("GET /", feFS)
|
||||
|
||||
// Serve UI Pages
|
||||
pagesFS := http.FileServer(http.Dir("../frontend/public/pages/"))
|
||||
mux.Handle("GET /pages/", http.StripPrefix("/pages/", pagesFS))
|
||||
// Serve embedded static assets
|
||||
staticFS, err := fs.Sub(web.Assets, "static")
|
||||
if err != nil {
|
||||
logrus.Fatal("Failed to create static filesystem: ", err)
|
||||
}
|
||||
mux.Handle("GET /", http.FileServer(http.FS(staticFS)))
|
||||
|
||||
// Serve Generated Data
|
||||
genFS := http.FileServer(http.Dir(path.Join(dataDir, "generated")))
|
||||
|
||||
Reference in New Issue
Block a user