# slim does not work w/tini # FROM node:10-slim as prod FROM node:10.15-alpine as prod ENV NODE_ENV=production EXPOSE 3000 RUN apk add --no-cache tini WORKDIR WORKDIR /app COPY package*.json ./ RUN npm install --only=production && npm cache clean --force COPY . . # ..use this in prod if want to prevent images from building as a result of failed tests # RUN npm test ENTRYPOINT ["/sbin/tini", "--"] CMD ["node", "./bin/www"] FROM prod as dev ENV NODE_ENV=development RUN npm install --only=development CMD ["../node_modules/nodemon/bin/nodemon.js", "./bin/www", "--inspect=0.0.0.0:9229"] FROM dev as test ENV NODE_ENV=development CMD ["npm", "test"] # Build + run prod: # docker build -t multistage --target prod . && docker run --init -p 3000:3000 multistage # Build + run dev: # docker build -t multistage:dev --target dev . && docker run --init -p 3000:3000 multistage:dev # need the tini `--init` process for `ctrl + c`..stopping container # Build + run test: # docker build -t multistage:test --target test . && docker run --init multistage:test