From bdb84b7a8f5663c33e888af44a95cb12a0dd736e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 13 Jul 2021 19:09:16 +0200 Subject: [PATCH] root: build bundled docs into helo dir to fix path issue with packaged static files Signed-off-by: Jens Langhammer --- Dockerfile | 2 +- internal/web/web_static.go | 7 +++---- website/.gitignore | 2 +- website/package.json | 2 +- website/static.go | 4 ++-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index a6bd54b8c..03109320e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/internal/web/web_static.go b/internal/web/web_static.go index 11c0d0e9c..3fc03a3b8 100644 --- a/internal/web/web_static.go +++ b/internal/web/web_static.go @@ -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) diff --git a/website/.gitignore b/website/.gitignore index 67a2e8067..e1d31e6ac 100644 --- a/website/.gitignore +++ b/website/.gitignore @@ -3,7 +3,7 @@ # Production /build -/build_docs +/help # Generated files .docusaurus diff --git a/website/package.json b/website/package.json index 3c81db5d9..153383c08 100644 --- a/website/package.json +++ b/website/package.json @@ -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" diff --git a/website/static.go b/website/static.go index 2634b0f5a..1c44b1d66 100644 --- a/website/static.go +++ b/website/static.go @@ -2,5 +2,5 @@ package web import "embed" -//go:embed build_docs/* -var DocsDist embed.FS +//go:embed help/* +var Help embed.FS