This workshop will walk you through creating and composing a set of microservices using docker and docker-compose.
Note: This is an intermediate level workshop. You should be comfortable with creating node.js modules and applications. A basic understanding of docker and it's principles is also recommended.
The app you're building is a sensor fed chart that provides realtime data from a dummy sensor. This 'app' is broken down into a number of individually deployed containers, each with its own well defined concern.
A simple web app that uses JQuery, Rickshaw charts, and WebSockets to show a realtime graph of data being emitted by our sensor. This app has an API which is included in the same microservice who's sole job is to talk to and read from other microservices.
A small microservice that causes reads on the sensor based on an offset.
A dummy temperature sensor that sends out varying values based on what it receives from the actuator.
A service that handles reads and writes in serial fashion to the database. Uses websocket-stream to update the web app and thus the graph, in real time.
A robust messaging layer build for IoT based devices. We use this to wire up the actuator, serialiser and sensor in a loosely coupled fashion.
A database in a container that the serialiser uses for robust storage of data.
A charting library for the web.
http://code.shutterstock.com/rickshaw/
A HTTP Web server library.
A web socket streams implementation for realtime communication to the browser.
https://www.npmjs.com/package/websocket-stream
A module to let you require modules client side by bundling up dependencies.
A pattern matching Microservices library.
An MQTT broker that enables robust message, particularly suited to IoT.
https://github.com/mcollina/mosca
A time series database particularly suited to time sensitive data.
A container engine.
To complete this workshop you will need both the offical node image as well as the InfluxDB image. These can be pulled from Docker Hub or via a usb key if applicable.
Start your default machine
Add the correct env variables to your shell
Confirm that docker is available to use.
Import the offical node image.
Import the influx db image.
Confirm that you have both influx and node.
We have included a set of common commands for docker and docker machine, including a short decscription of what they do below.
Sets up your current shell with the variables from docker-machine env NAME
.
Imports a tarball (or other file) image into docker.
Lists all of your containers.
Lists all of your images, these are the building blocks for your containers.
Starts your docker virtual machine (only applicable to non Linux).
Stops your docker virtual machine (only applicable to non Linux).
Lists the needed ENV variables needed to connect to your virtual machine.
Sets up your current shell with the variables from docker-machine env NAME
.
Will return the ip address your docker machine is running on.
Will stop all running containers based on the list from docker ps
.
Will compose your services together based off a root docker-compose.yml file.
Runs your composed services (asumming you are in the correct directory.
For a full cheatsheet on docker please see the Docker Cheat Sheet repo.