Hacking Orion Context Broker with Docker
Currently the official Orion Context Broker (OCB) build target is CentOS 3.6. As my favorite Linux box is Ubuntu
I was very interested in being able to hack OCB using the latest version of Ubuntu.
Let's do it
What I have been hacking is a Docker image (orion-dev) that will allow any developer to use Ubuntu to hack OCB.
The Dockerfile installs all the packages and utilities that will allow you to compile, execute tests and run OCB.
If you have a look at the Dockerfile you might wonder where the OCB code is.
The OCB code will be in your local machine and not in the container. That has been done on purpose.
Why? Because that will allow you to edit the source code locally and compile it in the container.
And where is Mongo? Mongo will be in its own Docker Container that will be linked to the orion-dev container.
OCB Hacking step by Step
- Clone the OCB repo to a local directory. Clone the dockerfiles repo as well.
git clone https://github.com/telefonicaid/fiware-orion.git fiware-orion git clone https://github.com/jmcanterafonseca/dockerfiles.git dockerfiles
- Build the docker image
cd dockerfiles/fiware-orion docker build --rm=true --tag=orion-dev:latest .
Run MongoDB container
Run the docker image in a container
docker run -p 1026:1026 --name orionDev --cpuset-cpus="0-3" --link mongoOrion:mongoOrion \ -v /Users/jmcf/work/develop/fiware-orion:/root/src -t -i orion-dev:latest /bin/bash
As you can see we are binding the src container's directory to the local directory in which we
have cloned the OCB code. In addition we are linking the container on which Mongo resides
now you will see a shell prompt which current working directory is
if you type make the compilation process will start. But before doing so, you must comment out in CMakeLists.txt
the line corresponding to the proxy COAP, as this image is not including the proxy COAP, which might be
discontinuated in the near future.
and finally if you want to run functional tests type
CB_DATABASE_HOST=mongoOrion make ft
If you want to try out docker-compose you can use https://github.com/jmcanterafonseca/dockerfiles/fiware-orion/docker-compose.yml as well.