Node app showing container info

parent 6b12565c
FROM node:4.6
WORKDIR /app
COPY ./public/ /app
RUN npm install
EXPOSE 3000
CMD npm start
\ No newline at end of file
var express = require('express');
var os = require('os')
var app = express();
function format(seconds){
function pad(s){
return (s < 10 ? '0' : '') + s;
}
var hours = Math.floor(seconds / (60*60));
var minutes = Math.floor(seconds % (60*60) / 60);
var seconds = Math.floor(seconds % 60);
var result = "";
if (hours > 0) {result = pad(hours)+ ' hours'}
if (minutes > 0) {result = result + pad(minutes)+ ' minutes '}
result = result + pad(seconds)+ ' seconds';
return result;
}
app.get('/', function (req, res) {
var uptime = process.uptime();
res.send("Hello from "+os.hostname()+" I born "+format(uptime)+" ago!");
});
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Programa de ejemplo escuchando en http://%s:%s',host,port);
});
\ No newline at end of file
{
"name": "myapp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node index.js"
},
"engines": {
"node": "^4.6.2"
},
"dependencies": {
"express": "^4.17.1"
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment