Skip to content

Commit

Permalink
Merge pull request jgraph#4 from krufab/DockerfileWithBuildStage
Browse files Browse the repository at this point in the history
Refactored Dockerfiles to use multi-stage builds
  • Loading branch information
m-mohamedin authored Feb 15, 2020
2 parents 6b3d455 + 518ffd8 commit 017374b
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 48 deletions.
60 changes: 35 additions & 25 deletions alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,43 @@
FROM openjdk:8-alpine AS build

RUN apk update --no-cache && \
apk add --no-cache \
apache-ant \
git

RUN cd /tmp && \
git clone https://github.com/jgraph/drawio.git && \
cd /tmp/drawio/etc/build/ && \
ant war

FROM tomcat:9-jre8-alpine

LABEL maintainer="JGraph Ltd"

RUN apk add \
openjdk8 apache-ant git patch xmlstarlet certbot curl && \
cd /tmp && \
git clone https://github.com/jgraph/drawio.git && \
cd /tmp/drawio/etc/build && \
ant war && \
cd /tmp/drawio/build && \
mkdir -p $CATALINA_HOME/webapps/draw && \
unzip /tmp/drawio/build/draw.war -d $CATALINA_HOME/webapps/draw && \
apk del --purge openjdk8 apache-ant git patch && \
rm -rf \
/tmp/drawio

# Update server.xml to set Draw.io webapp to root
RUN cd $CATALINA_HOME && \
RUN apk update --no-cache && \
apk add --no-cache \
certbot \
curl \
xmlstarlet

COPY --from=build /tmp/drawio/build/draw.war /tmp

# Extract draw.io war & Update server.xml to set Draw.io webapp to root
RUN mkdir -p $CATALINA_HOME/webapps/draw && \
unzip /tmp/draw.war -d $CATALINA_HOME/webapps/draw && \
rm -rf /tmp/draw.war /tmp/drawio && \
cd $CATALINA_HOME && \
xmlstarlet ed \
-P -S -L \
-i '/Server/Service/Engine/Host/Valve' -t 'elem' -n 'Context' \
-i '/Server/Service/Engine/Host/Context' -t 'attr' -n 'path' -v '/' \
-i '/Server/Service/Engine/Host/Context[@path="/"]' -t 'attr' -n 'docBase' -v 'draw' \
-s '/Server/Service/Engine/Host/Context[@path="/"]' -t 'elem' -n 'WatchedResource' -v 'WEB-INF/web.xml' \
-i '/Server/Service/Engine/Host/Valve' -t 'elem' -n 'Context' \
-i '/Server/Service/Engine/Host/Context[not(@path="/")]' -t 'attr' -n 'path' -v '/ROOT' \
-s '/Server/Service/Engine/Host/Context[@path="/ROOT"]' -t 'attr' -n 'docBase' -v 'ROOT' \
-s '/Server/Service/Engine/Host/Context[@path="/ROOT"]' -t 'elem' -n 'WatchedResource' -v 'WEB-INF/web.xml' \
conf/server.xml
-P -S -L \
-i '/Server/Service/Engine/Host/Valve' -t 'elem' -n 'Context' \
-i '/Server/Service/Engine/Host/Context' -t 'attr' -n 'path' -v '/' \
-i '/Server/Service/Engine/Host/Context[@path="/"]' -t 'attr' -n 'docBase' -v 'draw' \
-s '/Server/Service/Engine/Host/Context[@path="/"]' -t 'elem' -n 'WatchedResource' -v 'WEB-INF/web.xml' \
-i '/Server/Service/Engine/Host/Valve' -t 'elem' -n 'Context' \
-i '/Server/Service/Engine/Host/Context[not(@path="/")]' -t 'attr' -n 'path' -v '/ROOT' \
-s '/Server/Service/Engine/Host/Context[@path="/ROOT"]' -t 'attr' -n 'docBase' -v 'ROOT' \
-s '/Server/Service/Engine/Host/Context[@path="/ROOT"]' -t 'elem' -n 'WatchedResource' -v 'WEB-INF/web.xml' \
conf/server.xml

# Copy draw.io config files
COPY PreConfig.js PostConfig.js $CATALINA_HOME/webapps/draw/js/
Expand Down
Empty file modified alpine/docker-entrypoint.sh
100644 → 100755
Empty file.
59 changes: 36 additions & 23 deletions debian/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,49 @@
FROM openjdk:11-jdk-slim AS build

