I usually write Dockerfiles for Java / Go applications and it's the first time I have encountered a situation where I have to write a Dockerfile for an already existing (and production running) Node.js application. As per my little knowledge about the Node.js which I acquired in the past couple of days, dist folder is generated after we build a Node.js project which carries the source code (please correct me if I am wrong here). So I am interested in copying the dist folder from parent Docker image to child Docker image.
However, after I copy everything from an application into my parent Docker image (line 6) and run 'npm run build' command, dist folder is not generated for me (please note the node_modules and package-lock.json are being generated).
My Dockerfile is as below:
FROM node:10-alpine as BUILD
WORKDIR /src
COPY package*.json /src
RUN apk add --update --no cache \
python \
make \
g++
RUN npm install
COPY . /src
RUN npm run build
How can I resolve this?
"build"
command do inside yourpackage.json
file? – ChirrRUN npm install -g grunt-cli RUN npm install grunt
just before the lineCOPY . /src
. Still I am not able to see dist folder generated in my docker image – Creaky