JSReport Docker Container not writing to data folder

165 Views Asked by At

I have been trying to create a docker image of Jsreport that persists even after it is stopped. However, no matter what I try, templates and work done in the portal that the image is running does not save to the data directory.

I have tried running the image and mounting the data directory that it is stored in

docker run -p 5483:5483 -v /mydata:/DOCKERJSREPORT/data jsreport-container

I have tried adding the property "Storage Path" In the Store Object of the config file:

"store": {
      "provider": "fs",
      "storagePath": "/DOCKERJSREPORT/data"
    },

And I have tried adding JSREPORT as a USER in my docker file:

USER jsreport

It runs with these and even loads all the stored custom templates from the data directory, but does not save or persist new ones. I'm at a lost please help!

Here is my full DockerFile in case it's needed:

FROM jsreport/jsreport:3.13.0

USER jsreport

COPY --chown=jsreport:jsreport jsreport.config.json /app
COPY --chown=jsreport:jsreport /data /app/data

RUN npm install handlebars-intl --save

this is what my hierarchy looks like:

hierarchy

1

There are 1 best solutions below

2
BJR Matos On

the straight way to make it persist the data is mounting a volume that targets /app/data. there is no need to modify the configuration store.provider. storagePath (unless you want a different location inside the container), also no need that you copy manually the data folder on the Dockerfile.

the steps that work are the following:

  • Dockerfile
    FROM jsreport/jsreport:3.13.0
    COPY --chown=jsreport:jsreport jsreport.config.json /app
    RUN npm install handlebars-intl --save
  • build your custom docker image as usual, with a command like this (assuming your working directory when running this command is your DOCKERJSREPORT project)
    docker build . -t custom-jsreport-3.13.0
  • run the image (assuming your working directory when running this command is your DOCKERJSREPORT project)
docker run -p 5488:5488 -v ./data:/app/data custom-jsreport-3.13.0