Best way to host jsreport?
-
I have my servers at AWS.
Most of them runs at Fargate. I also have my jsreport at Fargate, which has been fine up until now.I just managed to crash the jsreport server. ECS restarted the server as it should, but since Fargate cannot have mounted disks the restarted server had no templates. I had to import them from source-control again. Lucky me to discover this blunder before going into production.
What would be the best/easiest way to solve this?
- Move jsreport to an EC2 instance with mounted disk
- Move template storage to Postgres
- Other options?
-
I would rather stay at Fargate, but there is no way of mounting persistent volumes at Fargate. On every restart I get a new ephemeral volume to which I can import my templates (currently using the manual import function in Studio).
Would the following scenario be possible?
- I keep a full export (zip file) from jsreport in a GitHub repo
- A startup script at the jsreport server automatically pulls the zip file and makes a "full import"
I'm using the official Docker image (2.6), and would like to keep it this way if possible. I.e. I don't want to package my own node/jsreport server if I don't have to.
-
Just some thoughts from me...
You should primary decide if you want to edit the templates in production in real-time or you want to deploy to production final packages.Deploying final packages
It means you prepare your templates in dev, test them on UAT and deploy to the production image/package with templates inside it.
You would treat jsreport templates the same as any other source code and do the image deploy once per some weeks based on your release cycle.
This way you can keep using Fargate or even just AWS Lambda.Editing templates in real-time
This way you need a persistent jsreport template store.
It can be attached disk, aws s3, mongo, sql. It is up to you what you choose.
The s3 will be the cheapest but the slowest, the disk needs ec2... every option has pros and cons.
-
I'm fine with option one for now.
All reports are developed locally in a docker-compose environment with dev-versions of all AWS servers, including the jsreport image which I deploy to Fargate.What would be the easiest way to package this image?
While working in dev-environment the templates are stored on a mounted volume which is also version controlled with Git. This way I can work with the reports locally in Studio and still store the templates safely outside of the Docker image.
- Do I need to copy the templates into the image when I build the production image (i.e. have a different Dockerfile for prod vs dev)?
- Or can I make the prod server automatically import the templates at startup?
-
Yes, I would copy the templates into the image using your dockerfile.
Prod server can at the startup load templates from the aws s3 for example. However, that is the second option.
With the first one, you are always sure what you have on the production because of image tag.
You can easily switch back to the previous version when there is an error for example.
-
Thanks, I'm not quite sure of what goes where..
Normally, there is only one Dockerfile. This file is used both for production building and for building dev-images. But I run the dev images via docker-compose which also mounts a local folder.
If my Dockerfile looks like this:
FROM jsreport/jsreport:2.6.0 COPY license-key.txt /app COPY ./mounted/jsreport.config.json /app COPY ./mounted/data /app/data
And my docker-compose looks like this:
jsreport: build: context: ../services/jsreport environment: - mode=development expose: - '5488' ports: - '5488:5488' volumes: - '../services/jsreport/mounted:/jsreport'
What template files will jsreport use while I'm in my local dev environment?
- The static copy in /app/data inside the image?
- Or the mounted folder on my local machine, i.e. mounted as
/jsreport
?
And now when I compare the files, I do wonder: How can jsreport find my mounted volume when its mounted as
/jsreport
? It seems that jsreport actually wants this volume to be/app/data