node-export-server icon indicating copy to clipboard operation
node-export-server copied to clipboard

Docker file for V4

Open Pascal76 opened this issue 1 year ago • 11 comments

Hi

Could someone provide a working docker file for the V4 please ?

Thank you.

Pascal76 avatar May 20 '24 09:05 Pascal76

Built for myself using the one below. I add some fonts (for example google fonts) - put them into folder fonts.

from node:22

WORKDIR /usr/share/fonts/truetype
ADD fonts/* /usr/share/fonts/truetype/
# ADD src/fonts/OpenSans-Regular.ttf OpenSans-Regular.ttf
# ADD src/fonts/OpenSans-Light.ttf OpenSans-Light.ttf
# ADD src/fonts/OpenSans-Semibold.ttf OpenSans-Semibold.ttf
# ADD src/fonts/OpenSans-Bold.ttf OpenSans-Bold.ttf
# ADD src/fonts/OpenSans-ExtraBold.ttf OpenSans-ExtraBold.ttf
# ADD src/fonts/OpenSans-Italic.ttf OpenSans-Italic.ttf
# ADD src/fonts/OpenSans-LightItalic.ttf OpenSans-LightItalic.ttf
# ADD src/fonts/OpenSans-BoldItalic.ttf OpenSans-BoldItalic.ttf
# ADD src/fonts/OpenSans-SemiboldItalic.ttf OpenSans-SemiboldItalic.ttf
# ADD src/fonts/OpenSans-ExtraBoldItalic.ttf OpenSans-ExtraBoldItalic.ttf

USER root
WORKDIR /

RUN git clone https://github.com/highcharts/node-export-server.git && \
    chown -R node /node-export-server

WORKDIR /node-export-server

USER node 

ENV ACCEPT_HIGHCHARTS_LICENSE="YES" HIGHCHARTS_MOMENT="1"

RUN rm package-lock.json && \
    npm install -S  moment moment-timezone && \
    npm install

USER root
RUN npm link --unsafe-perm
RUN apt update && apt install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 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 libxss1 libxtst6 ca-certificates fonts-liberation libnss3 lsb-release xdg-utils wget ca-certificates

USER node

WORKDIR /node-export-server

EXPOSE 7801
ENTRYPOINT ["highcharts-export-server", "--enableServer", "1", "--logLevel", "4", "--allowCodeExecution", "1"]

ba1dr avatar May 29 '24 07:05 ba1dr

It displays:

(node:7) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead. (Use node --trace-deprecation ... to show where the warning was created)

Also the "height" on "chart" on the json file is ignored. It uses the default value :( I have to add the value as argument on the /usr/local/bin/highcharts-export-server command line.

And the png creation takes 0:02.69 vs 0:00.63 on the old version without pupetter (maybe due the the display of the warning) (I don't use highcharts as a server)

Pascal76 avatar May 29 '24 20:05 Pascal76

FYI, I also made this https://github.com/highcharts/node-export-server/commit/d029d00144af238c7f28cb50f5a52d7079273ae1 addition, because of this error ...

Mon Jun 17 2024 09:17:00 GMT+0000 [warning] - [chart] Unable to load the default resources.json file. 
 Error: ENOENT: no such file or directory, open 'resources.json'
    at readFileSync (node:fs:448:20)
    at doExport (file:///node-export-server/lib/chart.js:318:27)
    at doStraightInject (file:///node-export-server/lib/chart.js:488:12)
    at startExport (file:///node-export-server/lib/chart.js:102:16)
    at exportHandler (file:///node-export-server/lib/server/routes/export.js:212:11)
    at Layer.handle [as handle_request] (/node-export-server/node_modules/express/lib/router/layer.js:95:5)
    at next (/node-export-server/node_modules/express/lib/router/route.js:149:13)
    at Route.dispatch (/node-export-server/node_modules/express/lib/router/route.js:119:3)
    at Layer.handle [as handle_request] (/node-export-server/node_modules/express/lib/router/layer.js:95:5)
    at /node-export-server/node_modules/express/lib/router/index.js:284:15

... according to --allowFileResources: Controls the ability to inject resources from the filesystem. This setting has no effect when running as a server (defaults to false). mentioned here https://github.com/highcharts/node-export-server/blob/master/README.md#command-line-arguments, the file resources.json should only be checked for when running as a Server (which I didn't check for in my change) and allowFileResources=true.

baroso avatar Jun 17 '24 09:06 baroso

I had a need for this recently and simply installing the export server onto the Puppeteer provided image seemed to be the easiest way to get this up and running.

# building on https://github.com/puppeteer/puppeteer/blob/main/docker/Dockerfile
FROM ghcr.io/puppeteer/puppeteer:23.0.2

ENV HIGHCHARTS_VERSION="11.4.7"

USER root 
RUN npm install [email protected] -g 

WORKDIR /

EXPOSE 8080
ENTRYPOINT ["highcharts-export-server", "--enableServer", "1", "--port", "8080"]

zlangner avatar Aug 14 '24 14:08 zlangner

docker image list size = 3.08GB !

Pascal76 avatar Sep 09 '24 14:09 Pascal76

Looking at the image size for the docker file I shared, it reports it's only 1181.76 MB in AWS ECR.

zlangner avatar Sep 09 '24 14:09 zlangner

Is there any progress on this issue ?

dallalgaham avatar Feb 18 '25 15:02 dallalgaham

Here's the dockerfile I was using on aws arm. I've stopped using it and am using Lambda now, but it should still work fine.

Archive.zip

davidseverwright avatar Feb 18 '25 16:02 davidseverwright

@davidseverwright thank's a lot

dallalgaham avatar Feb 19 '25 09:02 dallalgaham

@davidseverwright thanks for providing that zip. Out of curiosity were you able to get 4.0.0+ working on lambda? Been struggling on this myself for a few days. Have seen a fork out there but haven't tried it yet. My goal is to run the puppeteer version on an ARM lambda.

ar090 avatar Apr 25 '25 23:04 ar090