FROM node:9.3.0-alpine # install static server RUN npm install -g serve # create a 'tmp' folder for the build and make it the current working directory WORKDIR /app/tmp # copy only the package.json to take advantage of cached Docker layers COPY package.json . # install project dependencies RUN npm install # copy project files and folders to the working directory COPY . . # build for production with minification RUN npm run build # make the 'app' folder the current working directory WORKDIR /app # clean up (i.e. extract 'dist' folder and remove everything else) RUN mv tmp/dist dist && rm -fr tmp EXPOSE 5000 CMD [ "serve", "--single", "--port", "3000", "dist" ]