jgraph / docker-drawio

Dockerized draw.io based on whichever is the most secure image at the time.
GNU General Public License v3.0
1.48k stars 359 forks source link

Docker linux/arm/v7 support ? #154

Closed Blasci closed 1 month ago

Blasci commented 6 months ago

Hello,

Are you considering porting a Docker drawio image compatible with linux/arm/v7 (Raspberry Pi) ?

Best regards

welyfun commented 3 months ago

I tried to build this image with linux/arm/v7. But there were some problems.

I changed FROM openjdk:11-jdk-slim AS build to FROM openjdk:11-ea-11-jdk-slim AS build in the first line to support armv7 and run build.

Then I meet this problem.

image

It seemed like the public key was not added. But when I tried to add it or delete apt-get update -y, it still didn't work.

welyfun commented 3 months ago

I have solved this problem and built an arm/v7 version, which run on my arm/v7 platform successfully.

I pushed it at https://hub.docker.com/r/welywely/drawio

Anyone can use the arm/v7 version with docker pull welywely/drawio

How can I build the arm/v7 version

I tried to change FROM openjdk:11-jdk-slim AS build to FROM adoptopenjdk/openjdk11:armv7l-debianslim-jdk-11.0.23_9-slim AS build in the first line to support armv7 and run build.

Then I meet this error.

Buildfile: /tmp/drawio/etc/build/build.xml

merge:
[jscomp] Compiling 1 file(s) with 112 extern(s)
#
# A fatal error has been detected by the Java Runtime Environment:
#
#SIGBUS (0x7) at pc=0x413ee354, pid=28, tid=101
#
# JRE version: OpenJDK Runtime Environment Temurin-11.0.23+9 (11.0.23+9) (build 11.0.23+9)
# Java VM: OpenJDK Server VM Temurin-11.0.23+9 (11.0.23+9, mixed mode, g1 gc, linux-)
# Problematic frame:
#V[libjvm.so+0xa63354]
#
#No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /tmp/drawio/etc/build/hs_err_pid28.log
#
# If you would like to submit a bug report, please visit:
#   https://github.com/adoptium/adoptium-support/issues
#
qemu: uncaught target signal 6 (Aborted) - core dumped
Aborted

I tried other similar images, but no one worked.

Solution

Run the following command outside the docker to get the draw.war, which means run in the system directly.

git clone --depth 1 https://github.com/jgraph/drawio.git
cd drawio/etc/build/
ant war

Copy the draw.war at drawio/build/draw.war to docker-drawio-dev/main/, which is the same contents with Dockerfile.

Then change COPY --from=build /tmp/drawio/build/draw.war /tmp to COPY draw.war /tmp in the Dockerfile and delete the command line before FROM tomcat:9-jre11.

Now the Dockerfile only has these commands.

FROM tomcat:9-jre11

LABEL maintainer="JGraph Ltd" \
      org.opencontainers.image.authors="JGraph Ltd" \
      org.opencontainers.image.url="https://www.drawio.com" \
      org.opencontainers.image.source="https://github.com/jgraph/docker-drawio"

ENV RUN_USER            tomcat
ENV RUN_GROUP           tomcat

RUN apt-get update -y && \
    apt-get install -y --no-install-recommends \
        certbot \
        curl \
        xmlstarlet \
        unzip && \
    apt-get autoremove -y --purge && \
    apt-get clean && \
    rm -r /var/lib/apt/lists/*

COPY 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' \
        conf/server.xml

# Copy docker-entrypoint
COPY docker-entrypoint.sh /
RUN chmod 755 /docker-entrypoint.sh
# Add a tomcat user
RUN groupadd -r ${RUN_GROUP} && useradd -g ${RUN_GROUP} -d ${CATALINA_HOME} -s /bin/bash ${RUN_USER} && \
    chown -R ${RUN_USER}:${RUN_GROUP} ${CATALINA_HOME}

USER ${RUN_USER}

WORKDIR $CATALINA_HOME

EXPOSE 8080 8443

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["catalina.sh", "run"]

Now you can build the arm/v7 version with docker build --platform linux/arm/v7 -t welywely/drawio:latest --push .

Blasci commented 3 months ago

Amazing ! Thank you so much.

Great job