Skip to content

Commit 4681393

Browse files
authored
📄Host kroki in container for GitHub Pages workflow (#765)
1 parent 3378fd8 commit 4681393

6 files changed

Lines changed: 21 additions & 3 deletions

File tree

‎.github/workflows/docs_latest.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ jobs:
3333
- name: Write version to conf.py
3434
run: |
3535
echo -e "version = release = \"latest\"\n" | cat - docs/conf.py > /tmp/conf.py && mv /tmp/conf.py docs/conf.py
36+
- name: Run kroki with docker
37+
run: |
38+
docker compose up -d
3639
- name: Build the documentation
3740
uses: sphinx-notes/pages@v2
3841
# Note: This action has a newer version (v3 atm), but it doesn't has the feature to specify the target path.

‎.github/workflows/python-publish.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ jobs:
9393
run: |
9494
echo -e "version = release = \"${{ github.ref_name }}\"\n" | cat - docs/conf.py > /tmp/conf.py
9595
mv /tmp/conf.py docs/conf.py
96+
- name: Run kroki with docker
97+
run: |
98+
docker compose up -d
9699
- name: Build the documentation
97100
uses: sphinx-notes/pages@v2
98101
# Note: This action has a newer version (v3 atm), but it doesn't has the feature to specify the target path.

‎.github/workflows/test_docs.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ jobs:
1414
uses: actions/setup-python@v5
1515
with:
1616
python-version: ${{ matrix.python-version }}
17+
- name: Run kroki with docker
18+
run: |
19+
docker compose up -d
1720
- name: Install dependencies
1821
run: |
1922
python -m pip install --upgrade pip

‎docker-compose.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: "3"
2+
services:
3+
core:
4+
image: yuzutech/kroki
5+
ports:
6+
- "8000:8000"

‎docs/conf.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,5 +311,5 @@
311311
uml.write_class_umls(_network, _namespaces_to_parse, Path(output_dir) / "uml")
312312
print("Created uml files.")
313313

314-
uml.compile_files_kroki(Path(output_dir) / "uml", Path(output_dir).parent / "_static" / "images")
314+
uml.compile_files_kroki(Path(output_dir) / "uml", Path(output_dir).parent / "_static" / "images", locally_hosted=True)
315315
print(f"Compiled uml files into svg using kroki.")

‎docs/uml.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,12 +565,15 @@ def _recursive_add_class(
565565
# ------------------------------------------------------------------------------------------------------------------
566566

567567

568-
def compile_files_kroki(input_dir: Path, output_dir: Path) -> None:
568+
def compile_files_kroki(input_dir: Path, output_dir: Path, locally_hosted: bool = False) -> None:
569569
"""
570570
Compiles all plantuml files inside `input_dir` (recursive) to svg's in `output_dir` with the same subpath as in
571571
`input_dir`. Files are compiled using web service of [kroki](https://kroki.io)
572572
"""
573-
url = "https://kroki.io"
573+
if locally_hosted:
574+
url = "http://localhost:8000"
575+
else:
576+
url = "https://kroki.io"
574577
for root, _, files in os.walk(input_dir):
575578
for file in files:
576579
with open(os.path.join(root, file), "r", encoding="utf-8") as uml_file:

0 commit comments

Comments
 (0)