Latest PlantUML in Ubuntu (docker)

0 votes
asked Feb 28, 2021 in Question / help by Fuhrmanator (1,700 points)

For some pandoc/latex and CI use (e.g, GitHub actions), I've made a Ubuntu-based docker image with a Dockerfile. But when plantuml is installed with `apt-get install -y plantuml` it's a version from 2018:

PlantUML version 1.2018.13 (Mon Nov 26 12:11:51 EST 2018)

That's preventing me from taking advantage of a lot of new features. 

What's the best way to get the latest (or specific release of) PlantUML for Ubuntu? Hopefully it's a simple install that also gets a valid JRE and the right version of GraphViz, but I don't mind putting those as separate commands provided it's valid.

2 Answers

+1 vote
answered Mar 4, 2021 by chris (2,820 points)

You just need the jar file, so just install Graphviz and whatever JRE you prefer, then download the latest jar (or whatever version you want to fix the container at).

As you're using a container, and sourceforge is a pain, it's probably easiest to just download the jar manually and include it when building the container (you just copy the file to wherever you want it in your dockerfile).

COPY plantuml.jar /usr/plantuml/plantuml.jar

(don't forget the license files)

You can then either use the direct path to the jar file, or put it into the PATH with something like 

PATH="$PATH:/usr/plantuml"
0 votes
answered Mar 4, 2021 by Fuhrmanator (1,700 points)
edited Mar 4, 2021 by Fuhrmanator

I experimented a lot with Docker finally, and since I'm calling PlantUML from a pandoc filter (in Python) it requires some more configuring. I also preferred to have the version of PlantUML already downloaded rather than taking the latest version always. I'm using a customized font, e.g. https://github.com/dummy-index/xkcd-font for a "handwritten" look, so it also needs to be installed. Here's what I came up with for a Dockerfile:

FROM pandoc/ubuntu-latex:2.11.4
COPY plantuml.jar /usr/bin/plantuml.jar
RUN apt-get update && apt-get install -y \
    python3-pip \
    default-jre \
    graphviz \
    && pip3 install pandocfilters \
    # PlantUML binary install - shebang is needed for Python
    && printf '#!/bin/sh\njava -jar /usr/bin/plantuml.jar $@' > /usr/bin/plantuml \
    && chmod +x /usr/bin/plantuml
# Used by the pandoc filter
ENV PLANTUML_BIN="/usr/bin/plantuml"
# PlantUML custom fonts
RUN mkdir -p /usr/share/fonts/TTF
COPY somefont/mycustomfont.ttf /usr/share/fonts/TTF
ENV JAVA_FONTS="/usr/share/fonts/TTF"

...