modelmat / sphinxcontrib-drawio

Sphinx extension for including draw.io files.
MIT License
39 stars 17 forks source link

DrawIO fails to run on gitlab-ci docker container #49

Closed mcfly3001 closed 3 years ago

mcfly3001 commented 3 years ago

Hi,

I have problems when running drawio within a gitlab-ci test setup. The following error occurs:

Running as root without --no-sandbox is not supported

The issue seems to be related to this issue one from the original drawio repository. A workaround seems to be to use '--no-sandbox --headless --disable-gpu'. These parameters are currently not used, right?

Or am I doing something wrong? This is the relevant snippet of my ci-file:

image: python:latest

build: stage: build script:

modelmat commented 3 years ago

This project should work on the CI (after all, our tests run on the CI).

This should be autodetected to run Xvfb if an X display is not detected, and will use the --no-sandbox option as necessary.

Could you try forcing drawio_headless to True? See the README for how to set this up. If that does work, maybe GitLab CI is setting the DISPLAY env variable, yet not starting an X display? If that fails, could you try using v12.6.5 - this is what our CI tests against.

mcfly3001 commented 3 years ago

Hi, thanks for the info. drawio_headless was already set to True. So I now tried the version 12.6.5 but still have no success. Here is the output:

$ make html
Running Sphinx v3.3.1
making output directory... done
running in headless mode, starting Xvfb
Xvfb is running on display :0
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 18 source files that are out of date
updating environment: [new config] 18 added, 0 changed, 0 removed
reading sources... [  5%] a_qm_employee_guide/employee_guide
reading sources... [ 11%] b_qm_process_description/4_context_of_organization/4_context_of_organization
reading sources... [ 16%] b_qm_process_description/5_leadership/5_leadership
reading sources... [ 22%] b_qm_process_description/6_qms_planning/6_qms_planning
reading sources... [ 27%] b_qm_process_description/7_assistance/7_assistance
reading sources... [ 33%] b_qm_process_description/8_operation/8_operation
reading sources... [ 38%] b_qm_process_description/9_evaluation_of_performance/9_evaluation_of_performance
reading sources... [ 44%] b_qm_process_description/process_description
reading sources... [ 50%] glossary
reading sources... [ 55%] index
reading sources... [ 61%] n_qm_proofs/qm_evidence
DrawIO Error:
draw.io (/opt/draw.io/drawio --export --crop --page-index 0 --scale 1.0 --format svg --output /builds/dev-threads/quality-management/source/.drawio/d4b8393918efb4f4a5df6a1803b44e7321edfd84/organigram.svg /builds/dev-threads/quality-management/source/_static/organigram.drawio) exited with error:
[stderr]
b'[2154:1120/073022.142580:FATAL:atom_main_delegate.cc(211)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.\n'
[stdout]
b''

Any other ideas or suggestions? Thanks!

modelmat commented 3 years ago

Can you try setting drawio_no_sandbox=True? I believe this was recently split out from drawio_headless, and thus would be why this is now occurring. (I'm assuming you're on 0.0.12?)

@brechtm I'm not sure what advantage having these as two different config options provides?

mcfly3001 commented 3 years ago

Thanks! That solved the issue. Maybe its worth updating the readme to also set this option.

modelmat commented 3 years ago

This is located in the README, but it's not very clear that both may be necessary if you don't read the descriptions of all of the options. It is mentioned in the description of that option that "it may be required for docker". Definitely can make this more explicit.

brechtm introduced this extra option, so I'll wait and see if it's necessary for any reason as it might be possible to roll it together with drawio_headless.

mcfly3001 commented 3 years ago

Ah damnit! Seems it was just too late last night to properly read the documentation :-)

brechtm commented 3 years ago

To avoid any confusion: neither drawio (drawio --help) nor Electron seem to support the --headless or --disable-gpu command-line flags.

I learned that--no-sandbox (as the last argument!) was necessary to get drawio exporting to work in Docker in my situation. I don't know whether it is always necessary when running drawio in a Docker container.

I assume it is also necessary to pass --no-sandbox when not running drawio headless, but I haven't verified this.

yboujraf commented 1 year ago

Hi, thanks for the info. drawio_headless was already set to True. So I now tried the version 12.6.5 but still have no success. Here is the output:

$ make html
Running Sphinx v3.3.1
making output directory... done
running in headless mode, starting Xvfb
Xvfb is running on display :0
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 18 source files that are out of date
updating environment: [new config] 18 added, 0 changed, 0 removed
reading sources... [  5%] a_qm_employee_guide/employee_guide
reading sources... [ 11%] b_qm_process_description/4_context_of_organization/4_context_of_organization
reading sources... [ 16%] b_qm_process_description/5_leadership/5_leadership
reading sources... [ 22%] b_qm_process_description/6_qms_planning/6_qms_planning
reading sources... [ 27%] b_qm_process_description/7_assistance/7_assistance
reading sources... [ 33%] b_qm_process_description/8_operation/8_operation
reading sources... [ 38%] b_qm_process_description/9_evaluation_of_performance/9_evaluation_of_performance
reading sources... [ 44%] b_qm_process_description/process_description
reading sources... [ 50%] glossary
reading sources... [ 55%] index
reading sources... [ 61%] n_qm_proofs/qm_evidence
DrawIO Error:
draw.io (/opt/draw.io/drawio --export --crop --page-index 0 --scale 1.0 --format svg --output /builds/dev-threads/quality-management/source/.drawio/d4b8393918efb4f4a5df6a1803b44e7321edfd84/organigram.svg /builds/dev-threads/quality-management/source/_static/organigram.drawio) exited with error:
[stderr]
b'[2154:1120/073022.142580:FATAL:atom_main_delegate.cc(211)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.\n'
[stdout]
b''

Any other ideas or suggestions? Thanks!

could you share your gitlab-ci.yml ? I am figuring same issue.

Best Regards

mcfly3001 commented 1 year ago

Hi, it has been a while and we haven't changed anything in the ci-pipeline recently. This is, how we currently build the documentation and it runs without any problems:

build:
  stage: build
  script:
  - apt update
  - apt install -y wget
  - apt install -y libgbm-dev
  - apt install -y libasound2
  - wget https://github.com/jgraph/drawio-desktop/releases/download/v14.9.6/drawio-amd64-14.9.6.deb
  - apt install -y -f ./drawio-amd64-14.9.6.deb
  - apt install -y xvfb
  - pip install -r requirements.txt
  - export SPHINXOPTS=-W # treat warnings as errors
  - if [ $CI_COMMIT_REF_NAME != 'master' ] ; then export SPHINXOPTS="$SPHINXOPTS -t draft" ; fi
  - make html
  - mv build/html public
  artifacts:
    name: "Doc-$CI_COMMIT_REF_NAME"
    expose_as: "Documentation"
    paths:
    - public/