diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..6d3cf4c59 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.cache +.github +.vscode +.editorconfig +.markdownlint.yaml +Dockerfile diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a0e4528f1..21b404b9c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -33,6 +33,15 @@ jobs: key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | ${{ runner.os }}-pip- + - name: Install d2 + run: | + mkdir -p /tmp/d2 + D2_VERSION=$(curl -s https://api.github.com/repos/terrastruct/d2/releases/latest | awk '/tag_name/{print $4;exit}' FS='[""]') + curl -o \ + /tmp/d2.tar.gz -L \ + "https://github.com/terrastruct/d2/releases/download/${D2_VERSION}/d2-${D2_VERSION}-linux-amd64.tar.gz" + tar xzf /tmp/d2.tar.gz -C /tmp/d2 --strip-components=1 + cp /tmp/d2/bin/d2 /usr/local/bin - name: Install dependencies run: pip install -r docs/requirements.txt - name: Build documentation @@ -65,6 +74,15 @@ jobs: key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | ${{ runner.os }}-pip- + - name: Install d2 + run: | + mkdir -p /tmp/d2 + D2_VERSION=$(curl -s https://api.github.com/repos/terrastruct/d2/releases/latest | awk '/tag_name/{print $4;exit}' FS='[""]') + curl -o \ + /tmp/d2.tar.gz -L \ + "https://github.com/terrastruct/d2/releases/download/${D2_VERSION}/d2-${D2_VERSION}-linux-amd64.tar.gz" + tar xzf /tmp/d2.tar.gz -C /tmp/d2 --strip-components=1 + cp /tmp/d2/bin/d2 /usr/local/bin - name: Install dependencies run: pip install -r docs/requirements.txt - name: Deploy to GitHub Pages diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..0391359de --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +# syntax=docker/dockerfile:1 + +FROM ghcr.io/linuxserver/d2-builder:latest AS d2 + +FROM ghcr.io/linuxserver/baseimage-alpine:edge + +# set version label +ARG BUILD_DATE +ARG VERSION +ARG D2_VERSION +LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" +LABEL maintainer="roxedus" + +RUN \ + echo "**** install packages ****" && \ + apk add --no-cache \ + git \ + python3 && \ + mkdir -p /app/mkdocs/docs && \ + git config --global --add safe.directory /app/mkdocs && \ + python3 -m venv /lsiopy && \ + pip install -U --no-cache-dir \ + pip \ + wheel + +COPY --from=d2 /usr/local/bin/d2 /usr/local/bin + +COPY docs/requirements.txt /app/mkdocs/docs/requirements.txt + +RUN \ + pip install -U --no-cache-dir \ + -r /app/mkdocs/docs/requirements.txt + +COPY . /app/mkdocs/ + +WORKDIR /app/mkdocs + +ENTRYPOINT ["catatonit", "--", "mkdocs", "serve"] + +CMD [ "-a", "0.0.0.0:8000" ] diff --git a/docs/requirements.txt b/docs/requirements.txt index 9facdc907..c20944f66 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,4 +1,5 @@ mkdocs-awesome-pages-plugin==2.9.3 +mkdocs-d2-plugin==1.5.0 mkdocs-git-revision-date-localized-plugin==1.3.0 mkdocs-material==9.5.45 mkdocs-minify-plugin==0.8.0 diff --git a/local.md b/local.md new file mode 100644 index 000000000..a8d87a581 --- /dev/null +++ b/local.md @@ -0,0 +1,35 @@ +# Local development + +To speed up the build, you should consider commenting out the `git-revision-date-localized` and `minify` plugin in mkdocs.yml + +## Build image + +```shell +docker build -t lsio/documentation -f Dockerfile . +``` + +## Run image + +With docs from buildtime + +```shell +docker run --rm --name=docs -p 8000:8000 lsio/documentation +``` + +With docs from runtime + +```shell +docker run --rm --name=docs -p 8000:8000 -v $PWD:/app/mkdocs lsio/documentation +``` + +With watching at runtime + +```shell +docker run --rm --name=docs -p 8000:8000 -v $PWD:/app/mkdocs lsio/documentation -a 0.0.0.0:8000 --dirty +``` + +With custom port + +```shell +docker run --rm --name=docs -p 9999:9999 lsio/documentation -a 0.0.0.0:9999 +``` diff --git a/mkdocs.yml b/mkdocs.yml index cfb97bd14..94e1ae25c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -75,6 +75,11 @@ markdown_extensions: permalink: true plugins: - awesome-pages + - d2: + layout: elk + pad: 0 + theme: 3 + dark_theme: 200 - git-revision-date-localized: enable_creation_date: true - minify: