root: build bundled docs into helo dir to fix path issue with packaged static files

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-07-13 19:09:16 +02:00
parent 84e9748340
commit bdb84b7a8f
5 changed files with 8 additions and 9 deletions

View File

@ -47,7 +47,7 @@ COPY --from=web-builder /static/robots.txt /work/web/robots.txt
COPY --from=web-builder /static/security.txt /work/web/security.txt
COPY --from=web-builder /static/dist/ /work/web/dist/
COPY --from=web-builder /static/authentik/ /work/web/authentik/
COPY --from=website-builder /static/build_docs/ /work/website/build_docs/
COPY --from=website-builder /static/help/ /work/website/help/
COPY ./cmd /work/cmd
COPY ./web/static.go /work/web/static.go

View File

@ -17,16 +17,15 @@ func (ws *WebServer) configureStatic() {
ws.log.Debug("Using local static files")
statRouter.PathPrefix("/static/dist").Handler(http.StripPrefix("/static/dist", http.FileServer(http.Dir("./web/dist"))))
statRouter.PathPrefix("/static/authentik").Handler(http.StripPrefix("/static/authentik", http.FileServer(http.Dir("./web/authentik"))))
statRouter.PathPrefix("/media").Handler(http.StripPrefix("/media", fs))
statRouter.PathPrefix("/help").Handler(http.StripPrefix("/help", http.FileServer(http.Dir("./website/build_docs"))))
statRouter.PathPrefix("/help").Handler(http.StripPrefix("/help", http.FileServer(http.Dir("./website/help"))))
} else {
statRouter.Use(ws.staticHeaderMiddleware)
ws.log.Debug("Using packaged static files with aggressive caching")
statRouter.PathPrefix("/static/dist").Handler(http.StripPrefix("/static", http.FileServer(http.FS(staticWeb.StaticDist))))
statRouter.PathPrefix("/static/authentik").Handler(http.StripPrefix("/static", http.FileServer(http.FS(staticWeb.StaticAuthentik))))
statRouter.PathPrefix("/media").Handler(http.StripPrefix("/media", fs))
statRouter.PathPrefix("/help").Handler(http.StripPrefix("/help", http.FileServer(http.FS(staticDocs.DocsDist))))
statRouter.PathPrefix("/help").Handler(http.FileServer(http.FS(staticDocs.Help)))
}
statRouter.PathPrefix("/media").Handler(http.StripPrefix("/media", fs))
ws.lh.Path("/robots.txt").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
rw.Header()["Content-Type"] = []string{"text/plain"}
rw.WriteHeader(200)

2
website/.gitignore vendored
View File

@ -3,7 +3,7 @@
# Production
/build
/build_docs
/help
# Generated files
.docusaurus

View File

@ -6,7 +6,7 @@
"docusaurus": "docusaurus",
"watch": "docusaurus start",
"build": "docusaurus build",
"build-docs-only": "docusaurus build --config docusaurus.docs-only.js --out-dir build_docs",
"build-docs-only": "docusaurus build --config docusaurus.docs-only.js --out-dir help",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"serve": "docusaurus serve"

View File

@ -2,5 +2,5 @@ package web
import "embed"
//go:embed build_docs/*
var DocsDist embed.FS
//go:embed help/*
var Help embed.FS