From 963f0d266b823b244ba4e7a70063e659b03f557d Mon Sep 17 00:00:00 2001 From: Dilee Kumar Paladugu Date: Wed, 18 Dec 2024 10:06:24 +0100 Subject: [PATCH 1/4] drawio application image using alpine as base --- Dockerfile | 37 +++++++++++++++++++++++++++++++- root-fs/usr/local/bin/startup.sh | 10 +++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 root-fs/usr/local/bin/startup.sh diff --git a/Dockerfile b/Dockerfile index d09a9bb..2458bcd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1 +1,36 @@ -FROM jgraph/drawio:latest \ No newline at end of file +FROM alpine:3.20.3 AS builder + +ARG SHA256SUM_1=f799541380bfff2b674cefd86c5376d2d7d566b3a2e7c4579d2b491de8ec6c36 +ARG SHA256SUM_2=89417f1e6e0b1498ea22d7ebb9ec3bed126719c0a1b9a1cb76ac31020027e6ee + +RUN apk add --no-cache wget tar \ + && wget https://archive.apache.org/dist/tomcat/tomcat-10/v10.1.34/bin/apache-tomcat-10.1.34.tar.gz \ + && echo "$SHA256SUM_1 apache-tomcat-10.1.34.tar.gz" | sha256sum -c - \ + && mkdir -p /opt/tomcat \ + && tar xzf apache-tomcat-10.1.34.tar.gz -C /opt/tomcat --strip-components 1 \ + && rm apache-tomcat-10.1.34.tar.gz + +RUN wget https://github.com/jgraph/drawio/releases/download/v24.7.17/draw.war \ + && echo "$SHA256SUM_2 draw.war" | sha256sum -c - \ + && unzip draw.war /opt/tomcat/webapps/_diagram \ + && rm -rf draw.war + + +FROM alpine:3.20.3 + +ENV JAVA_OPTS="-Xverify:none" + +ARG USER=tomcat +ARG UID=1000 +ARG GROUPNAME=tomcat +RUN apk add openjdk21 +COPY --from=builder /opt/tomcat /opt/tomcat +COPY ./root-fs/usr/local/bin/startup.sh /usr/local/bin/ +RUN addgroup -g $UID $GROUPNAME \ + && adduser -G $GROUPNAME -u $UID --disabled-password --gecos "" $USER \ + && chown -R tomcat:tomcat /opt/tomcat \ + && chmod +x /usr/local/bin/startup.sh + +EXPOSE 8080 +USER $USER +ENTRYPOINT [ "/usr/local/bin/startup.sh" ] diff --git a/root-fs/usr/local/bin/startup.sh b/root-fs/usr/local/bin/startup.sh new file mode 100644 index 0000000..c1a5dc8 --- /dev/null +++ b/root-fs/usr/local/bin/startup.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +set -o errexit +set -o nounset +set -o pipefail + +exec /opt/tomcat/bin/catalina.sh run + + + From 29573de6c62146b078665ef322705eda5f15d053 Mon Sep 17 00:00:00 2001 From: Dilee Kumar Paladugu Date: Wed, 18 Dec 2024 10:11:30 +0100 Subject: [PATCH 2/4] Add ARG for user --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 2458bcd..b0368a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,3 +34,4 @@ RUN addgroup -g $UID $GROUPNAME \ EXPOSE 8080 USER $USER ENTRYPOINT [ "/usr/local/bin/startup.sh" ] + From 2f1a648011f9ce3b7f1a60630e14b28a83f3ce43 Mon Sep 17 00:00:00 2001 From: Dilee Kumar Paladugu Date: Wed, 18 Dec 2024 10:48:38 +0100 Subject: [PATCH 3/4] Improvements to the docker file. --- Dockerfile | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index b0368a6..88e1812 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ -FROM alpine:3.20.3 AS builder +ARG BASE_IMAGE=alpine:3.20.3 + +FROM $BASE_IMAGE AS builder ARG SHA256SUM_1=f799541380bfff2b674cefd86c5376d2d7d566b3a2e7c4579d2b491de8ec6c36 ARG SHA256SUM_2=89417f1e6e0b1498ea22d7ebb9ec3bed126719c0a1b9a1cb76ac31020027e6ee @@ -16,22 +18,22 @@ RUN wget https://github.com/jgraph/drawio/releases/download/v24.7.17/draw.war \ && rm -rf draw.war -FROM alpine:3.20.3 - -ENV JAVA_OPTS="-Xverify:none" +FROM $BASE_IMAGE AS main -ARG USER=tomcat +ARG JAVA_OPTS="-Xverify:none" +ENV JAVA_OPTS=$JAVA_OPTS +ENV USER=tomcat ARG UID=1000 -ARG GROUPNAME=tomcat -RUN apk add openjdk21 -COPY --from=builder /opt/tomcat /opt/tomcat +ENV UID=$UID + COPY ./root-fs/usr/local/bin/startup.sh /usr/local/bin/ -RUN addgroup -g $UID $GROUPNAME \ - && adduser -G $GROUPNAME -u $UID --disabled-password --gecos "" $USER \ - && chown -R tomcat:tomcat /opt/tomcat \ + +RUN apk add --no-cache openjdk21 \ + && addgroup -g $UID $USER \ + && adduser -G $USER -u $UID --disabled-password --gecos "" $USER \ && chmod +x /usr/local/bin/startup.sh +COPY --from=builder --chown=tomcat:tomcat /opt/tomcat /opt/tomcat EXPOSE 8080 USER $USER -ENTRYPOINT [ "/usr/local/bin/startup.sh" ] - +ENTRYPOINT [ "/usr/local/bin/startup.sh" ] \ No newline at end of file From bafad45cecc3e8c628c1489cba75c05c4f698aad Mon Sep 17 00:00:00 2001 From: Dilee Kumar Paladugu Date: Fri, 17 Jan 2025 16:40:53 +0100 Subject: [PATCH 4/4] update unzip command --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 88e1812..5ce66de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ RUN apk add --no-cache wget tar \ RUN wget https://github.com/jgraph/drawio/releases/download/v24.7.17/draw.war \ && echo "$SHA256SUM_2 draw.war" | sha256sum -c - \ - && unzip draw.war /opt/tomcat/webapps/_diagram \ + && unzip draw.war -d /opt/tomcat/webapps/_diagram \ && rm -rf draw.war