Rapid WebRTC application development with RestcommONE and docker
Recently we released the new RestcommONE 7.4.0.GA and with this release we introduced the RestcommONE docker image https://hub.docker.com/r/mobicents/restcomm/ to make it even easier for developers to start development of telecom applications with RestcommONE.
For those who don’t know what is docker you can visit https://www.docker.com/ to learn more but I will add here a quote from the official docker site:
Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications. Consisting of Docker Engine, a portable, lightweight runtime and packaging tool, and Docker Hub, a cloud service for sharing applications and automating workflows, Docker enables apps to be quickly assembled from components and eliminates the friction between development, QA, and production environments. As a result, IT can ship faster and run the same app, unchanged, on laptops, data center VMs, and any cloud.
Using RestcommONE and docker, you can avoid the setup and configuration of RestcommONE and prerequisites (Java, screen, ipcalc etc) and have a telecom application development environment ready within minutes and thus you can focus on your application. A true rapid telecom application development with RestcommONE and Docker.
The RestcommONE docker image currently supports two image tags:
- latest tags the image that uses the last successful artifact of Mobicents RestcommONE
- 7.4.0 tags the image that uses the 7.4.0.GA version of Mobicents RestcommONE – 22.214.171.1246
IMPORTANT Notice for docker image version
Initial RestcommONE docker image was pretty big in size 1.393GB. After the proper optimizations of the Dockerfile, the RestcommONE docker image was reduced by 54% to 652,8 MB.
If you already downloaded the initial “fat” RestcommONE image (before May 29, 2015), you need to remove the image and download it again:
- latest tag: docker rmi mobicents/restcomm && docker pull mobicents/restcomm
- 7.4.0 tag: docker rmi mobicents/restcomm:7.4.0 && docker pull mobicents/restcomm:7.4.0
For the rest of this post we will use the latest tag, which in fact you can omit from the docker commands since where there is no tag, latest is the default value.
You need to make sure you are working with Docker version higher than 1.5 since RestcommONE docker image relies on some features that were introduced at Docker 1.5 version. The recommended Docker version is 1.6.x.
To download the RestcommONE docker image you need to run:
- latest tag: docker pull mobicents/restcomm
- 7.4.0 tag: docker pull mobicents/restcomm:7.4.0
From time to time, when there is a new Mobicents RestcommONE binary, the latest tag image will be updated. You can use the “docker pull mobicents/restcomm” command to update your local RestcommONE image to the latest image.
Next we have to create a container from the RestcommONE image that will run RestcommONE inside. The RestcommONE docker image supports several environment variables that the container will use to properly configure RestcommONE. Also, RestcommONE docker image provides support for database, recordings, text-to-speech cache and RVD workspace persistence so you don’t lose your work next time you update the RestcommONE docker image or you simply start a new container. For this post we will use only a subset of the available options, but you can find the full set of options at https://hub.docker.com/r/mobicents/restcomm/.
Here will use the simplest way to run the RestcommONE docker image which is:
docker run --name=restcomm -d -e STATIC_ADDRESS="YOUR_HOST_IP_ADDRESS_HERE" -p 8080:8080 -p 5080:5080 -p 5082:5082 -p 5080:5080/udp -p 65000-65535:65000-65535/udp mobicents/restcomm
Some notes for some of the arguments of the above command:
- This container has a name, “restcomm”, so we can use this name with the various docker commands such “docker stop restcomm” or “docker start restcomm” or “docker rm restcomm”
- The “-p” arguments in the above command will make sure to publish container’s ports and link them to the host’s ports. For example “-p 5080:5080/udp” will publish container’s 5080/udp port (SIP UDP) and link it to the host’s 5080/udp port. Same for the HTTP 8080 port, the SIP TCP 5080 port, the SIP WS 5082 port and the RTP port range 65000-65535/udp
- The environment variable STATIC_ADDRESS will be used by RestcommONE to properly setup the Media Server so you can properly establish a call (at SIP and RTP level) with sip clients that are not running in the same machine the docker container is running.
By publishing the proper container’s ports and link them to the host’s ports, we are now able to access RestcommONE that runs in the docker container by using the host’s IP Address.
For example if host IP Address is 192.168.1.1 and RestcommONE container IP Address is 172.17.42.11, to access RestcommONE Administrators user interface you should point your browser to http://192.168.1.1:8080/restcomm-management. Same for the SIP ports, for example if you want to make a call to RestcommONE application 1234, you should send an invite to sip:firstname.lastname@example.org:5080.
IMPORTANT Notice for RestcommONE networking
When using a sip client that is not running on the same machine as the RestcommONE docker image, for example when calling from sip desk phone to RestcommONE docker image, you won’t be able to properly setup the call and receive any RTP traffic, because RestcommONE docker image will be using the ip address of the container, that docker assigned to the container, thus all the SIP and SDP messages will be tagged with the container’s ip address that can’t be reached outside the local machine.
The fix for that is to provide the IP Address of the host machine using the STATIC_ADDRESS environment variable so RestcommONE will properly configured:
docker run -e VOICERSS_KEY="YOUR_VOICESS_KEY_HERE" -e STATIC_ADDRESS="YOUR_HOST_IP_ADDRESS_HERE" --name=restcomm -d -p 8080:8080 -p 5080:5080 -p 5082:5082 -p 5080:5080/udp -p 65000-65535:65000-65535/udp mobicents/restcomm:7.4.0
Using the STATIC_ADDRESS and given that the sip client can reach the host’s ip address, you will be able now to properly setup a call and receive RTP traffic.
Now that we have a RestcommONE container running – check with “docker ps” – we can make a test call. You can use any sip client to make a test call to sip:1234@HOST_IP_ADDRESS:5080 but for now we will use Olympus, the WebRTC client that comes with RestcommONE.
To use Olympus follow the steps bellow:
1. Point your browser to http://HOST_IP_ADDRESS:8080/olympus
2. Press “Sign in”
3. Your browser will ask for permission to share microphone and camera, press allow
4. Go to “Contacts”, click on the “+1234” and press the “Audio Call” button (phone icon)
5. You should hear the “Welcome to RestcommONE, a Telestax Sponsored project” announcement
At this point you have everything you need to start developing RestcommONE applications. You can jump to RestcommONE Visual Designer at http://HOST_IP_ADDRESS:8080/restcomm-rvd and develop an application and later move to RestcommONE Administrator user interface at http://HOST_IP_ADDRESS:8080/restcomm-management to bind your application to a number that you can call using Olympus WebRTC client or any other sip client.
Your feedback is highly appreciated. If you discover any bug or you have an idea for a new feature, we would like to hear from you. Please report RestcommONE bugs and new features at https://github.com/Mobicents/RestComm/issues.
Visit http://www.restcomm.com/ for more news, tutorials and documentation and stay tuned for more, just make sure you subscribe to Telestax newsletter and follow us on Twitter so you miss nothing.