Sign inSign up

tangjoe88/nodejs-alpine

By tangjoe88

•Updated almost 11 years ago

Node.js Web Server on Alpine

Image
0

139

tangjoe88/nodejs-alpine repository overview

⁠Dockerfile

FROM alpine RUN apk add --update nodejs WORKDIR /data COPY web.js /data/web.js EXPOSE 8088 CMD node /data/web.js

⁠web.js

// import the HTTP module var http = require('http');

// define a web server port const PORT=8081;

// define a function to handle requests and send response function handleRequest(request, response) { response.end('Hi! This is Joe Tang from IBM. Path hit: ' + request.url); }

// create a server var server = http.createServer(handleRequest);

// start the web server server.listen(PORT, function() { console.log("Node.JS web server is listening on: http://localhost:%s⁠", PORT); });

⁠How to Run

$ docker run -it --rm -p 8081:8081 --name nodeweb tangjoe88/nodejs-alpine

⁠On Host

$ curl http://localhost:8081/⁠

Tag summary

Content type

Image

Digest

sha256:b70f4d2f7…

Size

8 MB

Last updated

almost 11 years ago

docker pull tangjoe88/nodejs-alpine