I want to create a Dockerfile for launching jsreport as a package in my Node.js package.



  • Hi,

    I want to create a Dockerfile for launching jsreport as a package in my Node.js package. Currently, it is throwing errors like not able to launch the chrome browser.
    Please provide a quick help.

    Thanks


  • administrators

    hi! if you are creating your image from scratch and copy/paste the steps from our docker file it is normal that you had issues with chrome. why? because the chrome it is a bit special to download, there are some online binaries that only work for some time and after that, they disappear. this means that when you build a container at some time it means that it can download and have everything ok but if you try to rebuild or create a new image with the same steps it in the future it may fail because the same chrome binaries are probably gone from the internet. please share the docker file you are trying to build and also the error message you have



  • Hi,

    I have enclosed jsreport as a package in node project. I have attached jsreport to existing express app like follows.

    const express = require('express');
    const app = express();

    app.get('/', (req, res) => {
    res.send('Hello from the main application');
    });

    const reportingApp = express();
    app.use('/reporting', reportingApp);

    const server = app.listen(3000);

    const jsreport = require('jsreport')({
    extensions: {
    express: { app: reportingApp, server: server },
    },
    appPath: "/reporting"
    });

    jsreport.init().then(() => {
    console.log('jsreport server started')
    }).catch((e) => {
    console.error(e);
    });

    Following is the docker code.

    FROM node:12
    WORKDIR src/app
    COPY package*.json ./
    RUN npm install
    COPY . .
    EXPOSE 3003
    CMD [ "npm", "start" ]

    Please help me to fix it.


  • administrators

    i see, for a moment i was thinking that you were using our same steps (in dockerfile) to build your image.. as I said, building chrome is a bit special, the best for you will be to follow this.

    so in the end you dockerfile can be something like this.

    FROM jsreport/jsreport:2.10.0
    WORKDIR src/app
    COPY --chown=jsreport:jsreport package*.json ./
    RUN npm install
    COPY --chown=jsreport:jsreport . .
    EXPOSE 3003
    CMD [ "npm", "start" ]
    


  • Hi,

    I have package.json in the project with some dependencies to be installed, how to include it?

    Can you please include that also in the above docker file so that we can try and let u know.

    Thanks,

    Surya Prakash


  • administrators

    the steps i described above should copy your package.json and install the modules in your package.json, take a deep look, it is almost the same file just with some lines modified.

    if you hit any error let me know.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.