I am using OS-Windows 11 Enterprice
, NodeJS 14.0.0
, NPM 6.14.4
and Highchart exprot server 2.1.0
Trying to generate/export static images through the docker.
Docker File:
# Getting image from node
FROM node:carbon
ENV ACCEPT_HIGHCHARTS_LICENSE="1"
ENV HIGHCHARTS_USE_STYLED="1"
ENV HIGHCHARTS_USE_MAPS="1"
ENV HIGHCHARTS_USE_GANTT="1"
RUN npm install highcharts-export-server -g --unsafe-perm
RUN npm config set strict-ssl=false
RUN node /usr/local/lib/node_modules/highcharts-export-server/build.js
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
# Bundle app source
COPY . .
#CMD ls
EXPOSE 3001
CMD [ "node", "index.js" ]
#ENTRYPOINT ["highcharts-export-server", "--enableServer", "1"]
Exporting Highchart image code (developed in NodeJS as API : index.js file name) :
const chartExporter = require("highcharts-export-server");
chartExporter.initPool();
let imageB64 = '';
chartExporter.export(chartDetails, (err, res) => {
imageB64 = res.data;
response.send(imageB64);
chartExporter.killPool();
});
I am successfully export/generate the image while manually running index.js in NodeJS. But facing below error while running through Docker image.
Error : phantom worker 5/6/7/8/9 unexpected data - SyntaxError: Expected token ')'
phantomjs://code/worker.js:658 in loop
I am using below Highchart JSON object for generating chart:
const chartDetails = {
type: "jpeg",
options: {
chart: {
type: "pie"
},
title: {
text: "Heading of Chart"
},
plotOptions: {
pie: {
dataLabels: {
enabled: true,
format: "<b>{point.name}</b>: {point.y}"
}
}
},
series: [
{
data: [
{
name: "a",
y: 20
},
{
name: "b",
y: 20
},
{
name: "c",
y: 50
},
{
name: "d",
y: 10
}
]
}
],
exporting: {
sourceWidth: 200,
sourceHeight: 200
}
}
};
Please let me know for further details. Thanks in an advance.
Follow below docker file. Use node:14 image and comment the line ssl_conf = ssl_sect
in /etc/ssl/openssl.cnf
FROM node:14/15/16/17
ENV ACCEPT_HIGHCHARTS_LICENSE="YES"
ENV HIGHCHARTS_VERSION=8.1.2
ENV HIGHCHARTS_USE_STYLED="YES"
ENV HIGHCHARTS_USE_MAPS="YES"
ENV HIGHCHARTS_USE_GANTT="YES"
ENV HIGHCHARTS_MOMENT="NO"
WORKDIR /app
COPY package.json .
RUN npm install
COPY index.js .
RUN sed -i 's/ssl_conf = ssl_sect/#ssl_conf = ssl_sect/g' /etc/ssl/openssl.cnf
EXPOSE 3001
CMD [ "node", "index.js" ]