[[ -z $(docker ps -qaf name=^/node_xxx$) ]] || docker rm -f node_xxx
cd /var/node/docker_node && docker build --rm --no-cache=true -t node_xxx . && docker run -d --name node_xxx -p 9999:8091 node_xxx && docker rmi $(docker images -qf dangling=true)
pm2的Dockerfile:
#FROM keymetrics/pm2:latest-alpine node版本要10的,
FROM keymetrics/pm2:10-alpine
# Bundle APP files ./表示当前目录所有文件,用*是表示所有文件,copy进去会没有目录结构
COPY ./ /docker_node
WORKDIR /docker_node
# Install app dependencies
ENV NPM_CONFIG_LOGLEVEL warn
RUN cd /docker_node
RUN npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass
RUN npm install --registry=https://registry.npm.taobao.org
#RUN npm install --production --registry=https://registry.npm.taobao.org
#RUN npm install -g cnpm --registry=https://registry.npm.taobao.org
#RUN cnpm insall
# Show current folder structure in logs
#RUN ls -al /docker_node
CMD [ "pm2-runtime", "start", "pm2-innertest.json" ]