Last active
August 29, 2015 14:18
-
-
Save gionn/3b8ae2fd16f46acadea9 to your computer and use it in GitHub Desktop.
Simple example of Dockerfile for nodejs application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
// handle all request with a 200 ok | |
var server = http.createServer(function (request, response) { | |
response.writeHead(200, {"Content-Type": "text/plain"}); | |
text = "Running Node.js:" + process.versions.node | |
response.end(text); | |
}); | |
// search for an injected port or use a default one | |
var port = process.env.PORT; | |
// go! | |
server.listen(port); | |
// logs con terminal that server is ready | |
console.log("Server running at http://0.0.0.0:" + port + "/"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:14.04 | |
MAINTAINER Giovanni Toraldo | |
ENV DEBIAN_FRONTEND noninteractive | |
RUN sed -i s/archive/it.archive/g /etc/apt/sources.list | |
RUN apt-get update | |
RUN apt-get install -y software-properties-common | |
RUN apt-add-repository ppa:chris-lea/node.js | |
RUN apt-get update | |
RUN apt-get install -y nodejs | |
RUN apt-get clean | |
RUN rm -rf /var/lib/apt/lists/* | |
RUN mkdir /var/www | |
ADD app.js /var/www/app.js | |
ENV PORT 8080 | |
EXPOSE 8080 | |
VOLUME ["/var/www/data"] | |
CMD ["/usr/bin/node", "/var/www/app.js"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment