otium360 base Dockerfile for Express (NodeJs) HTTP server.
This image assumes that your application:
server.js as the entrypoint script8080The image will add to the container a file /express/package.json with the required NPM dependencies and install them locally to /express folder. NPM dependencies:
The default command is
CMD ['npm', 'start']
This image uses the /express directory as the root for your NodeJS/Express server, so you must copy here the server.js file and your web resources (HTML, JS, CSS and the like).
Sample Dockerfile:
FROM otium360organization/express
MAINTAINER Bálder Carraté <[email protected]>
ADD server.js /express/server.js
ADD www /express/www
Sample server.js:
'use strict';
var express = require('express');
var serveStatic = require('serve-static');
var app = express();
app.use(serveStatic('www', {'index': ['index.html']}));
app.listen(8080, function () {
console.log('MyApp is ready at http://localhost:8080');
});
Sample execution:
docker build -t my-app-express /path/to/your/Dockerfile
docker run -d -p 8080:8080 --name my-app-express my-app-express
Content type
Image
Digest
sha256:d1ca501bc…
Size
269 MB
Last updated
almost 11 years ago
docker pull otium360organization/express