foliant-docs / foliant

Comprehensive markdown-based documentation toolkit
https://foliant-docs.github.io/docs/
MIT License
160 stars 9 forks source link

Plantuml doesn't work in Docker mode. #52

Closed arisc097 closed 3 years ago

arisc097 commented 5 years ago

I am using the docker approach in which it doesn't work. (Plantuml works in non-docker approach).

Log:

2019-10-13 03:00:09,191 |              flt.cfg |  WARNING | Working in backward compatibility mode. To get rid of this warning, enable the escape_code config option
2019-10-13 03:00:09,223 |  flt.mkdocs.plantuml |    ERROR | Command 'plantuml .diagramscache/plantuml/0b281caf0bed2faae37fe21cf4015080.diag' returned non-zero exit status 127.
2019-10-13 03:00:09,225 |           flt.mkdocs |    ERROR | Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/foliant/preprocessors/plantuml.py", line 117, in _process_plantuml
    run(command, shell=True, check=True, stdout=PIPE, stderr=STDOUT)
  File "/usr/lib/python3.7/subprocess.py", line 487, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'plantuml .diagramscache/plantuml/0b281caf0bed2faae37fe21cf4015080.diag' returned non-zero exit status 127.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/foliant/backends/base.py", line 72, in apply_preprocessor
    preprocessor_options
  File "/usr/local/lib/python3.7/dist-packages/foliant/preprocessors/plantuml.py", line 200, in apply
    processed_content = self.process_plantuml(content)
  File "/usr/local/lib/python3.7/dist-packages/foliant/preprocessors/plantuml.py", line 185, in process_plantuml
    processed = self.pattern.sub(_sub, content)
  File "/usr/local/lib/python3.7/dist-packages/foliant/preprocessors/plantuml.py", line 169, in _sub
    diagram.group('body')
  File "/usr/local/lib/python3.7/dist-packages/foliant/preprocessors/plantuml.py", line 146, in _process_plantuml
    raise RuntimeError(f'Failed: {exception.output.decode()}')
RuntimeError: Failed: /bin/sh: 1: plantuml: not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/foliant/utils.py", line 131, in spinner
    yield
  File "/usr/local/lib/python3.7/dist-packages/foliant/backends/base.py", line 80, in apply_preprocessor
    f'Failed to apply preprocessor {preprocessor_name}: {exception}'
RuntimeError: Failed to apply preprocessor plantuml: Failed: /bin/sh: 1: plantuml: not found

Dockerfile:

FROM foliant/foliant
# If you plan to bake PDFs, uncomment this line and comment the line above:
# FROM foliant/foliant:pandoc

RUN pip3 install foliantcontrib.admonitions
RUN pip3 install foliantcontrib.badges
RUN pip3 install foliantcontrib.blockdiag
RUN pip3 install foliantcontrib.glossary
RUN pip3 install foliantcontrib.graphviz
RUN pip3 install foliantcontrib.imagemagick
RUN pip3 install foliantcontrib.plantuml
RUN pip3 install foliantcontrib.csvtables
COPY requirements.txt .
RUN pip3 install -r requirements.txt

foliant.yml:

title: Hello Foliant

chapters:
  - index.md

preprocessors:
  - admonitions
  - badges
  - blockdiag
  - csvtables
  - glossary
  - graphviz
  - imagemagick
  - plantuml:
      parse_raw: true

$ docker-compose build

