I need to dockerize a nodejs application that uses webpack. I have this script below:
"scripts": {
"start": "cross-env NODE_ENV=development webpack-dev-server --open webpack --env.envConfig=hello --config configs/webpack.dev.js ",
"build-dev": "cross-env NODE_ENV=development webpack --env.project=rm --env.envConfig=hello --env.publicPath=/ --config configs/webpack.dev.js",
"build": "cross-env NODE_ENV=production webpack --env.project=rm --env.envConfig=hello --env.publicPath=/ --config configs/webpack.prod.js",
},
This is my docker code snippet
FROM node:10-alpine as builder
# copy the package.json to install dependencies
COPY . /build
WORKDIR /build
# Install the dependencies and make the folder
RUN npm install && npm run build
However, I want to choose between npm run build and npm run build-dev whenever I execute docker run. Is it possible? If not, can I pass the webpack options on docker run instead?
docker run npm builddocker run npm build-dev. Maybe you want to choose which image to build? rather than what command to run after the image is built.