RUN apt-get update -y && \
# this solves some weird issue with openjdk-11-jdk-headless
# https://github.com/nextcloud/docker/issues/380
mkdir -p /usr/share/man/man1mkdir -p /usr/share/man/man1 && \
apt-get install -y \
ant \
git

RUN cd /tmp && \
git clone https://github.com/jgraph/drawio.git && \
cd /tmp/drawio/etc/build/ && \
ant war

FROM tomcat:9-jre11-slim

LABEL maintainer="JGraph Ltd"

RUN apt-get update -y && \
apt-get install -y --no-install-recommends \
openjdk-11-jdk-headless ant git patch wget xmlstarlet certbot curl && \
cd /tmp && \
git clone https://github.com/jgraph/drawio.git && \
cd /tmp/drawio/etc/build && \
ant war && \
cd /tmp/drawio/build && \
unzip /tmp/drawio/build/draw.war -d $CATALINA_HOME/webapps/draw && \
apt-get remove -y --purge openjdk-11-jdk-headless ant git patch wget && \
certbot \
curl \
xmlstarlet && \
apt-get autoremove -y --purge && \
apt-get clean && \
rm -r /var/lib/apt/lists/* && \
rm -rf \
/tmp/drawio
rm -r /var/lib/apt/lists/*

COPY --from=build /tmp/drawio/build/draw.war /tmp

# Update server.xml to set Draw.io webapp to root
RUN cd $CATALINA_HOME && \
# Extract draw.io war & Update server.xml to set Draw.io webapp to root
RUN mkdir -p $CATALINA_HOME/webapps/draw && \
unzip /tmp/draw.war -d $CATALINA_HOME/webapps/draw && \
rm -rf /tmp/draw.war /tmp/drawio && \
cd $CATALINA_HOME && \
xmlstarlet ed \
-P -S -L \
-i '/Server/Service/Engine/Host/Valve' -t 'elem' -n 'Context' \
-i '/Server/Service/Engine/Host/Context' -t 'attr' -n 'path' -v '/' \
-i '/Server/Service/Engine/Host/Context[@path="/"]' -t 'attr' -n 'docBase' -v 'draw' \
-s '/Server/Service/Engine/Host/Context[@path="/"]' -t 'elem' -n 'WatchedResource' -v 'WEB-INF/web.xml' \
-i '/Server/Service/Engine/Host/Valve' -t 'elem' -n 'Context' \
-i '/Server/Service/Engine/Host/Context[not(@path="/")]' -t 'attr' -n 'path' -v '/ROOT' \
-s '/Server/Service/Engine/Host/Context[@path="/ROOT"]' -t 'attr' -n 'docBase' -v 'ROOT' \
-s '/Server/Service/Engine/Host/Context[@path="/ROOT"]' -t 'elem' -n 'WatchedResource' -v 'WEB-INF/web.xml' \
conf/server.xml
-P -S -L \
-i '/Server/Service/Engine/Host/Valve' -t 'elem' -n 'Context' \
-i '/Server/Service/Engine/Host/Context' -t 'attr' -n 'path' -v '/' \
-i '/Server/Service/Engine/Host/Context[@path="/"]' -t 'attr' -n 'docBase' -v 'draw' \
-s '/Server/Service/Engine/Host/Context[@path="/"]' -t 'elem' -n 'WatchedResource' -v 'WEB-INF/web.xml' \
-i '/Server/Service/Engine/Host/Valve' -t 'elem' -n 'Context' \
-i '/Server/Service/Engine/Host/Context[not(@path="/")]' -t 'attr' -n 'path' -v '/ROOT' \
-s '/Server/Service/Engine/Host/Context[@path="/ROOT"]' -t 'attr' -n 'docBase' -v 'ROOT' \
-s '/Server/Service/Engine/Host/Context[@path="/ROOT"]' -t 'elem' -n 'WatchedResource' -v 'WEB-INF/web.xml' \
conf/server.xml

# Copy draw.io config files
COPY PreConfig.js PostConfig.js $CATALINA_HOME/webapps/draw/js/
Expand Down
Empty file modified debian/docker-entrypoint.sh
100644 → 100755
Empty file.

0 comments on commit 017374b

Please sign in to comment.