Skip to content
Advertisement

Add Carbone to Docker image

I have installed Carbone on my local Linux machine using the following command and it is working properly.

npm install carbone

Now, I need to add carbone in my docker image, but I don’t know how to add it to the image. Should I add the npm install command to DockerFile or add it to package.json?

I got the following error if I don’t add carbone to docker image:

Code : const carbone = require('carbone');
Error: Cannot find module 'carbone'

Advertisement

Answer

Carbone have to be used on node projects. You can install through NPM:

npm install carbone --save

Then, you must follow the documentation of the basics: https://github.com/Ideolys/carbone/#getting-started

If you want to dockerize your application, you can start your container from the image ideolys/carbone-env-docker. It’s a ready to go node:8 image with Libreoffice installed. Example of Dockerfile:

FROM ideolys/carbone-env-docker

ENV DIR /app

WORKDIR ${DIR}

COPY . ${DIR}

RUN npm install

# index.js should call carbone functions to generate your report.
CMD [ "node", "index.js" ]

Finally you can build and run the container ! If you need more help or encounter an issue, post an issue on the Carbone Github.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement