1
0
mirror of https://github.com/octoleo/plantuml-server.git synced 2024-07-23 08:30:20 +00:00

improve docker handling

This commit is contained in:
Florian 2021-10-11 17:33:30 +02:00 committed by arnaudroques
parent 5190a72cc8
commit 221af78afc
6 changed files with 73 additions and 82 deletions

View File

@ -1,20 +0,0 @@
FROM maven:3-jdk-11
RUN apt-get update && apt-get install -y --no-install-recommends graphviz fonts-wqy-zenhei && rm -rf /var/lib/apt/lists/*
COPY pom.xml /app/
COPY src /app/src/
ENV MAVEN_CONFIG=/app/.m2
WORKDIR /app
RUN mvn package
# chmod required to ensure any user can run the app
RUN mkdir /app/.m2 && chmod -R a+w /app
EXPOSE 8080
ENV HOME /app
CMD java -Djetty.contextpath=/ -jar target/dependency/jetty-runner.jar target/plantuml.war
# To run with debugging enabled instead
#CMD java -Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog -Dorg.eclipse.jetty.LEVEL=DEBUG -Djetty.contextpath=/ -jar target/dependency/jetty-runner.jar target/plantuml.war

View File

@ -1,26 +1,33 @@
FROM maven:3-jdk-11 AS builderjetty
FROM maven:3-jdk-11-slim AS builder
COPY pom.xml /app/
COPY src /app/src/
COPY src/main /app/src/main/
WORKDIR /app
RUN mvn --batch-mode --define java.net.useSystemProxies=true package
########################################################################################
FROM jetty:9.4-jre11
MAINTAINER D.Ducatel
FROM jetty:9.4-jre11-slim
USER root
RUN apt-get update && \
apt-get install -y --no-install-recommends graphviz fonts-noto-cjk && \
rm -rf /var/lib/apt/lists/* \
apt-get install -y --no-install-recommends \
fonts-noto-cjk \
graphviz \
&& \
rm -rf /var/lib/apt/lists/* && \
/generate-jetty-start.sh
COPY docker-entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
USER jetty
ENV GRAPHVIZ_DOT=/usr/bin/dot
ENV BASE_URL=ROOT \
WEBAPP_PATH=$JETTY_BASE/webapps
RUN rm -rf $WEBAPP_PATH && \
mkdir -p $WEBAPP_PATH
COPY --from=builder /app/target/plantuml.war $WEBAPP_PATH/ROOT.war
ARG BASE_URL=ROOT
COPY --from=builderjetty /app/target/plantuml.war /var/lib/jetty/webapps/$BASE_URL.war
ENTRYPOINT ["/entrypoint.sh"]

View File

@ -1,43 +1,30 @@
FROM maven:3-jdk-11 AS buildertomcat
FROM maven:3-jdk-11-slim AS builder
COPY pom.xml /app/
COPY src /app/src/
COPY src/main /app/src/main/
WORKDIR /app
RUN mvn --batch-mode --define java.net.useSystemProxies=true package
########################################################################################
FROM tomcat:9.0-jdk11-openjdk-slim as graphviz
RUN apt-get update && \
apt-get install -y wget binutils gcc make ghostscript groff g++ fontconfig fontconfig-config fonts-dejavu-core fonts-noto-cjk file libexpat1-dev libcairo2-dev libpango1.0-dev
RUN mkdir /root/build && \
cd /root/build && \
wget -O - https://www2.graphviz.org/Packages/stable/portable_source/graphviz-2.44.1.tar.gz | gzip -d | tar xvf - && \
cd graphviz-2.44.1 && \
./configure --prefix /usr && \
make -j 4 && \
make DESTDIR=/root/install/ install-strip
########################################################################################
FROM tomcat:9.0-jdk11-openjdk-slim
MAINTAINER D.Ducatel
RUN apt-get update && \
apt-get install -y --no-install-recommends fonts-noto-cjk libexpat1 libcairo2 libpango1.0 libpangoft2-1.0 libpangocairo-1.0 && \
apt-get install -y --no-install-recommends \
fonts-noto-cjk \
graphviz \
&& \
rm -rf /var/lib/apt/lists/*
ENV GRAPHVIZ_DOT=/usr/bin/dot
COPY docker-entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ARG BASE_URL=ROOT
RUN rm -rf /usr/local/tomcat/webapps/$BASE_URL
COPY --from=buildertomcat /app/target/plantuml.war /usr/local/tomcat/webapps/$BASE_URL.war
COPY --from=graphviz /root/install/usr/bin/dot /usr/bin/
COPY --from=graphviz /root/install/usr/lib/ /usr/lib/
RUN dot -c
ENV BASE_URL=ROOT \
WEBAPP_PATH=$CATALINA_HOME/webapps
RUN rm -rf $WEBAPP_PATH && \
mkdir -p $WEBAPP_PATH
COPY --from=builder /app/target/plantuml.war $WEBAPP_PATH/ROOT.war
ENTRYPOINT ["/entrypoint.sh"]
CMD ["catalina.sh", "run"]

View File

@ -57,12 +57,12 @@ This makes the container compatible with more restricted environment such as Ope
## Change base URL
To run plantuml using different base url, change the `docker-compose.yml` file:
~~~
args:
BASE_URL: plantuml
~~~
```yaml
environment:
- BASE_URL=plantuml
```
And run `docker-compose up --build`. This will build a modified version of the image using
And run `docker-compose up`. This will start a modified version of the image using
the base url `/plantuml`, e.g. http://localhost/plantuml
How to set PlantUML options
@ -86,21 +86,21 @@ docker run -d -p 8080:8080 -e THE_ENV_VARIABLE=THE_ENV_VALUE plantuml/plantuml-s
You can set all the following variables:
* `PLANTUML_LIMIT_SIZE`
* Limits image width and height
* Default value: `4096`
* `GRAPHVIZ_DOT`
* Link to 'dot' executable
* Default value: `/usr/local/bin/dot` or `/usr/bin/dot`
* `PLANTUML_STATS`
* Set it to `on` to enable [statistics report](http://plantuml.com/statistics-report)
* Default value: `off`
* `HTTP_AUTHORIZATION`
* when calling the `proxy` endpoint, the value of `HTTP_AUTHORIZATION` will be used to set the HTTP Authorization header
* Default value: `null`
* `ALLOW_PLANTUML_INCLUDE`
* Enables `!include` processing which can read files from the server into diagrams. Files are read relative to the current working directory.
* Default value: `false`
- `BASE_URL`
* PlantUML base url
* Default value: `ROOT`
- `PLANTUML_LIMIT_SIZE`
* Limits image width and height
* Default value: `4096`
- `PLANTUML_STATS`
* Set it to `on` to enable [statistics report](http://plantuml.com/statistics-report)
* Default value: `off`
- `HTTP_AUTHORIZATION`
* when calling the `proxy` endpoint, the value of `HTTP_AUTHORIZATION` will be used to set the HTTP Authorization header
* Default value: `null`
- `ALLOW_PLANTUML_INCLUDE`
* Enables `!include` processing which can read files from the server into diagrams. Files are read relative to the current working directory.
* Default value: `false`
Alternate: How to build your docker image
======================================================

View File

@ -5,9 +5,9 @@ services:
build:
context: .
dockerfile: Dockerfile.jetty
args:
BASE_URL: plantuml
image: plantuml/plantuml-server:local
image: plantuml/plantuml-server:jetty-local
container_name: plantuml-server
ports:
- 8080:8080
- 8080:8080
environment:
- BASE_URL=plantuml

17
docker-entrypoint.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/sh
# cspell:words mkdir
# cspell:enableCompoundWords
###########################################################
# use environment variables
if [ "$BASE_URL" != "ROOT" ]; then
mkdir -p "$(dirname "$WEBAPP_PATH/$BASE_URL")"
mv "$WEBAPP_PATH/ROOT.war" "$WEBAPP_PATH/$BASE_URL.war"
fi
# base image entrypoint
if [ -x /docker-entrypoint.sh ]; then
/docker-entrypoint.sh "$@"
else
exec "$@"
fi