root: add bundled docs

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-07-13 11:06:51 +02:00
parent 2036827f04
commit be5c8341d2
8 changed files with 184 additions and 9 deletions

View File

@ -3,3 +3,6 @@ static
htmlcov htmlcov
*.env.yml *.env.yml
**/node_modules **/node_modules
dist/**
build/**
build_docs/**

View File

@ -10,7 +10,15 @@ RUN pip install pipenv && \
pipenv lock -r > requirements.txt && \ pipenv lock -r > requirements.txt && \
pipenv lock -r --dev-only > requirements-dev.txt pipenv lock -r --dev-only > requirements-dev.txt
# Stage 2: Build web API # Stage 2: Build website
FROM node as website-builder
COPY ./website /static/
ENV NODE_ENV=production
RUN cd /static && npm i && npm run build-docs-only
# Stage 3: Build web API
FROM openapitools/openapi-generator-cli as api-builder FROM openapitools/openapi-generator-cli as api-builder
COPY ./schema.yml /local/schema.yml COPY ./schema.yml /local/schema.yml
@ -21,8 +29,8 @@ RUN docker-entrypoint.sh generate \
-o /local/web/api \ -o /local/web/api \
--additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=authentik-api,npmVersion=1.0.0 --additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=authentik-api,npmVersion=1.0.0
# Stage 3: Build webui # Stage 4: Build webui
FROM node as npm-builder FROM node as web-builder
COPY ./web /static/ COPY ./web /static/
COPY --from=api-builder /local/web/api /static/api COPY --from=api-builder /local/web/api /static/api
@ -30,15 +38,16 @@ COPY --from=api-builder /local/web/api /static/api
ENV NODE_ENV=production ENV NODE_ENV=production
RUN cd /static && npm i && npm run build RUN cd /static && npm i && npm run build
# Stage 4: Build go proxy # Stage 5: Build go proxy
FROM golang:1.16.5 AS builder FROM golang:1.16.5 AS builder
WORKDIR /work WORKDIR /work
COPY --from=npm-builder /static/robots.txt /work/web/robots.txt COPY --from=web-builder /static/robots.txt /work/web/robots.txt
COPY --from=npm-builder /static/security.txt /work/web/security.txt COPY --from=web-builder /static/security.txt /work/web/security.txt
COPY --from=npm-builder /static/dist/ /work/web/dist/ COPY --from=web-builder /static/dist/ /work/web/dist/
COPY --from=npm-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 ./cmd /work/cmd COPY ./cmd /work/cmd
COPY ./web/static.go /work/web/static.go COPY ./web/static.go /work/web/static.go
@ -48,7 +57,7 @@ COPY ./go.sum /work/go.sum
RUN go build -o /work/authentik ./cmd/server/main.go RUN go build -o /work/authentik ./cmd/server/main.go
# Stage 5: Run # Stage 6: Run
FROM python:3.9-slim-buster FROM python:3.9-slim-buster
WORKDIR / WORKDIR /

View File

@ -6,6 +6,7 @@ import (
"goauthentik.io/internal/config" "goauthentik.io/internal/config"
"goauthentik.io/internal/constants" "goauthentik.io/internal/constants"
staticWeb "goauthentik.io/web" staticWeb "goauthentik.io/web"
staticDocs "goauthentik.io/website"
) )
func (ws *WebServer) configureStatic() { func (ws *WebServer) configureStatic() {
@ -17,12 +18,14 @@ func (ws *WebServer) configureStatic() {
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("/media").Handler(http.StripPrefix("/media", fs))
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("/media").Handler(http.StripPrefix("/media", fs))
statRouter.PathPrefix("/help").Handler(http.StripPrefix("/help", http.FileServer(http.FS(staticDocs.DocsDist))))
} }
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"}

1
website/.gitignore vendored
View File

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

View File

@ -0,0 +1,86 @@
const mainConfig = require("./docusaurus.config");
module.exports = {
title: "authentik",
tagline: "Making authentication simple.",
url: "https://goauthentik.io",
baseUrl: "/help/",
onBrokenLinks: "throw",
favicon: "img/icon.png",
organizationName: "BeryJu",
projectName: "authentik",
themeConfig: {
navbar: {
title: "authentik",
logo: {
alt: "authentik logo",
src: "img/icon_left_brand.svg",
},
items: [
{
to: "docs/",
activeBasePath: "docs",
label: "Docs",
position: "left",
},
{
to: "developer-docs/",
activeBasePath: "developer-docs",
label: "Developer Docs",
position: "left",
},
{
href: "https://github.com/goauthentik/authentik",
label: "GitHub",
position: "right",
},
{
href: "https://discord.gg/jg33eMhnj6",
label: "Discord",
position: "right",
},
],
},
footer: mainConfig.themeConfig.footer,
colorMode: mainConfig.themeConfig.colorMode,
},
presets: [
[
"@docusaurus/preset-classic",
{
docs: {
id: "docs",
sidebarPath: require.resolve("./sidebars.js"),
editUrl: "https://github.com/goauthentik/authentik/edit/master/website/",
},
pages: false,
theme: {
customCss: require.resolve("./src/css/custom.css"),
},
},
],
],
plugins: [
[
'@docusaurus/plugin-content-docs',
{
id: 'docsDevelopers',
path: 'developer-docs',
routeBasePath: 'developer-docs',
sidebarPath: require.resolve('./sidebarsDev.js'),
editUrl: "https://github.com/goauthentik/authentik/edit/master/website/",
},
],
[
'@docusaurus/plugin-client-redirects',
{
redirects: [
{
to: '/docs/',
from: ['/'],
},
],
},
],
],
};

View File

@ -8,6 +8,7 @@
"name": "authentik-docs", "name": "authentik-docs",
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"@docusaurus/plugin-client-redirects": "*",
"@docusaurus/preset-classic": "2.0.0-beta.0", "@docusaurus/preset-classic": "2.0.0-beta.0",
"@mdx-js/react": "^1.6.22", "@mdx-js/react": "^1.6.22",
"clsx": "^1.1.1", "clsx": "^1.1.1",
@ -1781,6 +1782,42 @@
"react-dom": "^16.8.4 || ^17.0.0" "react-dom": "^16.8.4 || ^17.0.0"
} }
}, },
"node_modules/@docusaurus/plugin-client-redirects": {
"version": "2.0.0-beta.0",
"resolved": "https://registry.npmjs.org/@docusaurus/plugin-client-redirects/-/plugin-client-redirects-2.0.0-beta.0.tgz",
"integrity": "sha512-8USMnBo9YkcA/MFUBtTv2U+Me5uQih7cpAkgOhLkn9DwdgMoKNmcA+RGVLyKvczimYW4LpAZi+NoNqrJ7FkAkw==",
"dependencies": {
"@docusaurus/core": "2.0.0-beta.0",
"@docusaurus/types": "2.0.0-beta.0",
"@docusaurus/utils": "2.0.0-beta.0",
"@docusaurus/utils-validation": "2.0.0-beta.0",
"chalk": "^3.0.0",
"eta": "^1.11.0",
"fs-extra": "^9.1.0",
"globby": "^11.0.2",
"lodash": "^4.17.20",
"tslib": "^2.1.0"
},
"engines": {
"node": ">=10.9.0"
},
"peerDependencies": {
"react": "^16.8.4 || ^17.0.0",
"react-dom": "^16.8.4 || ^17.0.0"
}
},
"node_modules/@docusaurus/plugin-client-redirects/node_modules/chalk": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz",
"integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==",
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/@docusaurus/plugin-content-blog": { "node_modules/@docusaurus/plugin-content-blog": {
"version": "2.0.0-beta.0", "version": "2.0.0-beta.0",
"resolved": "https://registry.npmjs.org/@docusaurus/plugin-content-blog/-/plugin-content-blog-2.0.0-beta.0.tgz", "resolved": "https://registry.npmjs.org/@docusaurus/plugin-content-blog/-/plugin-content-blog-2.0.0-beta.0.tgz",
@ -16461,6 +16498,34 @@
"webpack": "^5.28.0" "webpack": "^5.28.0"
} }
}, },
"@docusaurus/plugin-client-redirects": {
"version": "2.0.0-beta.0",
"resolved": "https://registry.npmjs.org/@docusaurus/plugin-client-redirects/-/plugin-client-redirects-2.0.0-beta.0.tgz",
"integrity": "sha512-8USMnBo9YkcA/MFUBtTv2U+Me5uQih7cpAkgOhLkn9DwdgMoKNmcA+RGVLyKvczimYW4LpAZi+NoNqrJ7FkAkw==",
"requires": {
"@docusaurus/core": "2.0.0-beta.0",
"@docusaurus/types": "2.0.0-beta.0",
"@docusaurus/utils": "2.0.0-beta.0",
"@docusaurus/utils-validation": "2.0.0-beta.0",
"chalk": "^3.0.0",
"eta": "^1.11.0",
"fs-extra": "^9.1.0",
"globby": "^11.0.2",
"lodash": "^4.17.20",
"tslib": "^2.1.0"
},
"dependencies": {
"chalk": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz",
"integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==",
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
}
}
},
"@docusaurus/plugin-content-blog": { "@docusaurus/plugin-content-blog": {
"version": "2.0.0-beta.0", "version": "2.0.0-beta.0",
"resolved": "https://registry.npmjs.org/@docusaurus/plugin-content-blog/-/plugin-content-blog-2.0.0-beta.0.tgz", "resolved": "https://registry.npmjs.org/@docusaurus/plugin-content-blog/-/plugin-content-blog-2.0.0-beta.0.tgz",

View File

@ -6,11 +6,13 @@
"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",
"swizzle": "docusaurus swizzle", "swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy", "deploy": "docusaurus deploy",
"serve": "docusaurus serve" "serve": "docusaurus serve"
}, },
"dependencies": { "dependencies": {
"@docusaurus/plugin-client-redirects": "*",
"@docusaurus/preset-classic": "2.0.0-beta.0", "@docusaurus/preset-classic": "2.0.0-beta.0",
"@mdx-js/react": "^1.6.22", "@mdx-js/react": "^1.6.22",
"clsx": "^1.1.1", "clsx": "^1.1.1",

6
website/static.go Normal file
View File

@ -0,0 +1,6 @@
package web
import "embed"
//go:embed build_docs/*
var DocsDist embed.FS