[1570941564.log](https://github.com/foliant-docs/foliant/files/3721429/1570941564.log)

Building hello-foliant
Step 1/11 : FROM foliant/foliant
 ---> a4df1ec12308
Step 2/11 : RUN pip3 install foliantcontrib.admonitions
 ---> Using cache
 ---> d7cb3f6539e0
Step 3/11 : RUN pip3 install foliantcontrib.badges
 ---> Using cache
 ---> 3fca05075b08
Step 4/11 : RUN pip3 install foliantcontrib.blockdiag
 ---> Using cache
 ---> 8a90d5abd1a2
Step 5/11 : RUN pip3 install foliantcontrib.glossary
 ---> Using cache
 ---> 6e51980acbf7
Step 6/11 : RUN pip3 install foliantcontrib.graphviz
 ---> Using cache
 ---> ddf91cb4b8c5
Step 7/11 : RUN pip3 install foliantcontrib.imagemagick
 ---> Using cache
 ---> ed7a0562ada1
Step 8/11 : RUN pip3 install foliantcontrib.plantuml
 ---> Using cache
 ---> 86771dacac7f
Step 9/11 : RUN pip3 install foliantcontrib.csvtables
 ---> Using cache
 ---> 5b5d58d4e570
Step 10/11 : COPY requirements.txt .
 ---> Using cache
 ---> aba452c55f77
Step 11/11 : RUN pip3 install -r requirements.txt
 ---> Using cache
 ---> f905bba788e0
Successfully built f905bba788e0
Successfully tagged hello-foliant_hello-foliant:latest

Plantuml install:

Step 9/12 : RUN pip3 install foliantcontrib.plantuml
 ---> Running in 0bcb4bc1732b
Collecting foliantcontrib.plantuml
  Downloading https://files.pythonhosted.org/packages/3d/0a/31a1357ead85b1c00680817bbd4d3c512b44a10d107146a87c61f8f5c83f/foliantcontrib.plantuml-1.0.6.tar.gz
Requirement already satisfied: foliant>=1.0.8 in /usr/local/lib/python3.7/dist-packages (from foliantcontrib.plantuml) (1.0.10)
Requirement already satisfied: cliar<2.0.0,>=1.3.2 in /usr/local/lib/python3.7/dist-packages (from foliant>=1.0.8->foliantcontrib.plantuml) (1.3.2)
Requirement already satisfied: pyyaml<6.0.0,>=5.1.1 in /usr/local/lib/python3.7/dist-packages (from foliant>=1.0.8->foliantcontrib.plantuml) (5.1.1)
Requirement already satisfied: prompt_toolkit<3.0,>=2.0 in /usr/local/lib/python3.7/dist-packages (from foliant>=1.0.8->foliantcontrib.plantuml) (2.0.9)
Requirement already satisfied: six>=1.9.0 in /usr/lib/python3/dist-packages (from prompt_toolkit<3.0,>=2.0->foliant>=1.0.8->foliantcontrib.plantuml) (1.12.0)
Requirement already satisfied: wcwidth in /usr/local/lib/python3.7/dist-packages (from prompt_toolkit<3.0,>=2.0->foliant>=1.0.8->foliantcontrib.plantuml) (0.1.7)
Building wheels for collected packages: foliantcontrib.plantuml
  Running setup.py bdist_wheel for foliantcontrib.plantuml: started
  Running setup.py bdist_wheel for foliantcontrib.plantuml: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/ed/67/cd/0dc8e19796271f308101452f83b677f1a098982fe441cdd4e4
Successfully built foliantcontrib.plantuml
Installing collected packages: foliantcontrib.plantuml
Successfully installed foliantcontrib.plantuml-1.0.6
Removing intermediate container 0bcb4bc1732b

$ docker-compose run --rm hello-foliant make site

Parsing config... Done
Applying preprocessor admonitions... Done
Applying preprocessor badges... Done
Applying preprocessor blockdiag... Done
Applying preprocessor csvtables... Done
Applying preprocessor glossary... Done
Applying preprocessor graphviz... WARNING: [hello.md] Processing of GraphViz diagram failed.

Done
Applying preprocessor imagemagick... Done
Applying preprocessor plantuml... Failed to apply preprocessor plantuml: Failed: /bin/sh: 1: plantuml: not found

Applying preprocessor mkdocs... Done
Applying preprocessor _unescape... Done
Making site with MkDocs... Done
────────────────────
Result: Hello_Foliant-2019-10-13.mkdocs
anorm commented 4 years ago

You need to have your Dockerfile install plantuml as well. The foliantcontrib.plantuml installed in step 9 is the foliant plugin which expects plantuml to be reachable by the PATH.

You can solve this issue by either installing plantuml or by basing your Dockerfile on the foliant/foliant:full tag instead of the latest tag. The latter is the easier option:

Replace line 1 in your Dockerfile with:

FROM foliant/foliant:full

Also, since the full tag contains all the official contribs, you can remove all the lines starting with RUN pip3 install foliantcontrib from you Dockerfile.