ngs-doo / TemplaterExamples

Creating reports in .NET and Java
https://templater.info
The Unlicense
48 stars 27 forks source link

running TemplaterServer in docker container #52

Closed sergook closed 2 years ago

sergook commented 2 years ago

Hello!

I created and run docker container on windows 10 (WSL2) as suggested:

docker build -t templater .
docker run -p 7777:7777 --tmpfs /mnt/ramdisk -it templater -tmp=/mnt/ramdisk -log=INFO
PS D:\sergook\TemplaterExamples-master\Advanced\TemplaterServer> docker run -p 7777:7777 --tmpfs /mnt/ramdisk -it templater -tmp=/mnt/ramdisk -log=INFO
Running without examples since resource path is not found...
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at hr.ngs.templater.server.TemplaterServer.main(TemplaterServer.java:781)
Caused by: java.lang.RuntimeException: Unable to find LibreOffice on the system. Please explicitly specify it via: -libreoffice=/user/home/office/libreoffice
        at hr.ngs.templater.server.LibreOffice.<init>(LibreOffice.java:50)
        ... 5 more
Jul 20, 2022 2:15:33 PM hr.ngs.templater.server.TemplaterServer <init>
WARNING: No template files found
Jul 20, 2022 2:15:33 PM hr.ngs.templater.server.TemplaterServer <init>
WARNING: No template files found
Server started on port 7777, press Enter to stop ...

But the page on localhost:7777 isn't working. It shows: "This page isn’t working. localhost didn’t send any data. ERR_EMPTY_RESPONSE"

However http://localhost:7777/ works when running the following command in PowerShell:

PS D:\sergook\TemplaterServer> ls

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        20.07.2022     15:08                resources
-a----        20.07.2022     10:55        1793382 templater-server.jar
-a----        11.07.2022     23:36             29 templater.lic

PS D:\sergook\TemplaterServer> java -jar templater-server.jar
Example arguments:
    -port=8080
    -timeout=10
    -tmp=/mnt/ramdisk
    -log=INFO
    -plugins=/templater/jars
    -files=/templater/files
    -disable-exit
    -pdf=LibreOffice,Spire,Aspose
    -libreoffice=/user/home/office/libreoffice
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at hr.ngs.templater.server.TemplaterServer.main(TemplaterServer.java:781)
Caused by: java.lang.RuntimeException: Unable to find LibreOffice on the system. Please explicitly specify it via: -libreoffice=/user/home/office/libreoffice
        at hr.ngs.templater.server.LibreOffice.<init>(LibreOffice.java:50)
        ... 5 more
Server started on port 7777, press Enter to stop ...

I also eliminated all warning messages during image start:

  1. Slightly modified Dockerfile:
    FROM ubuntu:20.04
    ARG DEBIAN_FRONTEND=noninteractive
    ENV TZ=Europe/Zagreb
    RUN apt update && apt install openjdk-11-jre-headless libreoffice-common libreoffice-java-common libreoffice-writer libreoffice-calc wget -yq
    RUN wget -q https://github.com/ngs-doo/TemplaterExamples/releases/download/v7.1.0/templater-server.jar
    COPY templater.lic .
    COPY ./resources ./resources
    EXPOSE 7777
    ENTRYPOINT ["java", "-jar", "templater-server.jar"]
  2. Used the following command to run container:
    PS D:\sergook\TemplaterExamples-master\Advanced\TemplaterServer> docker run -p 7777:7777 --tmpfs /mnt/ramdisk -it templater -tmp=/mnt/ramdisk -log=INFO -libreoffice=/usr/lib/libreoffice
    Server started on port 7777, press Enter to stop ...

But still the page isn't working. Is any idea how to solve the problem? Thanks!

zapov commented 2 years ago

Tnx for the report. I wasn't aware this stopped working.

It seems Docker does not want to connect to loop-back address so I added additional argument and passed it around. It should work now on master.

sergook commented 2 years ago

Thank you! It works now!