Streaming twitter searches with node.js and docker

I've created an example of how to wrap up a simple node.js into a docker container. I'm indebted to William Blankenship's very clear article on how to do this. In fact I suggest you read that article first.

The example code is available on github. I've simply taken the twitter node.js streams example code and dockerised it. I've made a couple of small changes in how to run it.

Firstly I've used the dotenv library to read a .env file from your local checkout. This file can contain all your Twitter api keys etc.

Secondly I've changed the Dockerfile slightly so that command line arguments can be passed to the script, using the ENTRYPOINT directive. Here's the Dockerfile in full:

FROM nodesource/node:5.1.0

ADD package.json package.json
RUN npm install
ADD . .

ENTRYPOINT ["node","streamer.js"]

ENTRYPOINT simply allows command line arguments to be tacked onto the docker run at runtime. In this case I use it to specify the search term.

More details are available in the project's README.

Posted on November 23, 2015 and filed under dev.