How to install NPM package for actions on Docker?

Hi,

I search to install NPM package “canvas” for my action.

I use BotPress v12.19.1 on Docker, with Dokku (Heroku like).

I haven’t NodeJS on BP image, and I can’t install any NPM package.

dokku enter botpress-server

Thanks for help.

Maxence.

go to your action path:
cd data/bots/yourBotName/actions

then type…
npm i canvas
(node_modules path should be added to your actions path)

finally, push & release as usual (for deployment on docker at heroku)

The problem is I haven’t NodeJS installed on Docker image, I can’t type npm install canvas.

If I add data/bots/my_bot/actions with Dockerfile file, the script actions folder with package.json are not available when I enter on Docker container… The actions folder is empty.

I don’t want push node_modules too, because it’s too large.

Thanks for help.

Maxence.

The problem is I haven’t NodeJS installed on Docker image, I can’t type npm install canvas.

You can derive your own Botpress image from the official one while using a node-alpine image as a builder (see Use multi-stage builds | Docker Documentation).
Build your dist folder in the builder and then copy over the artifacts, including a node_modules folder if needed :wink: