| | 48 | # Create app directory |
| | 49 | WORKDIR /usr/src/app |
| | 50 | |
| | 51 | # Install app dependencies |
| | 52 | # A wildcard is used to ensure both package.json AND package-lock.json are copied |
| | 53 | # where available (npm@5+) |
| | 54 | COPY package*.json ./ |
| | 55 | |
| | 56 | RUN npm install |
| | 57 | # If you are building your code for production |
| | 58 | # RUN npm ci --only=production |
| | 59 | |
| | 60 | # Bundle app source |
| | 61 | COPY . . |
| | 62 | |
| | 63 | EXPOSE 8080 |
| | 64 | CMD [ "node", "server.js" ] |
| | 65 | }}} |
| | 66 | |
| | 67 | 4. Create a .dockerignore file in the same directory as your Dockerfile with following content: |
| | 68 | {{{ |
| | 69 | node_modules |
| | 70 | npm-debug.log |
| | 71 | }}} |
| | 72 | This will prevent your local modules and debug logs from being copied onto your Docker image and possibly overwriting modules installed within your image. |
| | 73 | |
| | 74 | |