Single Exe file not working in docker



  • Docker file

    FROM alpine:3.7
    
    # https://dev.to/setevoy/docker-configure-tzdata-and-timezone-during-build-20bk
    RUN ln -snf /usr/share/zoneinfo/Europe/London /etc/localtime && echo Europe/London > /etc/timezone
    
    # https://jsreport.net/learn/dotnet-local#docker
    RUN apt-get update && apt-get install -y --no-install-recommends libgconf-2-4 gnupg git curl wget ca-certificates && \
        wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
        sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
        apt-get update && \
        apt-get install -y lsb-release google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst libxtst6 libxss1 --no-install-recommends && \
        apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 \
        libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 \
        libxrender1 ca-certificates fonts-liberation libappindicator1 libnss3 xdg-utils
    
    ENV chrome_launchOptions_executablePath google-chrome-stable
    ENV chrome_launchOptions_args --no-sandbox,--disable-dev-shm-usage,--single-process,--no-zygote
    
    RUN mkdir -p /unmanaged/bin/jsreport && curl -fsSL https://github.com/jsreport/jsreport/releases/download/2.11.0/jsreport-linux.tar.gz | tar zxC /unmanaged/bin/jsreport
    ENV JSREPORT_EXEC="/unmanaged/bin/jsreport/jsreport"
    
    ADD jsreport /unmanaged/bin/jsreport
    
    ADD in/ /unmanaged/bin/tomcat/webapps/ROOT/
    
    
    
    
    

    java file: we are trying to execute the command by java program and the template name will sent by client side.

    private boolean excuteCommand(java.nio.file.Path parentPath, String templateName, String nodeId) {
    		
    		String mTemplatePath = Paths.get( parentPath.toString(), "input", "template", templateName+".html").toString();
    		String mDataPath = Paths.get( parentPath.toString(), "input", "data", nodeId+".json").toString();
    		String mOutputPath =  Paths.get( parentPath.toString(),"output",  nodeId+".pdf").toString();
    		
    		final String templatePath=String.format("--template.content=%s", mTemplatePath);
    		final String dataPath=String.format("--data=%s",mDataPath);
    		final String outputPath= String.format("--out=%s", mOutputPath);
    		
    		try {
    			String outputString = new ProcessExecutor()
    					.command(jsReport, "render", "--template.engine=ejs", "--template.recipe=chrome-pdf", templatePath, dataPath, outputPath)
    					.directory(parentPath.toFile())
    					.readOutput(true)
    					.execute()
    					.outputString();		
    			logger.info("Output of the command: {}", outputString);
    			
    			return Files.exists(Paths.get(mOutputPath));
    			
    			
    		} catch (Exception e) {
    			logger.error("Exception while executing command:", e);
    			return false;
    		} 
    	
    	}
    


  • You seem you use FROM alpine:3.7 but alpine doesn't have apt-get which you use later. So it seems this isn't a valid dockerfile that you've shared. What am I missing?



  • #!/bin/bash -e
    
    pushd "$(dirname "$0")"
    
    version=$(cat version)
    fversion=v${version}
    base_version=$(cat base_version)
    
    cat <<EOF > Dockerfile
    
    FROM xxxxxxxxxx.dkr.ecr.us-west-2.amazonaws.com/${base_version}
    
    # https://dev.to/setevoy/docker-configure-tzdata-and-timezone-during-build-20bk
    RUN ln -snf /usr/share/zoneinfo/Europe/London /etc/localtime && echo Europe/London > /etc/timezone
    
    # https://jsreport.net/learn/dotnet-local#docker
    RUN apt-get update && apt-get install -y --no-install-recommends libgconf-2-4 gnupg git curl wget ca-certificates && \
        wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
        sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
        apt-get update && \
        apt-get install -y lsb-release google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst libxtst6 libxss1 --no-install-recommends && \
        apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 \
        libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 \
        libxrender1 ca-certificates fonts-liberation libappindicator1 libnss3 xdg-utils
    
    ENV chrome_launchOptions_executablePath google-chrome-stable
    ENV chrome_launchOptions_args --no-sandbox,--disable-dev-shm-usage,--single-process,--no-zygote
    
    RUN mkdir -p /unmanaged/bin/jsreport && curl -fsSL https://github.com/jsreport/jsreport/releases/download/2.11.0/jsreport-linux.tar.gz | tar zxC /unmanaged/bin/jsreport
    ENV JSREPORT_EXEC="/unmanaged/bin/jsreport/jsreport"
    
    ADD jsreport /unmanaged/bin/jsreport
    
    ADD in/ /unmanaged/bin/tomcat/webapps/ROOT/
    
    EOF
    
    tar -czh . | docker build -t esko/services/xxxxx:"${fversion}" --rm=true -
    

    popd



  • This is the docker file we are using and the java code is shared by sneka. the error is

    Output of the command: (node:897) UnhandledPromiseRejectionWarning: Error: EFAULT: bad address in system call argument, read
    

    (node:897) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
    (node:897) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

    Can we use process.unhandledRejections = 'warn' Or 'none' to supress this error in Java Code? Or any other solution can you provide???



  • Unfortunately, still, this isn't something I could use to replicate the error.
    I would need a complete dockerfile I could use to build the image and let's say a particular command-line command to call inside.

    I tried to search the error EFAULT: bad address and found a mention here

    I managed to trace this to the exact line of V8 which fails, wrote a small C program which exhibits the same behavior, and the issue is indeed copying files between different hard drives or partitions. This should be handled properly by V8, so the bug is actually on their side.

    Maybe you can try to install jsreport from npm and avoid using the compiled exe, because it brings an extra layer with a potential problem.



  • Thanks for the suggestion. I will try with npm installation.
    We need this jsreport as part of our application( which is Docker) or can run as exe but not as another service. Because if it is another service it might require another docker to setup.
    Is jsreport cli (npm install -g jsreport-cli )can be installed on Docker or linux OS and run using command prompt similar to single executable.



  • You can do the following in the dockerfike

    npm install -g jsreport-cli
    jsreport init
    

    And in the app container use cmd cli

    jsreport render ...
    


  • Hi Blaha, am able to install on docker . It worked on dev but not working on staging machine.
    wanted to check log and error details. But it is not logging when executed through cli. Is there any thing missed. Config file has logger details.



  • WORKDIR /unmanaged/bin/jsreport
    RUN apt-get update && apt install -y npm && npm install -g jsreport-cli
    RUN npm install && jsreport init
    COPY jsreport/jsreport.config.json /unmanaged/bin/jsreport

    As we need to have our own config file, we are copying that in the end. But its still not working in dev environment but local docker which generated with dev image is working. its even not generating an error log nor launching jsreport cmd process? we are launching a cmd process for every call from a restapi closing once the creation happend. and also collecting console log from the process and writing into our log. even that also having an empty output. will you tell us any ways to debug jsreport and get logs



  • Hi jan,

    We figured out the issues were likely caused by running out of memory on EC2 cluster and after increasing it single executable is working fine. Thanks for the support you provided.


Log in to reply
 

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