Getting Data In

Why is my node_modules folder deleted after docker build?

leb7abt
Engager

Hi guys!

I'm currently building a docker container with splunk/universalforwarder:7.0.0-monitor-k8s-logs as base image. During my docker build i install my own node.js and want to add my own scriptedinput scripts.

my eventhub folder:

/bin/myscript
/bin/package.json

Dockerfile:

FROM splunk/universalforwarder:7.0.0-monitor-k8s-logs

RUN apt-get update \ 
 && apt-get install curl -y \
 && curl -sL https://deb.nodesource.com/setup_8.x | bash \
 && sudo apt-get install -y nodejs 

COPY eventhub  /opt/splunk/etc/apps/eventhub/

WORKDIR /opt/splunk/etc/apps/eventhub/bin/

RUN npm i --production && ls -al  <==

ls -al gives me that all are successfully created:

myscript
node_modules
package.json
package.json.lock

However running my new image, the node_modules folder and package.json.lock is missing. After doing a manual npm install in the container everything is working.

Copying the files to /opt/splunk/ and doing the npm install there and not to /opt/splunk/etc the files are there.

I think it has something to do with the base image volumes of /opt/splunk/etc and /opt/splunk/etc see: https://github.com/splunk/docker-splunk/blob/master/enterprise/Dockerfile. But i cant't figure out what...I don't run splunk when running the image so i don't know how the volumes getting manipulated and also why only the npm install files getting deleted.

Thanks for your help!

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...