Skip to content

Commit 12e8bbe

Browse files
authored
Merge pull request #267 from linuxserver/d2
2 parents bac2f65 + 289753d commit 12e8bbe

6 files changed

Lines changed: 105 additions & 0 deletions

File tree

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.cache
2+
.github
3+
.vscode
4+
.editorconfig
5+
.markdownlint.yaml
6+
Dockerfile

.github/workflows/deploy.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ jobs:
3333
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
3434
restore-keys: |
3535
${{ runner.os }}-pip-
36+
- name: Install d2
37+
run: |
38+
mkdir -p /tmp/d2
39+
D2_VERSION=$(curl -s https://api.github.com/repos/terrastruct/d2/releases/latest | awk '/tag_name/{print $4;exit}' FS='[""]')
40+
curl -o \
41+
/tmp/d2.tar.gz -L \
42+
"https://github.com/terrastruct/d2/releases/download/${D2_VERSION}/d2-${D2_VERSION}-linux-amd64.tar.gz"
43+
tar xzf /tmp/d2.tar.gz -C /tmp/d2 --strip-components=1
44+
cp /tmp/d2/bin/d2 /usr/local/bin
3645
- name: Install dependencies
3746
run: pip install -r docs/requirements.txt
3847
- name: Build documentation
@@ -65,6 +74,15 @@ jobs:
6574
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
6675
restore-keys: |
6776
${{ runner.os }}-pip-
77+
- name: Install d2
78+
run: |
79+
mkdir -p /tmp/d2
80+
D2_VERSION=$(curl -s https://api.github.com/repos/terrastruct/d2/releases/latest | awk '/tag_name/{print $4;exit}' FS='[""]')
81+
curl -o \
82+
/tmp/d2.tar.gz -L \
83+
"https://github.com/terrastruct/d2/releases/download/${D2_VERSION}/d2-${D2_VERSION}-linux-amd64.tar.gz"
84+
tar xzf /tmp/d2.tar.gz -C /tmp/d2 --strip-components=1
85+
cp /tmp/d2/bin/d2 /usr/local/bin
6886
- name: Install dependencies
6987
run: pip install -r docs/requirements.txt
7088
- name: Deploy to GitHub Pages

Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM ghcr.io/linuxserver/d2-builder:latest AS d2
4+
5+
FROM ghcr.io/linuxserver/baseimage-alpine:edge
6+
7+
# set version label
8+
ARG BUILD_DATE
9+
ARG VERSION
10+
ARG D2_VERSION
11+
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
12+
LABEL maintainer="roxedus"
13+
14+
RUN \
15+
echo "**** install packages ****" && \
16+
apk add --no-cache \
17+
git \
18+
python3 && \
19+
mkdir -p /app/mkdocs/docs && \
20+
git config --global --add safe.directory /app/mkdocs && \
21+
python3 -m venv /lsiopy && \
22+
pip install -U --no-cache-dir \
23+
pip \
24+
wheel
25+
26+
COPY --from=d2 /usr/local/bin/d2 /usr/local/bin
27+
28+
COPY docs/requirements.txt /app/mkdocs/docs/requirements.txt
29+
30+
RUN \
31+
pip install -U --no-cache-dir \
32+
-r /app/mkdocs/docs/requirements.txt
33+
34+
COPY . /app/mkdocs/
35+
36+
WORKDIR /app/mkdocs
37+
38+
ENTRYPOINT ["catatonit", "--", "mkdocs", "serve"]
39+
40+
CMD [ "-a", "0.0.0.0:8000" ]

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
mkdocs-awesome-pages-plugin==2.9.3
2+
mkdocs-d2-plugin==1.5.0
23
mkdocs-git-revision-date-localized-plugin==1.3.0
34
mkdocs-material==9.5.45
45
mkdocs-minify-plugin==0.8.0

local.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Local development
2+
3+
To speed up the build, you should consider commenting out the `git-revision-date-localized` and `minify` plugin in mkdocs.yml
4+
5+
## Build image
6+
7+
```shell
8+
docker build -t lsio/documentation -f Dockerfile .
9+
```
10+
11+
## Run image
12+
13+
With docs from buildtime
14+
15+
```shell
16+
docker run --rm --name=docs -p 8000:8000 lsio/documentation
17+
```
18+
19+
With docs from runtime
20+
21+
```shell
22+
docker run --rm --name=docs -p 8000:8000 -v $PWD:/app/mkdocs lsio/documentation
23+
```
24+
25+
With watching at runtime
26+
27+
```shell
28+
docker run --rm --name=docs -p 8000:8000 -v $PWD:/app/mkdocs lsio/documentation -a 0.0.0.0:8000 --dirty
29+
```
30+
31+
With custom port
32+
33+
```shell
34+
docker run --rm --name=docs -p 9999:9999 lsio/documentation -a 0.0.0.0:9999
35+
```

mkdocs.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ markdown_extensions:
7575
permalink: true
7676
plugins:
7777
- awesome-pages
78+
- d2:
79+
layout: elk
80+
pad: 0
81+
theme: 3
82+
dark_theme: 200
7883
- git-revision-date-localized:
7984
enable_creation_date: true
8085
- minify:

0 commit comments

Comments
 (0)