Chandan Ghosh | 5d55c41 | 2019-04-09 15:18:05 +0530 | [diff] [blame] | 1 | # Check out https://hub.docker.com/_/node to select a new base image |
| 2 | FROM node:10-slim |
| 3 | |
| 4 | # Set to a non-root built-in user `node` |
| 5 | USER node |
| 6 | |
| 7 | # Create app directory (with user `node`) |
| 8 | RUN mkdir -p /home/node/app |
| 9 | |
| 10 | WORKDIR /home/node/app |
| 11 | |
| 12 | # Install app dependencies |
| 13 | # A wildcard is used to ensure both package.json AND package-lock.json are copied |
| 14 | # where available (npm@5+) |
| 15 | COPY --chown=node package*.json ./ |
| 16 | |
| 17 | RUN npm install |
| 18 | |
| 19 | # Bundle app source code |
| 20 | COPY --chown=node . . |
| 21 | |
| 22 | RUN npm run build |
| 23 | |
| 24 | # Bind to all network interfaces so that it can be mapped to the host OS |
| 25 | ENV HOST=0.0.0.0 PORT=3000 |
| 26 | |
| 27 | EXPOSE ${PORT} |
| 28 | CMD [ "node", "." ] |