How to Create a Docker Image to Run Aspose.Cells for Node.js via Java

This article guides on how to install Node.js to run Aspose.Cells for Node.js via Java. It contains the script for building a docker image and a sample code to test the installation. You will also get information on running the docker image from the terminal and run the sample code there demonstrating how to use Aspose.Cells for Node.js via Java.

Steps to Install Aspose.Cells for Node.js via Java

  1. Create a folder in your system
  2. Save the docker image creation instructions in a file named Dockerfile
  3. Save the sample code in a file named app.js
  4. Copy both files to the newly created folder
  5. Open the terminal/command window in the above folder and run the following command to generate a docker image
  6. docker build -t my-node-java-image .
  7. Run the following command to run the container and create an Excel file
  8. docker run -it my-node-java-image

These steps describe the process of how to install Aspose.Cells for Node.js via Java. Initially create the required files and save them in a folder followed by running the terminal/command window in the same folder. In the next steps, you will run the command to build the docker image and then run this image using the second command. The second command will just display a message however, you will not be able to see the output Excel file in the directory where the terminal/command window was opened. For viewing the Excel file, refer to the command in the last section.

Script to Install Node.js to run Aspose.Cells for Node.js via Java

Dockerfile app.js

This docker script uses the OpenJDK 8 image as a base image and then installs Node.js, Python 2.x, the PIP command, node-java bridge, the required build tools for node-gyp, and Aspose.Cells for Node.js using the npm command. If you want to run the code inside the container, run the command “docker run -it -v /PathToSharedFolderOnHostComputer:/SharedFolder my-node-java-image /bin/bash”. Here a folder from the host computer is shared for exchanging data between the host computer and the docker container.

When you run the docker image, a container is created and a command prompt is shown. Here run the command “node app.js” which will actually create an Excel file that can be viewed using the “ls” command in the container. As the container does not have Excel viewing tools, you may copy the output Excel file to the shared folder named “SharedFolder” in the container. It will show this file in the “PathToSharedFolderOnHostComputer” folder of your host computer where it can be seen in MS Excel.

 English