Can you please publish an official Docker image that supports GUI & headless operation?

+3 votes
asked Apr 11, 2020 in Wanted features by matthewadams12 (240 points)

The requirement of java & graphviz is a bit onerous and unnecessary in the world of Docker.

There are many unofficial plantuml Docker images out there:  https://hub.docker.com/search?q=plantuml&type=image

Can you please publish an official plantuml Docker image that allow for GUI operation?  You can steal from any of the existing Docker images found in the search above, or start with:

FROM openjdk:14-buster

ARG PLANTUML_VERSION=1.2020.6

ENV LANG en_US.UTF-8
RUN \
  apt update && \
  apt install -yy --no-install-recommends \
    graphviz wget ca-certificates fonts-dejavu-core fontconfig xorg libgl1-mesa-glx && \
  apt clean

RUN wget "http://downloads.sourceforge.net/project/plantuml/${PLANTUML_VERSION}/plantuml.${PLANTUML_VERSION}.jar" -O plantuml.jar

RUN ["java", "-jar", "plantuml.jar", "-version"]
RUN ["dot", "-version"]

ENTRYPOINT ["java", "-jar", "/plantuml.jar"]
CMD ["-help"]

Save the above to a file called Dockerfile, then run

docker build -f Dockerfile -t plantuml .

in the directory containing Dockerfile.  I run it with the following script ('nix only):

#!/usr/bin/env sh

THIS_DIR="$(cd "$(dirname "$0")"; pwd)"
IMAGE=${IMAGE:-plantuml}
PLANTUML_ARGS=${*:--gui -tsvg -o .}
FULL_ARGS=${FULL_ARGS:-$JAVA_OPTS -jar /plantuml.jar $PLANTUML_ARGS}
IF=${IF:-en0}

docker run --rm -i \
  -v "$THIS_DIR":/cwd -w /cwd \
  -e DISPLAY="$(ifconfig $IF | egrep '^\s*inet ' | cut -d' ' -f2):0" \
  --entrypoint "java" \
  $IMAGE $FULL_ARGS

It launches the file open dialog ok, but when I double-click on an entry, nothing happens, and when I use the down arrow then enter to open one, I get the error at the end of this message.

It would be great if y'all could finish this up.

Exception:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

at java.desktop/javax.swing.ImageIcon.<init>(ImageIcon.java:240)

at java.desktop/javax.swing.ImageIcon.<init>(ImageIcon.java:226)

at net.sourceforge.plantuml.swing.ImageWindow2.buildScrollablePicture(ImageWindow2.java:343)

...

commented Mar 15, 2023 by evantill (480 points)
Do you think of some plantuml CLI wrapper ?

Like running it from the command line "like" if it where installed locally ?

2 Answers

0 votes
answered Apr 11, 2020 by plantuml (295,000 points)
Unfortunately, we have little knowledge about Docker, so we probably need help here...

(Anyone can create pull request of new Dockerfiles to https://github.com/plantuml/plantuml-server )

The error message seems related to missing graphical ressource (see question about X11 in https://plantuml.com/faq ) But I'm not sure how to fix it. Sorry about that!
0 votes
answered Mar 12, 2023 by Sébastien Barbieri

I did just publish an how to add graphviz inside a jetty server to host a plantuml service.

https://blog.sbw.be/install-your-own-plantuml-server-inside-a-docker/

Feel free to comment, I'll update accordingly.

The idea is to start from a jetty docker service already configured, it's the easiest.

commented Mar 15, 2023 by plantuml (295,000 points)
Hey, that's very nice and interesting!

Would you mind if we copy your page to https://github.com/plantuml/plantuml-server in some markdown file (given your credit for it)?

I think it would give a better visibility to your post.

You can even provide a PR yourself if you want, but if you have to time to that, we'll do it for you.
...