Add D2 diagram support

pull/267/head
Roxedus 2024-11-25 19:11:01 +01:00
rodzic 92639f8b7d
commit bf6739308e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: EBC13557C4D91D7B
6 zmienionych plików z 105 dodań i 0 usunięć

6
.dockerignore 100644
Wyświetl plik

@ -0,0 +1,6 @@
.cache
.github
.vscode
.editorconfig
.markdownlint.yaml
Dockerfile

Wyświetl plik

@ -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

40
Dockerfile 100644
Wyświetl plik

@ -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" ]

Wyświetl plik

@ -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

35
local.md 100644
Wyświetl plik

@ -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
```

Wyświetl plik

@ -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: