1. Writing. Dockerignore
When you build the image, you do not need the Node_modules directory and so on, you can use the. Dockerignore Ignore the file
#. dockerignoredockerfilenode_modules/
2. Writing the Dockerfile file
From Mhart/alpine-node:7label maintainer "test-nodejs.com" COPY localtime/etc/localtimeworkdir/appcopy Package.json/ Apprun apk--update add git && apk--update Add Curl && rm-rf/tmp/*/var/cache/apk/* &&A mp NPM Install && npm install-g pm2copy/appexpose 5000HEALTHCHECK CMD Curl--fail Http://localhost:5000/funda tion | | Exit 1CMD ["PM2", "Start", "Pm2.json", "--no-daemon"]
- Set Workdir
- To install git, some dependencies need to be fetched from GitHub, and the node base image defaults to No git
- Node mirroring does not have curl by default
- Install PM2, the project starts using PM2
- Exposing Port 5000
- Healthchech Health Check
- PM2 boot needs to be added--no-daemon
Dockerfile Deployment Nodejs