Skip to content

Commit

Permalink
media server docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
Gennadiy Dubina committed Apr 14, 2016
1 parent fcd5084 commit 08a857e
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 14 deletions.
13 changes: 1 addition & 12 deletions .gitignore
@@ -1,12 +1 @@
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
release
23 changes: 23 additions & 0 deletions Dockerfile
@@ -0,0 +1,23 @@
FROM java:7-jdk
MAINTAINER gdubina@dataart.com

RUN apt-get update
RUN apt-get install net-tools

ADD https://mobicents.ci.cloudbees.com/view/MediaServer/job/RestComm-MediaServer-4.x/lastSuccessfulBuild/artifact/bootstrap/target/restcomm-media-server.zip /tmp/restcomm-media-server.zip

ADD https://mobicents.ci.cloudbees.com/view/MediaServer/job/RestComm-MediaServer-4.x/lastSuccessfulBuild/artifact/media-version.txt /tmp/media-version.txt

ENV work_dir /opt/restcomm-media-server

RUN unzip /tmp/restcomm-media-server.zip -d /opt && \
chmod +x $work_dir/bin/run.sh && \
rm /tmp/restcomm-media-server.zip && \
mv /tmp/media-version.txt $work_dir

ADD scripts/configure.sh $work_dir
ADD scripts/run.sh $work_dir

WORKDIR $work_dir
CMD ./run.sh

22 changes: 20 additions & 2 deletions README.md
@@ -1,2 +1,20 @@
# mediaserver-docker
Docker Image for RestComm Media Server at https://github.com/RestComm/mediaserver
# Restcomm MediaServer docker container

Restcomm mediaserver repo - https://github.com/RestComm/mediaserver

###Supported env variables

1. To modify properties in `server-beans.xml` you can use the following template `PROPERTY_xmlpropname`. **Example:** PROPERTY_lowestPort, PROPERTY_highestPort

2. if you run docker container with `--net=host` you should setup `USE_HOST_NETWORK=true`. in this case mediserver will be bound to `eth0` ip address

### Run command example

```shell
docker run --net host -d \
--name restcomm-mediaserver \
-e PROPERTY_lowestPort=64000 \
-e PROPERTY_highestPort=65500 \
-e USE_HOST_NETWORK=true \
-it restcomm-mediaserver
```
9 changes: 9 additions & 0 deletions build.sh
@@ -0,0 +1,9 @@
#!/bin/bash

docker build -t restcomm-mediaserver .

VERSION=`curl -s https://mobicents.ci.cloudbees.com/view/MediaServer/job/RestComm-MediaServer-4.x/lastSuccessfulBuild/artifact/media-version.txt`
echo "MediaServer build version: $VERSION"

docker tag -f restcomm-mediaserver:latest restcomm-mediaserver:$VERSION

10 changes: 10 additions & 0 deletions run.sh
@@ -0,0 +1,10 @@
#!/bin/bash

docker rm -f restcomm-mediaserver

docker run --net host -d \
--name restcomm-mediaserver \
-e PROPERTY_lowestPort=64000 \
-e PROPERTY_highestPort=65500 \
-e USE_HOST_NETWORK=true \
-it restcomm-mediaserver
30 changes: 30 additions & 0 deletions scripts/configure.sh
@@ -0,0 +1,30 @@
#!/bin/bash

BASE_DIR=$work_dir
CONFIG_FILE=$BASE_DIR/deploy/server-beans.xml

if [ -n "$USE_HOST_NETWORK" ]; then
LOCAL_IP=`ifconfig eth0 | awk '/inet addr/{print substr($2,6)}'`
PROPERTY_bindAddress=$LOCAL_IP
PROPERTY_localBindAddress=$LOCAL_IP
fi

set_xml_property () {
local property=$1
local new_value=$2
local xml_file=$3
sed -i "s|<property name=\"$property\">.*</property>|<property name=\"$property\">$new_value</property>|" $xml_file
}

echo "********************************"
echo "*** Configure media server ***"
echo "********************************"

for i in $( set -o posix ; set | grep ^PROPERTY_ | sort -rn ); do
reg=$(echo ${i} | cut -d = -f1 | cut -c 10-)
val=$(echo ${i} | cut -d = -f2)

echo "Update property: $reg -> $val"

set_xml_property $reg $val $CONFIG_FILE
done
5 changes: 5 additions & 0 deletions scripts/run.sh
@@ -0,0 +1,5 @@
#!/bin/bash

. configure.sh

./bin/run.sh

0 comments on commit 08a857e

Please sign in to comment.