✨ Run PocketBase as the wotra binary

The root package is now the entry point: one binary that serves the
PocketBase API, applies the migrations and ships the SvelteKit build
from web/build as a single-page app. The legacy chi entry point is
gone.

Note that the image is embedded unconditionally, so a Go build needs
at least the tracked web/build/.gitkeep and a web build has to run
first to get a working UI.
This commit is contained in:
2026-11-29 17:06:46 +00:00
parent 03c1a1f8d9
commit 58479668b6
2 changed files with 55 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
package main
import (
"embed"
"io/fs"
"mime"
"github.com/pocketbase/pocketbase/apis"
"github.com/pocketbase/pocketbase/core"
)
//go:embed all:web/build
var webBuild embed.FS
func registerUI(app core.App) {
_ = mime.AddExtensionType(".webmanifest", "application/manifest+json")
sub, err := fs.Sub(webBuild, "web/build")
if err != nil {
panic(err)
}
app.OnServe().BindFunc(func(se *core.ServeEvent) error {
if !se.Router.HasRoute("GET", "/{path...}") {
se.Router.GET("/{path...}", apis.Static(sub, true))
}
return se.Next()
})
}