Skip to content

rlespinasse/docker-drawio-desktop-headless

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Draw.io Desktop Headless docker image

Dockerized headless version of Draw.io Desktop v24.2.5

What it does

Draw.io Desktop exposes a command-line client to allow us to create, check or export diagrams.

Since Draw.io Desktop is a GUI application, we need a GUI environment to run it. And this prevents us to use it for automation in non-GUI environments such as CI tools.

This docker image enables us to run the command-line client in a headless mode by using a configurable X server.

Other minor additions are available

Note
Want a new font package, modify the Dockerfile to install the missing package.

Running

Default run
$ docker run -it -w /data -v $(pwd):/data rlespinasse/drawio-desktop-headless
Usage: drawio [options] [input file/folder]
...
Run using non-root user
$ docker run -it \
          -u $(id -u):$(id -g) \ (1)
          -e HOME=/data/home -w /data \ (2)
          -v $(pwd):/data rlespinasse/drawio-desktop-headless
Usage: drawio [options] [input file/folder]
...
  1. Enable non-root user

  2. env HOME need to contains the path of the working directory (can be the same)

    If env HOME is not set properly
    Fontconfig error: No writable cache directories
    A JavaScript error occurred in the main process
    Uncaught Exception:
    Error: Failed to get 'userData' path
        at initDataListener (/opt/drawio/resources/app.asar/node_modules/electron-store/index.js:15:19)
        at new ElectronStore (/opt/drawio/resources/app.asar/node_modules/electron-store/index.js:48:32)
        at Object.<anonymous> (/opt/drawio/resources/app.asar/src/main/electron.js:15:15)
        at Module._compile (node:internal/modules/cjs/loader:1271:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1326:10)
        at Module.load (node:internal/modules/cjs/loader:1126:32)
        at Module._load (node:internal/modules/cjs/loader:967:12)
        at l._load (node:electron/js2c/asar_bundle:2:13642)
        at node:electron/js2c/browser_init:2:120247
        at node:electron/js2c/browser_init:2:120456
    /opt/drawio-desktop/runner.sh: line 4:    15 Trace/breakpoint trap   (core dumped) "${DRAWIO_DESKTOP_EXECUTABLE_PATH:?}" "$@" --no-sandbox --disable-gpu

Configuration

Environment Variable Description Default Value

DRAWIO_DESKTOP_COMMAND_TIMEOUT

To prevent Draw.io Desktop process to hang indefinitely.

The value is a floating point number with an optional suffix: 's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days. A duration of 0 disables the associated timeout.

10s

XVFB_DISPLAY

Screen Display setup for XVFB

:42

XVFB_OPTIONS

Options for Xvfb

-nolisten unix (enable non-root run)

ELECTRON_DISABLE_SECURITY_WARNINGS

Avoid printing electron warning

true

DRAWIO_DISABLE_UPDATE

Disable auto-update of Draw.io Desktop

true

Use as docker base image

This docker image can be used as the base image to build a higher-level tool upon it.

In addition to running configuration, you have access to

  • DRAWIO_DESKTOP_EXECUTABLE_PATH to have access to the executable path of Draw.io Desktop.

  • DRAWIO_DESKTOP_RUNNER_COMMAND_LINE to run your script instead of the default one.

Used by

Thanks to

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.