[[ -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" ]
本文介绍了一个使用Docker和PM2部署Node.js应用程序的流程,包括清理旧的容器实例,构建新的Docker镜像,运行容器,以及使用PM2管理应用。特别注意了中国地区npm源的配置,确保依赖包安装顺利。
2898

被折叠的 条评论
为什么被折叠?



