1
0
mirror of https://github.com/octoleo/plantuml-server.git synced 2024-06-03 17:10:48 +00:00
plantuml-server/Dockerfile.tomcat
Florian a6e69b33eb docker: use always latest Graphviz release
This will change the Graphviz behaviour inside the docker container.
Until now it was always a fixed Graphviz version inside the Dockerfile.
With these changes the docker container will always use the latest Graphviz release if the version was not manually set via the docker build argument `GRAPHVIZ_VERSION`.

If not set as build arg fetch latest version of Graphviz based on their release name by default.
An alternative would be to use `tag_name`.

Also, to avoid the overhead of getting all kinds of relase data, GitLabs GraphQL interface could be used.
```bash
curl -s \
  -H "Content-Type:application/json" \
  -d '{"query": "{project(fullPath:\"graphviz/graphviz\"){releases(first:5,sort:RELEASED_AT_DESC){nodes{name}}}}"}' \
  "https://gitlab.com/api/graphql" \
| jq -r '.data.project.releases.nodes[].name' | sort -V -r | head -n 1
```
In GraphQL the alternative to `name` would be `tagName`.
2023-05-09 09:34:27 +02:00

66 lines
2.1 KiB
Docker

FROM maven:3-eclipse-temurin-11 AS builder
COPY pom.xml /app/
COPY src/main /app/src/main/
WORKDIR /app
RUN mvn --batch-mode --define java.net.useSystemProxies=true -Dapache-jsp.scope=compile package
########################################################################################
FROM tomcat:10-jdk11
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
fonts-noto-cjk \
libgd3 \
&& \
rm -rf /var/lib/apt/lists/*
# Build Graphviz from source because there are no binary distributions for recent versions
ARG GRAPHVIZ_VERSION
ARG GRAPHVIZ_BUILD_DIR=/tmp/graphiz-build
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
jq \
libexpat1-dev \
libgd-dev \
zlib1g-dev \
&& \
mkdir -p $GRAPHVIZ_BUILD_DIR && \
cd $GRAPHVIZ_BUILD_DIR && \
GRAPHVIZ_VERSION=${GRAPHVIZ_VERSION:-$(curl -s https://gitlab.com/api/v4/projects/4207231/releases/ | jq -r '.[] | .name' | sort -V -r | head -1)} && \
curl -o graphviz.tar.gz https://gitlab.com/api/v4/projects/4207231/packages/generic/graphviz-releases/${GRAPHVIZ_VERSION}/graphviz-${GRAPHVIZ_VERSION}.tar.gz && \
tar -xzf graphviz.tar.gz && \
cd graphviz-$GRAPHVIZ_VERSION && \
./configure && \
make && \
make install && \
apt-get remove -y \
build-essential \
jq \
libexpat1-dev \
libgd-dev \
zlib1g-dev \
&& \
apt-get autoremove -y && \
apt-get clean & \
rm -rf /var/lib/apt/lists/* && \
rm -rf $GRAPHVIZ_BUILD_DIR
COPY docker-entrypoint.tomcat.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENV WEBAPP_PATH=$CATALINA_HOME/webapps
RUN rm -rf $WEBAPP_PATH && \
mkdir -p $WEBAPP_PATH
COPY --from=builder /app/target/plantuml.war /plantuml.war
# Openshift https://docs.openshift.com/container-platform/4.9/openshift_images/create-images.html#images-create-guide-openshift_create-images
RUN chgrp -R 0 $CATALINA_HOME && chmod -R g=u $CATALINA_HOME
ENTRYPOINT ["/entrypoint.sh"]
CMD ["catalina.sh", "run"]