Rackspace recently launched Carina, their container environment service based on docker swarm. I’ve been wanting to put together a container based continuous delivery workflow to demo for a client and Carina seems like a perfect place to do it. To help me understand how Carina easily enables launching docker containers, I decided to launch a Hubot instance on their service.
If you’d like to dive right in, head over to the source code and fork it. You can also interact with Carinabot over at Gitter.im
Note: This article assumes Mac OSX but should translate to any linux platform with little modification
Prerequisites
- docker
- carina cli
- node.js and npm
- Github account
- gitter.im account
Launch a Carina Cluster
The carina cli1 allows us to create and destroy our clusters, download credentials and prepare our environment.
Assembling Carinabot
Now we can assemble Carinabot, an instance of Hubot2.
Optional, but recommended:
We can, and should, test that Carinabot is working as expected.
Carinabot as a Container
What’s a better welcoming gift than stuffing our bot into a tiny little container? Let’s create a Dockerfile
to define how this container should be built.
With our Dockerfile
defined, we can now build an image from it.
Intermission
Before we introduce Carinabot to the world, there are a few details to note. We will be using Gitter.im and the gitter2 adapter. Gitter’s business model is tightly coupled to GitHub. As such, you will need a GitHub account to sign up for Gitter.
The gitter2 adapter uses the Gitter API and requires a Personal Access Token to authenticate with the endpoint. We will pass this token via an environment variable when we run our docker container. Additionally, the bot will not respond to commands sent from the account it is logged in as, so you will need a second Gitter.im account to communicate with the bot.
Carinabot’s Grand Debut
Let’s resume the show!
Now that we’ve installed our tools, assembled Carinabot, packaged her into a portable container image, and got our accounts created, we’re ready to flip the switch and debut our creation.
Congratulations! We’ve got a working Hubot container running.
Head on over to Gitter.im and send a direct message to the account name your bot is running as to see it in work.
Next time, we’ll add a Redis Brain to Carinabot and introduce Docker Compose for orchestrating our containers.
-
For an explanation of all capabilities and available options, check out the carina cli documentation ↩
-
Explaining Hubot in depth is outside the scope of this post. If you’d like, head on over to the Hubot documentation to familiarize yourself. ↩