Make the SPA embeds optional at build time
probod cannot be built without apps/console/dist and apps/compliance-portal/dist existing, even when the frontends are not being used. This proposes a build tag to make the embeds optional. Default behaviour would be unchanged.
Why it currently can't
Both apps/console/console.go and apps/compliance-portal/complianceportal.go are thin shims around a //go:embed dist directive. Since go:embed resolves at compile time, dist/ must exist for those packages to build, and pkg/server/server.go imports the console package, so the whole server package graph fails to type-check without it. gqlgen type-checks that graph too, which is why codegen depends on it as well.
The Makefile works around this by writing a placeholder:
apps/console/dist/index.html apps/compliance-portal/dist/index.html:
$(MKDIR) $(dir $@)
$(ECHO) dev-server > $@
At runtime, pkg/server/statichandler/statichandler.go:119-121 then requires /index.html in the embedded FS:
indexETag, ok := etags["/index.html"]
if !ok {
return nil, errors.New("index.html not found")
}
That reaches console_web.NewServer() at pkg/server/server.go:136, which is called unconditionally, so the server will not start with an empty dist/.
Net effect for an API-only deployment: the binary embeds a 12-byte file, serves the literal string dev-server at /, and the build still needs the apps/ tree present.
@topriko could you please give a bit more context on the reason you need a release without frontend embedded?
Only the API neither SPA is used.
On why it might be worth doing in Probo regardless of who's asking: the placeholder rule is already a workaround for this seam.
apps/console/dist/index.html apps/compliance-portal/dist/index.html:
$(MKDIR) $(dir $@)
$(ECHO) dev-server > $@
Writing a 12-byte file so a go:embed resolves is a workaround for coupling that doesn't look intentional, and WITH_APPS already establishes the frontend build as opt-in. A build tag would make the seam explicit rather than implicit: the SPA-serving path (~500 lines across five files, three call sites) is currently load-bearing in pkg/server for every build, including ones that never serve it.
Concretely for the project:
make generate && make buildbecomes Go-only: no Node in the toolchain for backend-only CI runspkg/servergets a real boundary around presentation, rather than a compile-time dependency mediated by a stub file- Opens the option of an API-only image in the Helm chart, if that's ever useful
I'll close the issue for now as we are not working on this kind of build right and prefer a delivering a single binary as long as we can.