标签:span from 使用 console server none docker 镜像 快速 文件
yarn init
yarn add hapi
package.json add
"scripts":{
"run":"node index.js"
}
const Hapi = require(‘hapi‘);
// Create a server with a host and port
const server = new Hapi.Server();
server.connection({
host: ‘0.0.0.0‘,
port: 8009
});
// Add the route
server.route({
method: ‘GET‘,
path:‘/hello‘,
handler: function (request, reply) {
return reply(‘hello world‘);
}
});
// Start the server
server.start((err) => {
if (err) {
throw err;
}
console.log(‘Server running at:‘, server.info.uri);
});
FROM kkarczmarczyk/node-yarn
RUN mkdir -p /home/nodejs/app
WORKDIR /home/nodejs/app
COPY . /home/nodejs/app
RUN yarn
CMD ["yarn","run","run"]
docker build -t demo .
docker run -d -p 8009:8009 demo
https://hub.docker.com/r/kkarczmarczyk/node-yarn/
https://yarnpkg.com/zh-Hans/
https://hapijs.com/
nodejs docker 开发最好选择yarn 进行包管理而不是npm
标签:span from 使用 console server none docker 镜像 快速 文件
原文地址:http://www.cnblogs.com/rongfengliang/p/7815891.html