我已经编写了多阶段的Dockerfile,但是我还需要保持该映像有效,因此我决定编写小型服务器:
const debug = require('debug')('http'),
http = require('http');
const PORT = process.env.PORT || 80;
const INTERNAL_HEALTH_PATH = '/internal/health/live';
debug('Starting HTTP server on port', PORT);
console.info('======> Welcome in smoke tests space! <======');
http.createServer(function(req, res){
res.writeHead(200, {'Content-Type': 'text/html'}); // http header
debug(req.method + ' ' + req.url);
if(req.url === INTERNAL_HEALTH_PATH){
res.end('OK');
}
}).listen(PORT, function(){
debug('Listening on port: ' + PORT);
});
但是当我想执行(第二阶段)时:
# Run minimalist server to keep alive Docker's image
RUN node index.js
我知道了
Error: Cannot find module 'debug'
我了解这个问题,但是如何有效地解决呢?