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/security.txt /work/web/security.txt
COPY --from=web-builder /static/dist/ /work/web/dist/ COPY --from=web-builder /static/dist/ /work/web/dist/
COPY --from=web-builder /static/authentik/ /work/web/authentik/ 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 ./cmd /work/cmd
COPY ./web/static.go /work/web/static.go 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") 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/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("/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/help"))))
statRouter.PathPrefix("/help").Handler(http.StripPrefix("/help", http.FileServer(http.Dir("./website/build_docs"))))
} else { } else {
statRouter.Use(ws.staticHeaderMiddleware) statRouter.Use(ws.staticHeaderMiddleware)
ws.log.Debug("Using packaged static files with aggressive caching") 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/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("/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.FileServer(http.FS(staticDocs.Help)))
statRouter.PathPrefix("/help").Handler(http.StripPrefix("/help", http.FileServer(http.FS(staticDocs.DocsDist))))
} }
statRouter.PathPrefix("/media").Handler(http.StripPrefix("/media", fs))
ws.lh.Path("/robots.txt").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { ws.lh.Path("/robots.txt").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
rw.Header()["Content-Type"] = []string{"text/plain"} rw.Header()["Content-Type"] = []string{"text/plain"}
rw.WriteHeader(200) rw.WriteHeader(200)

2
website/.gitignore vendored
View File

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

View File

@ -6,7 +6,7 @@
"docusaurus": "docusaurus", "docusaurus": "docusaurus",
"watch": "docusaurus start", "watch": "docusaurus start",
"build": "docusaurus build", "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", "swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy", "deploy": "docusaurus deploy",
"serve": "docusaurus serve" "serve": "docusaurus serve"

View File

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