Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/480-cache-directory-path #488

Merged
merged 5 commits into from
Mar 7, 2024

Conversation

jszuminski
Copy link
Contributor

Added the cachePath (HIGHCHARTS_CACHE_PATH) option which allows you to change the default directory to which the scripts are saved which is a major problem on AWS Lambda where you do not have write permissions to the .cache directory in node_modules and thus, highcharts-export-server does not work as expected.

@jszuminski jszuminski self-assigned this Mar 4, 2024
@jszuminski jszuminski requested review from PaulDalek and cvasseng and removed request for PaulDalek March 4, 2024 16:09
@jszuminski jszuminski marked this pull request as ready for review March 4, 2024 16:09
@PaulDalek PaulDalek changed the base branch from master to feature/error-handling March 7, 2024 13:32
Copy link
Contributor

@PaulDalek PaulDalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work!

@PaulDalek PaulDalek merged commit dcbaac0 into feature/error-handling Mar 7, 2024
@PaulDalek PaulDalek deleted the feature/480-cache-directory-path branch March 7, 2024 18:51
@baroso
Copy link

baroso commented Jun 13, 2024

FYI, I tried to set HIGHCHARTS_CACHE_PATH but I got these errors ...

  • It would prepend the current path to the cachePath (e.g. /node-export-server/tmp/.cache)
  • Puppeteer (Browser) would also use the current path to write to a ./tmp direcrtory (e.g. /node-export-server/tmp)

I'm using the following Dockerfile to create a Kubernetes-Pod with readOnlyRootFilesystem and runAsNonRoot and a /tmp EmptyDir ...

FROM node:current-slim

ENV NODE_ENV=production
ENV ACCEPT_HIGHCHARTS_LICENSE=YES
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
ENV HIGHCHARTS_CACHE_PATH=/tmp/.cache
ENV LOGGING_DEST=/tmp/log

RUN apt-get update && apt-get install -y git chromium

USER root
WORKDIR /

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

WORKDIR /node-export-server

USER node

RUN rm package-lock.json && \
    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"]

... but I could only get it to work with these changes master...baroso:node-export-server:master in my own fork.

And one other question arises, since Kubernetes logs to stdout/stderr ...
How do I specify the LOGGING_DEST to not use a file?

@baroso baroso mentioned this pull request Jun 13, 2024
@baroso
Copy link

baroso commented Jun 14, 2024

Also, when I want to enable the following options (as start arguments) ...

ENTRYPOINT ["highcharts-export-server", "--enableServer", "1", "--callback", "true", "--resources", "true", "--customCode", "true"]

... but I get the following error message (on all calls to the server) ...

Error when processing chart: {"statusCode":500,"message":"[chart] The 'callback', 'resources' and 'customCode' options have been disabled for this server."}

Does anyone know why this is not working in Docker?

@gregkiyomi
Copy link

This is still not working as I believe it should. Whatever you put into HIGHCHARTS_CACHE_PATH gets appended to the executable path. This means that in the case of the node module version, it still has to be a sub-directory of the node_modules directory. Instead, if it is an absolute path, then it should use the absolute pathing. If it's a relative path, then it can be relative. If you also want to handle just a directory name (.cache) then this would require more logic, but should also be doable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants