# FROM node:12 # # See: https://nodejs.org/en/docs/guides/nodejs-docker-webapp/ # # Create app directory # WORKDIR /usr/src/app # # Install app dependencies # # A wildcard is used to ensure both package.json AND package-lock.json are copied # # where available (npm@5+) # COPY package*.json ./ # RUN npm install # # If you are building your code for production # # RUN npm ci --only=production # # Bundle app source # COPY . . # EXPOSE 8080 # CMD [ "node", "server.js" ] # ------ FROM mhart/alpine-node:12 WORKDIR /app COPY package.json ./ # If you have native dependencies, you'll need extra tools # RUN apk add --no-cache make gcc g++ python RUN npm install RUN npm ci --prod # Then we copy over the modules from above onto a `slim` image FROM mhart/alpine-node:slim-12 # If possible, run your container using `docker run --init` # Otherwise, you can use `tini`: # RUN apk add --no-cache tini # ENTRYPOINT ["/sbin/tini", "--"] WORKDIR /app COPY --from=0 /app . COPY . . CMD ["node", "server.js"]