This repository was archived by the owner on Sep 1, 2023. It is now read-only.
File tree 3 files changed +44
-2
lines changed
3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,11 @@ FROM docker.io/alpine:3
2
2
3
3
ENV PLANTUML_VERSION 1.2021.11
4
4
ENV LANG en_US.UTF-8
5
- RUN apk add --no-cache openjdk8-jre graphviz ttf-droid ttf-droid-nonlatin curl \
5
+ RUN apk add --no-cache openjdk8-jre graphviz ttf-droid ttf-droid-nonlatin curl shadow su-exec \
6
6
&& mkdir /app \
7
7
&& curl -L https://sourceforge.net/projects/plantuml/files/plantuml.${PLANTUML_VERSION}.jar/download -o /app/plantuml.jar \
8
8
&& apk del curl
9
+ COPY entrypoint /
9
10
10
- ENTRYPOINT [ "java" , "-jar" , "/app/plantuml.jar " ]
11
+ ENTRYPOINT [ "/entrypoint " ]
11
12
CMD [ "-h" ]
Original file line number Diff line number Diff line change @@ -34,6 +34,17 @@ $ run-plantuml [PLANTUML OPTIONS and ARGUMENTS]
34
34
` docker run ` and ` run-plantuml ` accept and pass a set of parameters to PlantUML CLI.
35
35
See ` docker run miy4/plantuml -h ` or ` run-plantuml -h ` output for more details.
36
36
37
+ ### Environment Variables
38
+
39
+ You can explicitly set the UID and GID of artifacts using the environment variables ` PUML_UID ` and ` PUML_GID ` .
40
+ In the following run example, PlantUML generates ` sequence_diagram.png ` owned by the user with UID 1000 and GID 1000.
41
+
42
+ ``` sh
43
+ $ docker run -e PUML_UID=1000 -e PUML_GID=1000 -v ${PWD} :/work -w /work --rm -t miy4/plantuml -tpng sequence_diagram.uml
44
+ ```
45
+
46
+ If you don't use ` PUML_UID ` and ` PUML_GID ` , PlantUML generates the files to have the same UID and GID as the owner of the working directory given by ` -w ` , ` --workdir ` .
47
+
37
48
## Example
38
49
39
50
``` sh
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ if [ " $( id -u) " -ne 0 ]; then
4
+ printf ' Error: You cannot be non-root users\n' 1>&2
5
+ printf ' Use environment variables PUML_UID and PUML_GID to pass your UID/GID.\n' 1>&2
6
+ exit 1
7
+ # or should do nothing in particular?
8
+ # exec java -jar /app/plantuml.jar "$@"
9
+ fi
10
+
11
+ # Read UID/GID via environment variables.
12
+ # If they are not available, Fetch UID/GID from the working directory.
13
+ # These values would be the owner UID/GID of PlantUML's artifacts.
14
+ #
15
+ # Note: For Windows filesystems, stat always returns UID=0 and GID=0
16
+ gid=${PUML_GID:- " $( stat -c ' %g' .) " }
17
+ uid=${PUML_UID:- " $( stat -c ' %u' .) " }
18
+
19
+ # Do as the root
20
+ if [ " $uid " -eq 0 ] || [ " $gid " -eq 0 ]; then
21
+ exec java -jar /app/plantuml.jar " $@ "
22
+ fi
23
+
24
+ # Create a new working user
25
+ user=' worker'
26
+ groupadd --non-unique --gid " $gid " " $user "
27
+ useradd --non-unique --uid " $uid " --gid " $gid " --create-home " $user "
28
+
29
+ # Execute a PlantUML process as the worker
30
+ su-exec " $user " java -jar /app/plantuml.jar " $@ "
You can’t perform that action at this time.
0 commit comments