mirror of
https://github.com/octoleo/plantuml-server.git
synced 2024-12-22 08:48:54 +00:00
improve docker handling
This commit is contained in:
parent
5190a72cc8
commit
221af78afc
20
Dockerfile
20
Dockerfile
@ -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
|
|
@ -1,26 +1,33 @@
|
|||||||
FROM maven:3-jdk-11 AS builderjetty
|
FROM maven:3-jdk-11-slim AS builder
|
||||||
|
|
||||||
COPY pom.xml /app/
|
COPY pom.xml /app/
|
||||||
COPY src /app/src/
|
COPY src/main /app/src/main/
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN mvn --batch-mode --define java.net.useSystemProxies=true package
|
RUN mvn --batch-mode --define java.net.useSystemProxies=true package
|
||||||
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
|
|
||||||
FROM jetty:9.4-jre11
|
FROM jetty:9.4-jre11-slim
|
||||||
MAINTAINER D.Ducatel
|
|
||||||
|
|
||||||
USER root
|
USER root
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y --no-install-recommends graphviz fonts-noto-cjk && \
|
apt-get install -y --no-install-recommends \
|
||||||
rm -rf /var/lib/apt/lists/* \
|
fonts-noto-cjk \
|
||||||
|
graphviz \
|
||||||
|
&& \
|
||||||
|
rm -rf /var/lib/apt/lists/* && \
|
||||||
/generate-jetty-start.sh
|
/generate-jetty-start.sh
|
||||||
|
|
||||||
|
COPY docker-entrypoint.sh /entrypoint.sh
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
USER jetty
|
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
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
COPY --from=builderjetty /app/target/plantuml.war /var/lib/jetty/webapps/$BASE_URL.war
|
|
||||||
|
@ -1,43 +1,30 @@
|
|||||||
FROM maven:3-jdk-11 AS buildertomcat
|
FROM maven:3-jdk-11-slim AS builder
|
||||||
|
|
||||||
COPY pom.xml /app/
|
COPY pom.xml /app/
|
||||||
COPY src /app/src/
|
COPY src/main /app/src/main/
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN mvn --batch-mode --define java.net.useSystemProxies=true package
|
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
|
FROM tomcat:9.0-jdk11-openjdk-slim
|
||||||
MAINTAINER D.Ducatel
|
|
||||||
|
|
||||||
RUN apt-get update && \
|
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/*
|
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
|
ENV BASE_URL=ROOT \
|
||||||
RUN rm -rf /usr/local/tomcat/webapps/$BASE_URL
|
WEBAPP_PATH=$CATALINA_HOME/webapps
|
||||||
COPY --from=buildertomcat /app/target/plantuml.war /usr/local/tomcat/webapps/$BASE_URL.war
|
RUN rm -rf $WEBAPP_PATH && \
|
||||||
|
mkdir -p $WEBAPP_PATH
|
||||||
COPY --from=graphviz /root/install/usr/bin/dot /usr/bin/
|
COPY --from=builder /app/target/plantuml.war $WEBAPP_PATH/ROOT.war
|
||||||
COPY --from=graphviz /root/install/usr/lib/ /usr/lib/
|
|
||||||
|
|
||||||
RUN dot -c
|
|
||||||
|
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
CMD ["catalina.sh", "run"]
|
||||||
|
40
README.md
40
README.md
@ -57,12 +57,12 @@ This makes the container compatible with more restricted environment such as Ope
|
|||||||
## Change base URL
|
## Change base URL
|
||||||
|
|
||||||
To run plantuml using different base url, change the `docker-compose.yml` file:
|
To run plantuml using different base url, change the `docker-compose.yml` file:
|
||||||
~~~
|
```yaml
|
||||||
args:
|
environment:
|
||||||
BASE_URL: plantuml
|
- 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
|
the base url `/plantuml`, e.g. http://localhost/plantuml
|
||||||
|
|
||||||
How to set PlantUML options
|
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:
|
You can set all the following variables:
|
||||||
|
|
||||||
* `PLANTUML_LIMIT_SIZE`
|
- `BASE_URL`
|
||||||
* Limits image width and height
|
* PlantUML base url
|
||||||
* Default value: `4096`
|
* Default value: `ROOT`
|
||||||
* `GRAPHVIZ_DOT`
|
- `PLANTUML_LIMIT_SIZE`
|
||||||
* Link to 'dot' executable
|
* Limits image width and height
|
||||||
* Default value: `/usr/local/bin/dot` or `/usr/bin/dot`
|
* Default value: `4096`
|
||||||
* `PLANTUML_STATS`
|
- `PLANTUML_STATS`
|
||||||
* Set it to `on` to enable [statistics report](http://plantuml.com/statistics-report)
|
* Set it to `on` to enable [statistics report](http://plantuml.com/statistics-report)
|
||||||
* Default value: `off`
|
* Default value: `off`
|
||||||
* `HTTP_AUTHORIZATION`
|
- `HTTP_AUTHORIZATION`
|
||||||
* when calling the `proxy` endpoint, the value of `HTTP_AUTHORIZATION` will be used to set the HTTP Authorization header
|
* when calling the `proxy` endpoint, the value of `HTTP_AUTHORIZATION` will be used to set the HTTP Authorization header
|
||||||
* Default value: `null`
|
* Default value: `null`
|
||||||
* `ALLOW_PLANTUML_INCLUDE`
|
- `ALLOW_PLANTUML_INCLUDE`
|
||||||
* Enables `!include` processing which can read files from the server into diagrams. Files are read relative to the current working directory.
|
* Enables `!include` processing which can read files from the server into diagrams. Files are read relative to the current working directory.
|
||||||
* Default value: `false`
|
* Default value: `false`
|
||||||
|
|
||||||
Alternate: How to build your docker image
|
Alternate: How to build your docker image
|
||||||
======================================================
|
======================================================
|
||||||
|
@ -5,9 +5,9 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile.jetty
|
dockerfile: Dockerfile.jetty
|
||||||
args:
|
image: plantuml/plantuml-server:jetty-local
|
||||||
BASE_URL: plantuml
|
|
||||||
image: plantuml/plantuml-server:local
|
|
||||||
container_name: plantuml-server
|
container_name: plantuml-server
|
||||||
ports:
|
ports:
|
||||||
- 8080:8080
|
- 8080:8080
|
||||||
|
environment:
|
||||||
|
- BASE_URL=plantuml
|
||||||
|
17
docker-entrypoint.sh
Executable file
17
docker-entrypoint.sh
Executable 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
|
Loading…
Reference in New Issue
Block a user