-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dockerized draw.io desktop in headless mode
- Loading branch information
1 parent
bf56974
commit 8f3ca38
Showing
29 changed files
with
6,778 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[Makefile] | ||
indent_style = tab | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# These are supported funding model platforms | ||
|
||
github: rlespinasse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Build | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- v1.x | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: rlespinasse/[email protected] | ||
- name: Build docker image | ||
run: make build | ||
env: | ||
DOCKER_IMAGE: ${{ github.repository }}:${{ env.GITHUB_REF_SLUG }} | ||
- uses: cycjimmy/semantic-release-action@v2 | ||
with: | ||
semantic_version: 17.3.7 | ||
branches: | | ||
[ | ||
'v1.x', | ||
] | ||
extra_plugins: | | ||
@semantic-release/[email protected] | ||
@semantic-release/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Update Docker Hub information | ||
on: | ||
release: | ||
types: [published] | ||
push: | ||
branches: | ||
- v1.x | ||
paths: | ||
- DOCKER.md | ||
- .github/workflows/dockerhub.yaml | ||
jobs: | ||
dockerHubDescription: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Sync information on Docker Hub | ||
uses: rlespinasse/[email protected] | ||
with: | ||
pass: ${{ secrets.DOCKER_PASSWORD }} | ||
slug: rlespinasse/drawio-desktop-headless | ||
readme: ./DOCKER.md | ||
description: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Publish to Registry | ||
on: | ||
release: | ||
types: [published] | ||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: rlespinasse/[email protected] | ||
- name: Publish to Registry | ||
uses: elgohr/[email protected] | ||
with: | ||
name: rlespinasse/drawio-desktop-headless | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
tags: "latest,${{ env.GITHUB_REF_SLUG }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Draw.io Desktop Headless docker image | ||
|
||
[Dockerized headless][1] version of [Draw.io Desktop][2] | ||
|
||
## What is does | ||
|
||
Draw.io Desktop expose a command-line client to allow us to create, check or export diagrams. | ||
|
||
Since Draw.io Desktop is an GUI application, we need an GUI environment to run it. | ||
And this prevent us to use it for automation in non-GUI environment such as CI tools. | ||
|
||
This [docker image][1] enable us to run the command-line client in a headless mode. | ||
|
||
## Running | ||
|
||
```bash | ||
docker run -it -v $(pwd):/data rlespinasse/drawio-desktop-headless | ||
``` | ||
|
||
Read about [docker image configuration][3] | ||
|
||
## License | ||
|
||
View [license information][4] for the software contained in this image. | ||
|
||
As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within. | ||
|
||
[1]: https://github.com/rlespinasse/docker-drawio-desktop-headless | ||
[2]: https://github.com/jgraph/drawio-desktop | ||
[3]: https://github.com/rlespinasse/docker-drawio-desktop-headless/blob/v1.x/README.adoc#configuration | ||
[4]: https://github.com/rlespinasse/docker-drawio-desktop-headless/blob/v1.x/LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
FROM debian:latest | ||
|
||
WORKDIR "/opt/drawio-desktop" | ||
|
||
ENV DRAWIO_VERSION "14.1.8" | ||
RUN set -e; \ | ||
apt-get update && apt-get install -y \ | ||
libappindicator3-1 \ | ||
libatspi2.0-0 \ | ||
libasound2 \ | ||
libgconf-2-4 \ | ||
libgtk-3-0 \ | ||
libnotify4 \ | ||
libnss3 \ | ||
libsecret-1-0 \ | ||
libxss1 \ | ||
libxtst6 \ | ||
libgbm-dev \ | ||
sgrep \ | ||
wget \ | ||
xdg-utils \ | ||
xvfb; \ | ||
wget -q https://github.com/jgraph/drawio-desktop/releases/download/v${DRAWIO_VERSION}/draw.io-amd64-${DRAWIO_VERSION}.deb \ | ||
&& apt-get install /opt/drawio-desktop/draw.io-amd64-${DRAWIO_VERSION}.deb \ | ||
&& rm -rf /opt/drawio-desktop/draw.io-amd64-${DRAWIO_VERSION}.deb; \ | ||
rm -rf /var/lib/apt/lists/*; | ||
|
||
COPY scripts/* ./ | ||
|
||
ENV ELECTRON_DISABLE_SECURITY_WARNINGS "true" | ||
ENV DRAWIO_DISABLE_UPDATE "true" | ||
ENV DRAWIO_DESKTOP_COMMAND_TIMEOUT "10s" | ||
ENV DRAWIO_DESKTOP_EXECUTABLE_PATH "/opt/draw.io/drawio" | ||
ENV DRAWIO_DESKTOP_RUNNER_COMMAND_LINE "/opt/drawio-desktop/runner.sh" | ||
ENV XVFB_DISPLAY ":42" | ||
ENV XVFB_OPTIONS "" | ||
|
||
ENTRYPOINT [ "/opt/drawio-desktop/entrypoint.sh" ] | ||
CMD [ "--help" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.PHONY: build run setup-test test cleanup | ||
|
||
DOCKER_IMAGE?=rlespinasse/drawio-desktop-headless:local | ||
build: | ||
@docker build -t ${DOCKER_IMAGE} . | ||
|
||
RUN_ARGS?= | ||
DOCKER_OPTIONS?= | ||
run: | ||
@docker run -t $(DOCKER_OPTIONS) -w /data -v $(PWD):/data ${DOCKER_IMAGE} ${RUN_ARGS} | ||
|
||
setup-test: | ||
@npm install -g bats | ||
|
||
test: cleanup build | ||
@mkdir -p tests/output | ||
@DOCKER_IMAGE=$(DOCKER_IMAGE) bats -r tests | ||
|
||
cleanup: | ||
@rm -rf tests/output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
= Draw.io Desktop Headless docker image | ||
|
||
image:https://img.shields.io/docker/v/rlespinasse/drawio-desktop-headless[Docker Version,link=https://hub.docker.com/r/rlespinasse/drawio-desktop-headless] | ||
image:https://img.shields.io/docker/pulls/rlespinasse/drawio-desktop-headless[Docker Pull,link=https://hub.docker.com/r/rlespinasse/drawio-desktop-headless] | ||
image:https://github.com/rlespinasse/docker-drawio-desktop-headless/workflows/Build/badge.svg[Build] | ||
|
||
Dockerized headless version of https://github.com/jgraph/drawio-desktop[Draw.io Desktop] | ||
|
||
== What is does | ||
|
||
Draw.io Desktop expose a command-line client to allow us to create, check or export diagrams. | ||
|
||
Since Draw.io Desktop is an GUI application, we need an GUI environment to run it. | ||
And this prevent us to use it for automation in non-GUI environment such as CI tools. | ||
|
||
This docker image enable us to run the command-line client in a headless mode by using a configurable **X** server. | ||
|
||
Other minor addition have been set | ||
* Add timeout capability since the application can hang sometimes (due to user action needed in GUI mode) | ||
* Clear the output log from Electron Security Warning | ||
* Disable auto-update functionality to avoid unneccessary log | ||
|
||
== Running | ||
|
||
[source,bash] | ||
---- | ||
docker run -it -v $(pwd):/data rlespinasse/drawio-desktop-headless | ||
---- | ||
|
||
=== Configuration | ||
|
||
[cols="2a,3a,1a",options="header"] | ||
|=== | ||
|
||
| 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 | ||
| | ||
|
||
| **ELECTRON_DISABLE_SECURITY_WARNINGS** | ||
| Avoid printing https://github.com/electron/electron/blob/master/docs/tutorial/security.md#electron-security-warnings[electron warning] | ||
| `true` | ||
|
||
| **DRAWIO_DISABLE_UPDATE** | ||
| Disable | ||
| `true` | ||
|
||
|=== | ||
|
||
== Use as docker base image | ||
|
||
This docker image can be used as base image to build a higher-level tool upon it. | ||
|
||
In addition of 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. | ||
|
||
== Thanks to | ||
|
||
Thanks for the community about https://github.com/jgraph/drawio-desktop/issues/127[the work around docker-image based of Draw.io Desktop]. | ||
|
||
== 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. |
Oops, something went wrong.