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!

ATTENTION!! We’re MOVING (not really)

Hey, all! In an effort to keep this Slack workspace secure and also to make our new members' experience easy, ...

Splunk Admins: Build a Smarter Stack with These Must-See .conf25 Sessions

  Whether you're running a complex Splunk deployment or just getting your bearings as a new admin, .conf25 ...

AppDynamics Summer Webinars

This summer, our mighty AppDynamics team is cooking up some delicious content on YouTube Live to satiate your ...