Nodejs Express dockerfile最佳实践

1. 少啰嗦,先看代码 1.1. package.json { "name": "xxx", "version": "0.0.0", "private": true, "scripts": { "start": "node ./bin/www", "forever": "node_modules/forever/bin/forever bin/www" }, "dependencies": { "async": "0.9.0", "body-parser": "1.13.2", "compression": "1.6.2", "config": "1.12.0", "connect-multiparty": "2.0.0", "cookie-parser": "1.3.5", "debug": "2.2.0", "ejs": "2.3.3", "express": "4.13.1", "forever": "0.15.3", "http-proxy-middleware": "0.17.3", "log4js": "0.6.24", "serve-favicon": "2.3.0" } } 1.2. dockerfile FROM node:9.2.1-alpine RUN apk update && apk add bash tzdata \ && cp -r -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime WORKDIR /app COPY package....

2018-02-08 · 1 min · 王端端

直接在Chrome DevTools调试Node.js

英文好的,直接看原文 https://blog.hospodarets.com/nodejs-debugging-in-chrome-devtools 1. 要求 Node.js 6.3+ Chrome 55+ 2. 操作步骤 1 打开连接 chrome://flags/#enable-devtools-experiments 2 开启开发者工具实验性功能 3 重启浏览器 4 打开 DevTools Setting -> Experiments tab 5 按6次shift后,隐藏的功能会出现,勾选"Node debugging" 3. 运行程序 必须要有 --inspect > node --inspect www Debugger listening on port 9229. Warning: This is an experimental feature and could change at any time. To start debugging, open the following URL in Chrome: chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?experiments=true&v8only=true&ws=localhost:9229/78a884f4-8c2e-459e-93f7-e1cbe87cf5cf 将这个地址粘贴到谷歌浏览器:chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?experiments=true&v8only=true&ws=localhost:9229/78a884f4-8c2e-459e-93f7-e1cbe87cf5cf 程序后端输出的日志也回输出到谷歌浏览器的console里面,同时也可以在Sources里进行断点调试了。

2018-02-07 · 1 min · 王端端

Nodejs 服务端框架合集(78个)

没有什么事情是一个框架解决不了的,如果有,就再找一个。 Photo by 贝莉儿 NG on Unsplash 1. MVC frameworks 2. Sinatra-like 这些框架提供了丰富的配置,比Rails-like或full-stack少。 Express hapi flatiron locomotive total.js koa.js TWEE.IO diet.js Flicker.js ZinkyJS 2.1. Rails-like 正确呈现您的项目。从包含的模板创建自己的艺术 Nodal Strapi CompoundJS geddy Sails.js Adonis RhapsodyJS ThinkJS Trails KambojaJS JS-Web 3. Full-stack frameworks 这就是Node.js真正闪耀的地方。全栈MVC框架与脚手架,模板引擎,websocket和持久性库捆绑在一起,允许您构建实时可伸缩的Web应用程序。 Catberry.js AllcountJS Derby Feathers SocketCluster SocketStream MEAN.js MEAN.io Meteor Meatier TWEE.IO Mojito Seeds.js SANE COKE Sleekjs Danf Catberry Nuke.js We.js seneca.js Keystone....

2018-01-29 · 1 min · 王端端

Nodejs alpine 基础docker镜像构建

1. 系统环境 centos7 内核:3.10.0-514.26.2.el7.x86_64 安装docker要求内核版本不低于3.10 2. 安装docker yum install docker // 安装docker systemctl start docker.service // 启动docker systemctl enable docker.service // 设置开机启动 3. Nodejs 镜像选择 REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/node 9.2.1-slim 69c9f9292fa4 3 days ago 230 MB docker.io/node 9.2.1-alpine afdc3aaaf748 3 days ago 67.46 MB docker.io/node latest 727b047a1f4e 3 days ago 675.6 MB docker....

2018-01-29 · 1 min · 王端端