diff --git a/openvidu-server/docker/openvidu-coturn/Dockerfile b/openvidu-server/docker/openvidu-coturn/Dockerfile index eac2ee94..dbd24bc5 100644 --- a/openvidu-server/docker/openvidu-coturn/Dockerfile +++ b/openvidu-server/docker/openvidu-coturn/Dockerfile @@ -11,4 +11,4 @@ RUN chmod +x /tmp/configuration-files.sh \ && chmod +x /usr/local/bin/entrypoint.sh \ && chmod +x /usr/local/bin/discover_my_public_ip.sh -CMD /usr/local/bin/entrypoint.sh \ No newline at end of file +ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ] \ No newline at end of file diff --git a/openvidu-server/docker/openvidu-coturn/README.md b/openvidu-server/docker/openvidu-coturn/README.md index df542138..fb8a93d6 100644 --- a/openvidu-server/docker/openvidu-coturn/README.md +++ b/openvidu-server/docker/openvidu-coturn/README.md @@ -28,9 +28,15 @@ docker run --rm --name some-redis -d -p 6379:6379 redis Get the ip of the container and after that, run coturn, you can use url as ip too, in this example I am running coturn with nip.io: ``` -docker run -it -e REDIS_IP=172.17.0.2 -e DB_NAME=0 -e DB_PASSWORD=turn -e MIN_PORT=40000 -e MAX_PORT=65535 -e TURN_LISTEN_PORT=3478 --network=host coturn-openvidu +docker run -it -e REDIS_IP=172.17.0.2 -e DB_NAME=0 -e DB_PASSWORD=turn -e MIN_PORT=40000 -e MAX_PORT=65535 -e TURN_LISTEN_PORT=3478 --network=host openvidu/openvidu-coturn ``` +## Execute turn locally with fixed username and password +``` +docker run -it -e TURN_USERNAME_PASSWORD=: -e MIN_PORT=40000 -e MAX_PORT=65535 -e TURN_LISTEN_PORT=3478 --network=host openvidu/openvidu-coturn +``` + + # Kubernetes TODO diff --git a/openvidu-server/docker/openvidu-coturn/configuration-files.sh b/openvidu-server/docker/openvidu-coturn/configuration-files.sh index 3d94420c..18a7b779 100644 --- a/openvidu-server/docker/openvidu-coturn/configuration-files.sh +++ b/openvidu-server/docker/openvidu-coturn/configuration-files.sh @@ -13,9 +13,16 @@ fingerprint lt-cred-mech max-port=${MAX_PORT:-65535} min-port=${MIN_PORT:-40000} +simple-log pidfile="/var/run/turnserver.pid" realm=openvidu -simple-log -redis-userdb="ip=${REDIS_IP} dbname=${DB_NAME} password=${DB_PASSWORD} connect_timeout=30" verbose -EOF \ No newline at end of file +EOF + +if [[ ! -z "${REDIS_IP}" ]] && [[ ! -z "${DB_NAME}" ]] && [[ ! -z "${DB_PASSWORD}" ]]; then + echo "redis-userdb=\"ip=${REDIS_IP} dbname=${DB_NAME} password=${DB_PASSWORD} connect_timeout=30\"" >> /etc/turnserver.conf +fi + +if [[ ! -z "${TURN_USERNAME_PASSWORD}" ]]; then + echo "user=${TURN_USERNAME_PASSWORD}" >> /etc/turnserver.conf +fi \ No newline at end of file diff --git a/openvidu-server/docker/openvidu-coturn/entrypoint.sh b/openvidu-server/docker/openvidu-coturn/entrypoint.sh index 8a87a719..f935fcf0 100644 --- a/openvidu-server/docker/openvidu-coturn/entrypoint.sh +++ b/openvidu-server/docker/openvidu-coturn/entrypoint.sh @@ -12,12 +12,6 @@ echo "TURN public IP: ${TURN_PUBLIC_IP}" [[ ! -z "${TURN_LISTEN_PORT}" ]] && echo "TURN listening port: ${TURN_LISTEN_PORT}" || { echo "TURN_LISTEN_PORT environment variable is not defined"; exit 1; } -[[ ! -z "${REDIS_IP}" ]] && echo "REDIS IP: ${REDIS_IP}" || { echo "REDIS_IP environment variable is not defined"; exit 1; } - -[[ ! -z "${DB_NAME}" ]] || { echo "DB_NAME environment variable is not defined"; exit 1; } - -[[ ! -z "${DB_PASSWORD}" ]] || { echo "DB_PASSWORD environment variable is not defined"; exit 1; } - [[ ! -z "${MIN_PORT}" ]] && echo "Defined min port coturn: ${MIN_PORT}" || echo "Min port coturn: 40000" [[ ! -z "${MAX_PORT}" ]] && echo "Defined max port coturn: ${MAX_PORT}" || echo "Max port coturn: 65535" @@ -28,19 +22,4 @@ source /tmp/configuration-files.sh # Remove temp file with configuration parameters rm /tmp/configuration-files.sh -# Save coturn External IP for other services - - -# Execute turn daemon -/usr/bin/turnserver -c /etc/turnserver.conf -v & - - -MAX_SECONDS=30 -# K8s only show turn server log in this way -while [ -z $(ls /var/log/ | grep turn_) ] && [ $SECONDS -lt $MAX_SECONDS ] -do - echo "Waiting turnserver to be running" - sleep 2 -done - -tail -f /var/log/turn_*.log +/usr/bin/turnserver -c /etc/turnserver.conf -v --log-file /dev/null \ No newline at end of file