Skip to content

Commit 4f47d54

Browse files
authored
Merge pull request #92 from Believe-SA/plantuml-from-official-image
build: Use PlantUML from Docker image to work with Renovate, remove pip cache
2 parents a08694b + d67ffd8 commit 4f47d54

4 files changed

Lines changed: 21 additions & 18 deletions

File tree

‎Dockerfile‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,24 @@ FROM python:3.14-alpine@sha256:05b2b8b732ecd268fee8727a369f936f022d1321b59befd13
1616

1717
RUN apk update && apk --no-cache add gcc musl-dev openjdk17-jdk curl graphviz ttf-dejavu fontconfig
1818

19-
# Download plantuml file, Validate checksum & Move plantuml file
20-
RUN curl -o plantuml.jar -L https://github.com/plantuml/plantuml/releases/download/v1.2026.2/plantuml-1.2026.2.jar \
21-
&& echo "55884e11f3f1075d4778a9ebaa9244d530a74391 plantuml.jar" | sha1sum -c - && mv plantuml.jar /opt/plantuml.jar
19+
# Take the plantuml jar from the official image, pinned by tag and digest so Renovate
20+
# keeps it updated.
21+
COPY --from=plantuml/plantuml:1.2026.2@sha256:711a0cdf56a46d9bfac8fcc4c08872cd47e1bd31cd87f2d0268ebe75a6b100ee \
22+
/opt/plantuml.jar /opt/plantuml.jar
2223

2324
COPY requirements.txt .
24-
RUN pip install --upgrade pip && pip install -r requirements.txt
25+
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -r requirements.txt
2526

2627
# Create script to call plantuml.jar from a location in path
27-
# When adding TechDocs to the Backstage Backend container, avoid this
28-
# error (OSError: [Errno 8] Exec format error: 'plantuml') by using the
29-
# following RUN command instead:
30-
# RUN echo '#!/bin/sh\n\njava -jar '/opt/plantuml.jar' ${@}' >> /usr/local/bin/plantuml
31-
3228
# When adding TechDocs with PlantUML diagrams, to refer external puml or pu files in any markdown file,
3329
# eg. '!include <referencedFileName.puml>', you'll need to include the diagrams directory eg. docs in the classpath.
3430
# Use following RUN command instead:
35-
# RUN echo $'#!/bin/sh\n\njava -Dplantuml.include.path=${diagramDir} -jar '/opt/plantuml.jar ' ${@}' >> /usr/local/bin/plantuml
36-
RUN echo $'#!/bin/sh\n\njava -jar '/opt/plantuml.jar' ${@}' >> /usr/local/bin/plantuml
37-
RUN chmod 755 /usr/local/bin/plantuml
31+
# RUN printf '#!/bin/sh\nexec java -Dplantuml.include.path=${diagramDir} -jar /opt/plantuml.jar "$@"\n' > /usr/local/bin/plantuml && chmod 755 /usr/local/bin/plantuml
32+
33+
# "$@", not ${@}: unquoted, docs paths containing spaces get split into separate args.
34+
# printf also copies as-is into the Backstage Backend container, where the echo form failed
35+
# with: OSError: [Errno 8] Exec format error: 'plantuml'
36+
RUN printf '#!/bin/sh\nexec java -jar /opt/plantuml.jar "$@"\n' > /usr/local/bin/plantuml \
37+
&& chmod 755 /usr/local/bin/plantuml
3838

3939
ENTRYPOINT [ "mkdocs" ]

‎README.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ Note: The `latest` tag on DockerHub points to the recent commits in the `main` b
3434

3535
## Updating PlantUML
3636

37-
PlantUML is a Java based tool which is packaged in a single JAR file. You can find the latest released in their [GitHub repo under Releases](https://github.com/plantuml/plantuml/releases). When updating the Docker file with a new release of PlantUML you'll need to download the relevant JAR file first and then generate a checksum using `sha1sum`. Here are the steps:
37+
PlantUML is a Java based tool which is packaged in a single JAR file. The Dockerfile takes the JAR from the official [`plantuml/plantuml`](https://hub.docker.com/r/plantuml/plantuml) image, pinned by tag and digest, so Renovate opens the update PR and no checksum needs to be maintained by hand.
3838

39-
1. Download the JAR file: `curl -o plantuml.jar -L https://github.com/plantuml/plantuml/releases/download/v1.2024.6/plantuml-1.2024.6.jar`
40-
2. Generate the checksum: `sha1sum plantuml.jar`
41-
3. Update the Dockerfile file with the proper release URL and checksum
39+
To bump it manually, update both the tag and the digest on the `COPY --from=plantuml/plantuml:...` line. Get the digest for a version with:
40+
41+
```bash
42+
docker buildx imagetools inspect plantuml/plantuml:1.2026.2
43+
```

‎renovate.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
],
1010
"enabledManagers": [
1111
"dockerfile",
12-
"pip_requirements"
12+
"pip_requirements",
13+
"github-actions"
1314
],
1415
"packageRules": [
1516
{

‎requirements.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
mkdocs-techdocs-core==1.7.0
1+
mkdocs-techdocs-core==1.7.1

0 commit comments

Comments
 (0)