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

0 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)

...

1 Answer

0 votes
answered Apr 11, 2020 by plantuml (247,300 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!
...