diff --git a/.env b/.env index 9dd5e01..5623e6a 100644 --- a/.env +++ b/.env @@ -1,17 +1,20 @@ +# Configure here the private IP of your machine +# It is used by the Media Server to announce it self +# and to configure LAN_MODE ip address +LAN_PRIVATE_IP=192.168.1.60 + # Expose OpenVidu with HTTPS. -USE_TLS=false +USE_HTTPS=true # If true, you can access OpenVidu through your LAN -# If true USE_TLS must be true -LAN_MODE=false +# If true, USE_HTTPS must be true +LAN_MODE=true -# IP Address to expose OpenVidu in your LAN -LAN_PRIVATE_IP=auto -# LiveKit API Key and Secret used for apps to connect to the LiveKit server. -LIVEKIT_API_KEY=key1 -LIVEKIT_API_SECRET=abcdefghijklmnopqrstuvwxyz123456 +# LiveKit API Key and Secret. +LIVEKIT_API_KEY=devkey +LIVEKIT_API_SECRET=secret # Dashboard admin user and password. DASHBOARD_ADMIN_USERNAME=admin diff --git a/README.md b/README.md index 5aef657..604954d 100644 --- a/README.md +++ b/README.md @@ -9,50 +9,34 @@ On **Linux**: - **Docker** - **Docker Compose** -## How to run +## Install + +### Windows ```sh git clone https://github.com/OpenVidu/openvidu-local-deployment cd openvidu-local-deployment +.\configure_lan_private_ip_windows.ps1 +``` + +### Mac + +```sh +git clone https://github.com/OpenVidu/openvidu-local-deployment +cd openvidu-local-deployment +./configure_lan_private_ip_mac.sh +``` + +### Linux + +```sh +git clone https://github.com/OpenVidu/openvidu-local-deployment +cd openvidu-local-deployment +./configure_lan_private_ip_linux.sh +``` + +## Run OpenVidu + +```sh docker compose up ``` - -When the deployment is ready you will see the following message in the logs: - -``` -readycheck | ------------------------ -readycheck | OpenVidu is ready! -readycheck | Open http://localhost:4443/ in your browser -readycheck | ------------------------ -``` - -## Additional Notes - -### LAN Access (Optional) - -If you want to access the deployment in your LAN for Android or iOS devices, you need to do the following: - -1. Get the private IP of your computer in your LAN. -2. Configure your Firewall to allow devices in your LAN to access your computer. -3. Change `LAN_DOMAIN` in the `.env` file to have the IP of your computer in your LAN. - - If your IP for example is `192.168.1.10`, `LAN_DOMAIN` should be `192-168-1-10.openvidu-local.dev`. - -### About `openvidu-local.dev` - -When you develop WebRTC applications, you require a secure context (HTTPS) to access the camera and microphone. This is a requirement of the WebRTC standard. - -With the aim of making it easier to develop with OpenVidu, we provide a magic domain name `openvidu-local.dev` which can resolve to any IP specified as a subdomain and it offers a valid wildcard certificate for HTTPS. It is similar to [nip.io](https://nip.io) or [traefik.me](https://traefik.me) or [localtls](https://github.com/Corollarium/localtls). - -But take into account that this is just as secure as a HTTP connection, so it is not suitable for production environments. - -### Edge cases: - -- Linux: All works just fine -- Windows (Docker desktop): - It looks like there is a little edge case which we are fighting with WSL + Docker. Looks related with this: https://stackoverflow.com/questions/61629450/webrtc-does-not-work-in-the-modern-browsers-when-a-peer-is-not-behind-a-nat-beca - - The behaviour is the following - - **Chrome based browsers**: Looks like everything works fine. ICE protocol finds a path to communicate the browser and openvidu. - - **Firefox browser**: - The only working candidate in Firefox is filtered, I was able to workaround this limitation with `media.peerconnection.ice.obfuscate_host_addresses=false`. diff --git a/caddy-proxy/entrypoint.sh b/caddy-proxy/entrypoint.sh index 94c740b..47b2ed3 100644 --- a/caddy-proxy/entrypoint.sh +++ b/caddy-proxy/entrypoint.sh @@ -11,9 +11,13 @@ if [ ! -f /var/www/index.html ]; then mkdir -p /var/www cp "$TMP_DIR/index.html" /var/www/index.html fi -if [ ! -f /var/www/app502.html ]; then +if [ ! -f /var/www/app502client.html ]; then mkdir -p /var/www - cp "$TMP_DIR/app502.html" /var/www/app502.html + cp "$TMP_DIR/app502client.html" /var/www/app502client.html +fi +if [ ! -f /var/www/app502server.html ]; then + mkdir -p /var/www + cp "$TMP_DIR/app502server.html" /var/www/app502server.html fi if [ ! -f /config/caddy/Caddyfile ]; then mkdir -p /config/caddy diff --git a/caddy-proxy/main.go b/caddy-proxy/main.go index 543e2e9..68b17bf 100644 --- a/caddy-proxy/main.go +++ b/caddy-proxy/main.go @@ -3,18 +3,19 @@ package main import ( "bytes" "fmt" - "html/template" "local-caddy-generate/templates" "os" "strconv" "strings" + "text/template" ) type TemplateData any var indexData = &templates.IndexData{} var caddyData = &templates.CaddyData{} -var app502Data = &templates.App502Data{} +var app502ClientData = &templates.App502Data{} +var app502ServerData = &templates.App502Data{} func main() { err := Initialize() @@ -45,12 +46,23 @@ func main() { os.Exit(1) } - rawApp502, err := GenerateTemplate(templates.App502Template, app502Data) + rawAppClient502, err := GenerateTemplate(templates.App502Template, app502ClientData) if err != nil { fmt.Println(err) os.Exit(1) } - err = WriteStringToFile("app502.html", rawApp502) + err = WriteStringToFile("app502client.html", rawAppClient502) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + rawAppServer502, err := GenerateTemplate(templates.App502Template, app502ServerData) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = WriteStringToFile("app502server.html", rawAppServer502) if err != nil { fmt.Println(err) os.Exit(1) @@ -59,21 +71,30 @@ func main() { } func Initialize() error { - httpPort := 8090 - httpsPort := 4443 - AppPort := 5442 + // OpenVidu && LiveKit API + httpPort := 7880 + httpsPort := 7443 + + // Http ports + appClientPort := 5080 + appClientServer := 6080 + + // Https ports + httpsAppClientPort := 5443 + httpsAppServerPort := 6443 + version := os.Getenv("VERSION") if version == "" { return fmt.Errorf("VERSION is not set") } - rawUseTLS := os.Getenv("USE_TLS") - if rawUseTLS == "" { - rawUseTLS = "false" + rawUseHTTPS := os.Getenv("USE_HTTPS") + if rawUseHTTPS == "" { + rawUseHTTPS = "false" } - useTLS, err := strconv.ParseBool(rawUseTLS) + useTLS, err := strconv.ParseBool(rawUseHTTPS) if err != nil { - return fmt.Errorf("USE_TLS is not a boolean") + return fmt.Errorf("USE_HTTPS is not a boolean") } lanMode := os.Getenv("LAN_MODE") @@ -98,10 +119,20 @@ func Initialize() error { httpUrl := fmt.Sprintf("http://localhost:%d", httpPort) httpsUrl := "" + wsUrl := fmt.Sprintf("ws://localhost:%d", httpPort) + wssUrl := "" + httpsAppClientUrl := "" + httpsAppServerUrl := "" if useTLS { httpsUrl = fmt.Sprintf("https://localhost:%d", httpsPort) + wssUrl = fmt.Sprintf("wss://localhost:%d", httpsPort) + httpsAppClientUrl = fmt.Sprintf("https://localhost:%d", httpsAppClientPort) + httpsAppServerUrl = fmt.Sprintf("https://localhost:%d", httpsAppServerPort) if lanMode == "true" { httpsUrl = fmt.Sprintf("https://%s:%d", lanDomain, httpsPort) + wssUrl = fmt.Sprintf("wss://%s:%d", lanDomain, httpsPort) + httpsAppClientUrl = fmt.Sprintf("https://%s:%d", lanDomain, httpsAppClientPort) + httpsAppServerUrl = fmt.Sprintf("https://%s:%d", lanDomain, httpsAppServerPort) } } @@ -139,6 +170,8 @@ func Initialize() error { LanMode: lanMode == "true", HttpUrl: httpUrl, HttpsUrl: httpsUrl, + WsUrl: wsUrl, + WssUrl: wssUrl, LiveKitApiKey: livekitApiKey, LiveKitApiSecret: livekitApiSecret, OpenViduSecret: openviduSecret, @@ -151,15 +184,30 @@ func Initialize() error { caddyData = &templates.CaddyData{ LanMode: lanMode == "true", LanDomain: lanDomain, - HttpUrl: httpUrl, - HttpsUrl: httpsUrl, + // Main OpenVidu and LiveKit API ports HttpPort: strconv.Itoa(httpPort), HttpsPort: strconv.Itoa(httpsPort), - AppPort: strconv.Itoa(AppPort), + // Main OpenVidu and LiveKit API URLs + HttpUrl: httpUrl, + HttpsUrl: httpsUrl, + // Tutorial ports + AppClientPort: strconv.Itoa(appClientPort), + AppServerPort: strconv.Itoa(appClientServer), + HttpsAppClientPort: strconv.Itoa(httpsAppClientPort), + HttpsAppServerPort: strconv.Itoa(httpsAppServerPort), + // Tutorial URLs + HttpsAppClientUrl: httpsAppClientUrl, + HttpsAppServerUrl: httpsAppServerUrl, } - app502Data = &templates.App502Data{ - AppPort: strconv.Itoa(AppPort), + app502ClientData = &templates.App502Data{ + Title: "Application Client Not Found", + Message: fmt.Sprintf("Run your Application Client at port %d and you will see it here", appClientPort), + } + + app502ServerData = &templates.App502Data{ + Title: "Application Server Not Found", + Message: fmt.Sprintf("Run your Application Server at port %d and you will see it here", appClientServer), } return nil diff --git a/caddy-proxy/templates/app502.go b/caddy-proxy/templates/app502.go index 84d8813..c9cafec 100644 --- a/caddy-proxy/templates/app502.go +++ b/caddy-proxy/templates/app502.go @@ -1,7 +1,8 @@ package templates type App502Data struct { - AppPort string + Title string + Message string } const App502Template = ` @@ -37,14 +38,12 @@ const App502Template = `
502 - Bad Gateway
-

OpenVidu Application Not Found

+

{{.Title}}


-

If you are developing an application and run it locally at port {{.AppPort}}, you will see here your application, under - the same domain and TLS certificate as OpenVidu.

+

{{ .Message }}

- - + ` diff --git a/caddy-proxy/templates/caddy.go b/caddy-proxy/templates/caddy.go index 2148886..fb15789 100644 --- a/caddy-proxy/templates/caddy.go +++ b/caddy-proxy/templates/caddy.go @@ -3,11 +3,20 @@ package templates type CaddyData struct { LanMode bool LanDomain string - HttpUrl string - HttpsUrl string + // Main OpenVidu and LiveKit API ports HttpPort string HttpsPort string - AppPort string + // Main URLs for OpenVidu and LiveKit + HttpUrl string + HttpsUrl string + // Tutorials ports + AppClientPort string + AppServerPort string + HttpsAppClientPort string + HttpsAppServerPort string + // Tutorial URLs + HttpsAppClientUrl string + HttpsAppServerUrl string } const CaddyfileTemplate = ` @@ -28,7 +37,7 @@ const CaddyfileTemplate = ` # OpenVidu v2 API @openvidu_v2 path /openvidu/api/* /openvidu/ws/* handle @openvidu_v2 { - reverse_proxy http://openvidu-v2compatibility:4443 + reverse_proxy http://openvidu-v2compatibility:5080 } # Minio console @@ -53,15 +62,26 @@ const CaddyfileTemplate = ` } } -(custom_app) { +(application_client) { handle_errors { @502 expression {http.error.status_code} == 502 - rewrite @502 /app502.html + rewrite @502 /app502client.html file_server { root /var/www } } - reverse_proxy http://host.docker.internal:{{ .AppPort }} + reverse_proxy http://host.docker.internal:{{ .AppClientPort }} +} + +(application_server) { + handle_errors { + @502 expression {http.error.status_code} == 502 + rewrite @502 /app502server.html + file_server { + root /var/www + } + } + reverse_proxy http://host.docker.internal:{{ .AppServerPort }} } # Servers @@ -73,7 +93,8 @@ const CaddyfileTemplate = ` {{- if .HttpsUrl }} {{- if .LanMode }} -{{.HttpsUrl}} { + +{{ .HttpsUrl }} { {{- if hasSuffix .LanDomain ".openvidu-local.dev" }} tls internal { get_certificate http https://certs.openvidu-local.dev/caddy.pem @@ -82,14 +103,49 @@ const CaddyfileTemplate = ` tls internal {{- end }} import general_rules - import custom_app + import index } + +{{ .HttpsAppClientUrl }} { + {{- if hasSuffix .LanDomain ".openvidu-local.dev" }} + tls internal { + get_certificate http https://certs.openvidu-local.dev/caddy.pem + } + {{- else }} + tls internal + {{- end }} + import application_client +} + +{{ .HttpsAppServerUrl }} { + {{- if hasSuffix .LanDomain ".openvidu-local.dev" }} + tls internal { + get_certificate http https://certs.openvidu-local.dev/caddy.pem + } + {{- else }} + tls internal + {{- end }} + import application_server +} + {{- else }} + https://*:{{.HttpsPort}} { tls internal import general_rules - import custom_app + import index } + +https://*:{{.HttpsAppClientPort}} { + tls internal + import application_client +} + +https://*:{{.HttpsAppServerPort}} { + tls internal + import application_server +} + {{- end }} {{- end}} diff --git a/caddy-proxy/templates/index.go b/caddy-proxy/templates/index.go index 71fff8b..da104cd 100644 --- a/caddy-proxy/templates/index.go +++ b/caddy-proxy/templates/index.go @@ -5,6 +5,8 @@ type IndexData struct { LanMode bool HttpUrl string HttpsUrl string + WsUrl string + WssUrl string DashboardAdminUsername string DashboardAdminPassword string MinioAdminKey string @@ -14,9 +16,9 @@ type IndexData struct { OpenViduSecret string } -const IndexTemplate = ` - +const IndexTemplate = ` + @@ -35,83 +37,58 @@ const IndexTemplate = `
-
-

Welcome to OpenVidu Local Deployment

-

OpenVidu Version: {{ .OpenViduVersion }}

- -
- {{- if .HttpsUrl }} - -

HTTPS URLs

- {{- if .LanMode }} - - {{- end}} - -
- - {{- end }} -

HTTP URLs

- -
- -

Credentials

- +

Welcome to OpenVidu Local Deployment

+

OpenVidu Version: {{.OpenViduVersion}}

+ +
+

OpenVidu Server and LiveKit Server API:

+ +
+

Services and passwords:

+ +
+ ` diff --git a/configure_lan_private_ip_linux.sh b/configure_lan_private_ip_linux.sh new file mode 100755 index 0000000..b4662a9 --- /dev/null +++ b/configure_lan_private_ip_linux.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +getPrivateIp() { + ip="$(ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')" + echo "$ip" +} + +LAN_PRIVATE_IP=$(getPrivateIp) +if [ -z "$LAN_PRIVATE_IP" ]; then + echo "No LAN private IP found" + echo "Specify the LAN private IP in the .env file" + exit 1 +fi + +# Replace the LAN_PRIVATE_IP in the .env file +sed -i "s/LAN_PRIVATE_IP=.*/LAN_PRIVATE_IP=$LAN_PRIVATE_IP/g" .env diff --git a/configure_lan_private_ip_macos.sh b/configure_lan_private_ip_macos.sh new file mode 100755 index 0000000..b168984 --- /dev/null +++ b/configure_lan_private_ip_macos.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +getPrivateIp() { + ip=$(ipconfig getifaddr $(route -n get default | grep interface | awk '{print $2}')) + echo "$ip" +} + +LAN_PRIVATE_IP=$(getPrivateIp) +if [ -z "$LAN_PRIVATE_IP" ]; then + echo "No LAN private IP found" + echo "Specify the LAN private IP in the .env file" + exit 1 +fi + +# Replace the LAN_PRIVATE_IP in the .env file +sed -i "s/LAN_PRIVATE_IP=.*/LAN_PRIVATE_IP=$LAN_PRIVATE_IP/g" .env diff --git a/configure_lan_private_ip_windows.bat b/configure_lan_private_ip_windows.bat new file mode 100755 index 0000000..6b4c5b4 --- /dev/null +++ b/configure_lan_private_ip_windows.bat @@ -0,0 +1,30 @@ +@echo off +call :getPrivateIp +if "%ip%"=="" ( + echo No LAN private IP found + echo Specify the LAN private IP in the .env file + exit /b 1 +) + +:: Replace the LAN_PRIVATE_IP in the .env file +setlocal enabledelayedexpansion +set "tempFile=%temp%\temp_env_%random%.txt" +if exist "%tempFile%" del "%tempFile%" +for /f "tokens=*" %%a in (.env) do ( + set "line=%%a" + if "!line:~0,14!"=="LAN_PRIVATE_IP=" ( + echo LAN_PRIVATE_IP=%ip%>>"%tempFile%" + ) else ( + echo !line!>>"%tempFile%" + ) +) +move /y "%tempFile%" ".env" >nul +endlocal +exit /b 0 + +:getPrivateIp +for /f "tokens=4" %%i in ('route print ^| findstr "\<0.0.0.0\>"') do ( + set ip=%%i + goto :eof +) +goto :eof diff --git a/docker-compose.override.yml b/docker-compose.override.yml index c344719..712a4cb 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -4,7 +4,7 @@ services: container_name: openvidu-call restart: on-failure environment: - - USE_TLS=${USE_TLS:-false} + - USE_HTTPS=${USE_HTTPS:-false} - LAN_MODE=${LAN_MODE:-false} - LAN_DOMAIN=${LAN_DOMAIN:-} - LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-} diff --git a/docker-compose.yaml b/docker-compose.yaml index 64a0ae8..a3a6476 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -10,7 +10,7 @@ services: - LAN_DOMAIN=${LAN_DOMAIN:-} - LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-} - LAN_MODE=${LAN_MODE:-false} - - USE_TLS=${USE_TLS:-false} + - USE_HTTPS=${USE_HTTPS:-false} - LIVEKIT_API_KEY=${LIVEKIT_API_KEY:-} - LIVEKIT_API_SECRET=${LIVEKIT_API_SECRET:-} - DASHBOARD_ADMIN_USERNAME=${DASHBOARD_ADMIN_USERNAME:-} @@ -19,8 +19,10 @@ services: - MINIO_SECRET_KEY=${MINIO_SECRET_KEY:-} - OPENVIDU_SHIM_SECRET=${OPENVIDU_SHIM_SECRET:-} ports: - - 4443:4443 - - 8090:8090 + - 5443:5443 + - 6443:6443 + - 7443:7443 + - 7880:7880 depends_on: setup: condition: service_completed_successfully @@ -43,14 +45,12 @@ services: image: bitnami/minio:2024.3.15-debian-12-r0 container_name: minio restart: unless-stopped - ports: - - 9000:9000 environment: - MINIO_ROOT_USER=${MINIO_ACCESS_KEY:-} - MINIO_ROOT_PASSWORD=${MINIO_SECRET_KEY:-} - MINIO_DEFAULT_BUCKETS=openvidu - MINIO_CONSOLE_SUBPATH=/minio-console - - MINIO_BROWSER_REDIRECT_URL=http://localhost:4443/minio-console/ + - MINIO_BROWSER_REDIRECT_URL=http://localhost:7880/minio-console/ volumes: - ./minio/data:/bitnami/minio/data - minio-certs:/certs @@ -139,11 +139,11 @@ services: container_name: openvidu-v2compatibility entrypoint: /bin/sh /scripts/entrypoint.sh environment: - - USE_TLS=${USE_TLS:-false} + - USE_HTTPS=${USE_HTTPS:-false} - LAN_DOMAIN=${LAN_DOMAIN:-} - LAN_MODE=${LAN_MODE:-false} - LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-} - - SERVER_PORT=4443 + - SERVER_PORT=5080 - OPENVIDU_SHIM_SECRET=${OPENVIDU_SHIM_SECRET:-} - LIVEKIT_URL_PRIVATE=ws://openvidu:7880 - LIVEKIT_API_KEY=${LIVEKIT_API_KEY:-} @@ -169,7 +169,7 @@ services: container_name: ready-check restart: on-failure environment: - - USE_TLS=${USE_TLS:-false} + - USE_HTTPS=${USE_HTTPS:-false} - LAN_DOMAIN=${LAN_DOMAIN:-} - LAN_MODE=${LAN_MODE:-false} - LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-} @@ -202,7 +202,7 @@ services: - ./egress:/egress - ./scripts/setup.sh:/scripts/setup.sh environment: - - USE_TLS=${USE_TLS:-false} + - USE_HTTPS=${USE_HTTPS:-false} - LAN_MODE=${LAN_MODE:-false} - LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-} - RUN_WITH_SCRIPT=${RUN_WITH_SCRIPT:-false} diff --git a/egress.yaml b/egress.yaml index a9eb336..45f5bec 100644 --- a/egress.yaml +++ b/egress.yaml @@ -4,8 +4,8 @@ redis: password: redispassword db: 0 use_tls: false -api_key: key1 -api_secret: abcdefghijklmnopqrstuvwxyz123456 +api_key: devkey +api_secret: secret ws_url: ws://openvidu:7880 health_port: 9091 diff --git a/ingress.yaml b/ingress.yaml index cbe564d..3afefc4 100644 --- a/ingress.yaml +++ b/ingress.yaml @@ -4,8 +4,8 @@ redis: password: redispassword db: 0 use_tls: false -api_key: key1 -api_secret: abcdefghijklmnopqrstuvwxyz123456 +api_key: devkey +api_secret: secret ws_url: ws://openvidu:7880 rtmp_port: 1935 whip_port: 8085 diff --git a/livekit.yaml b/livekit.yaml index 64a8142..7ba2b59 100644 --- a/livekit.yaml +++ b/livekit.yaml @@ -25,11 +25,11 @@ turn: relay_range_start: 40000 relay_range_end: 50000 keys: - key1: abcdefghijklmnopqrstuvwxyz123456 + devkey: secret webhook: - api_key: key1 + api_key: devkey urls: - - http://openvidu-v2compatibility:4443/openvidu/api/webhook + - http://openvidu-v2compatibility:5080/livekit ingress: rtmp_base_url: rtmp://localhost:1935/rtmp whip_base_url: http://localhost:8085/whip diff --git a/openvidu_linux.sh b/openvidu_linux.sh deleted file mode 100755 index 6900b6d..0000000 --- a/openvidu_linux.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh - -showHelp() { - echo "" - echo "Run OpenVidu Local Deployment in Linux" - echo "" - echo "-------" - echo " Usage " - echo "-------" - echo " $0 " - echo "" - echo "----------" - echo " Commands " - echo "----------" - echo " start - Start OpenVidu" - echo " stop - Stop OpenVidu" - echo " help - Show this help" - echo "" -} - -getPrivateIp() { - ip="$(ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')" - echo "$ip" -} - -# Flags -START=false -STOP=false - -if [ -n "${1:-}" ]; then - while :; do - case "${1:-}" in - start) - START=true - shift 1 - break - ;; - stop) - STOP=true - shift 1 - break - ;; - help) - showHelp - exit 0 - ;; - *) - echo "Not a valid command. For usage information: \"$0 help\"" - exit 1 - ;; - esac - done -else - showHelp - exit -fi - -if [ "$START" = "true" ]; then - # Load environment variables - if [ -f .env ]; then - export $(grep -v '^#' .env | xargs) - fi - - if [ "$LAN_PRIVATE_IP" = "auto" ]; then - LAN_PRIVATE_IP="$(getPrivateIp)" - if [ -z "$LAN_PRIVATE_IP" ]; then - LAN_PRIVATE_IP=none - fi - export LAN_PRIVATE_IP - fi - - echo "Starting OpenVidu..." - export RUN_WITH_SCRIPT=true - docker compose down --volumes - docker compose up -fi - -if [ "$STOP" = "true" ]; then - echo "Stopping OpenVidu" - docker compose down --volumes -fi diff --git a/openvidu_macos.sh b/openvidu_macos.sh deleted file mode 100644 index d606269..0000000 --- a/openvidu_macos.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh - -showHelp() { - echo "" - echo "Run OpenVidu Local Deployment in Linux" - echo "" - echo "-------" - echo " Usage " - echo "-------" - echo " $0 " - echo "" - echo "----------" - echo " Commands " - echo "----------" - echo " start - Start OpenVidu" - echo " stop - Stop OpenVidu" - echo " help - Show this help" - echo "" -} - -getPrivateIp() { - ip=$(ipconfig getifaddr $(route -n get default | grep interface | awk '{print $2}')) - echo "$ip" -} - -# Flags -START=false -STOP=false - -if [ -n "${1:-}" ]; then - while :; do - case "${1:-}" in - start) - START=true - shift 1 - break - ;; - stop) - STOP=true - shift 1 - break - ;; - help) - showHelp - exit 0 - ;; - *) - echo "Not a valid command. For usage information: \"$0 help\"" - exit 1 - ;; - esac - done -else - showHelp - exit -fi - -if [ "$START" = "true" ]; then - # Load environment variables - if [ -f .env ]; then - export $(grep -v '^#' .env | xargs) - fi - - if [ "$LAN_PRIVATE_IP" = "auto" ]; then - LAN_PRIVATE_IP="$(getPrivateIp)" - if [ -z "$LAN_PRIVATE_IP" ]; then - LAN_PRIVATE_IP=none - fi - export LAN_PRIVATE_IP - fi - # MongoDB support on Apple Silicon - export EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1 - - echo "Starting OpenVidu..." - export RUN_WITH_SCRIPT=true - docker compose down --volumes - docker compose up -fi - -if [ "$STOP" = "true" ]; then - echo "Stopping OpenVidu" - docker compose down --volumes -fi diff --git a/openvidu_windows.bat b/openvidu_windows.bat deleted file mode 100644 index 8669454..0000000 --- a/openvidu_windows.bat +++ /dev/null @@ -1,79 +0,0 @@ -@echo off -setlocal enabledelayedexpansion - -:: Function to show help -goto :main - -:showHelp -echo. -echo Run OpenVidu Local Deployment in Windows -echo. -echo ------- -echo Usage -echo ------- -echo %~nx0 ^ -echo. -echo ---------- -echo Commands -echo ---------- -echo start - Start OpenVidu -echo stop - Stop OpenVidu -echo help - Show this help -echo. -exit /b 0 - -:getPrivateIp -for /f "tokens=4" %%i in ('route print ^| findstr "\<0.0.0.0\>"') do ( - set ip=%%i - goto :eof -) -goto :eof - -:main -if "%1"=="" ( - call :showHelp - goto :eof -) -if /i "%1"=="start" ( - call :startOpenVidu - goto :eof -) -if /i "%1"=="stop" ( - call :stopOpenVidu - goto :eof -) -if /i "%1"=="help" ( - call :showHelp - goto :eof -) -echo Not a valid command. For usage information: ".\%~nx0 help" -exit /b 0 - - -:startOpenVidu -if exist .env ( - for /f "usebackq tokens=*" %%a in (".env") do ( - echo %%a | findstr /v /b /c:"#" >nul - if not errorlevel 1 set %%a - ) -) - -if "%LAN_PRIVATE_IP%"=="auto" ( - call :getPrivateIp || exit /b 1 - if defined ip ( - set LAN_PRIVATE_IP=!ip! - ) else ( - set LAN_PRIVATE_IP=none - ) -) - -echo Starting OpenVidu... -set RUN_WITH_SCRIPT=true -docker-compose down --volumes || exit /b 1 -docker-compose up || exit /b 1 -exit /b 0 - -:stopOpenVidu -echo Stopping OpenVidu... -docker-compose down --volumes || exit /b 1 -exit /b 0 diff --git a/scripts/ready-check.sh b/scripts/ready-check.sh index 6cb5651..994c256 100644 --- a/scripts/ready-check.sh +++ b/scripts/ready-check.sh @@ -35,7 +35,8 @@ wait_for_service 'Minio' 'http://minio:9000/minio/health/live' wait_for_service 'Minio Console' 'http://minio:9001/minio-console' wait_for_service 'Mongo' 'http://mongo:27017' --connect-timeout 10 --silent -URL=$(getDeploymentUrl) +LAN_HTTP_URL=$(getDeploymentUrl http) +LAN_WS_URL=$(getDeploymentUrl ws) for i in $(seq 1 10); do echo 'Starting OpenVidu... Please be patient...' @@ -43,54 +44,27 @@ for i in $(seq 1 10); do done; echo '' echo '' -echo '------------------------' -echo 'OpenVidu is ready!' -echo '------------------------' +echo '=========================================' +echo '🎉 OpenVidu is ready! 🎉' +echo '=========================================' echo '' -echo '🎉🎉🎉 Welcome Page: http://localhost:8090' 🎉🎉🎉 +echo 'OpenVidu Server && LiveKit Server URLs:' echo '' -echo '------------------------' -if [ "${USE_TLS}" = 'true' ]; then - echo '========================' - echo 'HTTPS services:' - echo '========================' - if [ "${LAN_MODE}" = 'true' ]; then - echo 'NOTE: You can access all of these services on any device' - echo 'connected to the same network as this machine' - fi - echo "- OpenVidu and LiveKit API: ${URL}" - echo "- OpenVidu Dashboard: ${URL}/dashboard" - echo "- Minio Console: ${URL}/minio-console" - echo "- OpenVidu Call: ${URL}/openvidu-call" - echo "- Your App*: ${URL}" - echo " *: Any application deployed at port 5442 will be accessible through ${URL}" -fi +echo ' - From this machine:' echo '' -echo '========================' -echo 'HTTP services:' -echo '========================' -echo "- OpenVidu and LiveKit API: http://localhost:8090" -echo "- OpenVidu Dashboard: http://localhost:8090/dashboard" -echo "- Minio Console: http://localhost:8090/minio-console" -if [ "${USE_TLS}" = 'false' ]; then - echo '- OpenVidu Call: http://localhost:8090/openvidu-call' -fi +echo ' - http://localhost:7880' +echo ' - ws://localhost:7880' echo '' -echo '========================' -echo 'Credentials:' -echo '========================' -echo 'OpenVidu Basic Auth:' -echo ' - Username: OPENVIDUAPP' -echo " - Password: ${OPENVIDU_SHIM_SECRET}" -echo 'LiveKit API:' -echo " - Username: ${LIVEKIT_API_KEY}" -echo " - Password: ${LIVEKIT_API_SECRET}" -echo 'OpenVidu Dashboard:' -echo " - Username: ${DASHBOARD_ADMIN_USERNAME}" -echo " - Password: ${DASHBOARD_ADMIN_PASSWORD}" -echo 'Minio:' -echo " - Access Key: ${MINIO_ACCESS_KEY}" -echo " - Secret Key: ${MINIO_SECRET_KEY}" -echo '------------------------' +echo ' - From other devices in your LAN:' echo '' +echo " - $LAN_HTTP_URL" +echo " - $LAN_WS_URL" echo '' +echo '=========================================' +echo '' +echo 'OpenVidu Developer UI (services and passwords):' +echo '' +echo ' - http://localhost:7880' +echo " - $LAN_HTTP_URL" +echo '' +echo '=========================================' diff --git a/scripts/setup.sh b/scripts/setup.sh index 50e8996..2eafaac 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -1,27 +1,23 @@ #!/bin/sh -if [ "$RUN_WITH_SCRIPT" = 'false' ]; then +if [ -z "$LAN_PRIVATE_IP" ]; then echo '------------------------' echo '' - echo 'Do not run this docker-compose file via "docker compose up" directly.' - echo 'Please run it via the provided scripts.' + echo 'LAN_PRIVATE_IP is required in .env file' + echo 'Depending on your OS, you can run the following command to get your LAN private IP:' echo '' - echo ' - Linux: ./openvidu_linux.sh start' - echo ' - MacOS: ./openvidu_macos.sh start' - echo ' - Windows: ./openvidu_windows.bat start' + echo ' - Linux: ./configure_lan_private_ip_linux.sh' + echo ' - MacOS: ./configure_lan_private_ip_macos.sh' + echo ' - Windows: .\configure_lan_private_ip_windows.bat' echo '' + echo 'The script will automatically update the .env file with the LAN_PRIVATE_IP' + echo 'If it can'\''t be found, you can manually set it in the .env file' echo '------------------------' exit 1 fi -if [ -z "$LAN_PRIVATE_IP" ]; then - echo 'LAN_PRIVATE_IP is required' - echo 'Valid values are: "none", "auto" or a valid IP address' - echo 'Define it in the .env file' - exit 1 -fi -if [ "$LAN_MODE" = 'true' ] && [ "$USE_TLS" = 'false' ]; then - echo 'LAN_MODE cannot be "true" if USE_TLS is "false"' +if [ "$LAN_MODE" = 'true' ] && [ "$USE_HTTPS" = 'false' ]; then + echo 'LAN_MODE cannot be "true" if USE_HTTPS is "false"' exit 1 fi diff --git a/scripts/utils.sh b/scripts/utils.sh index 108b1db..206efa0 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -1,9 +1,10 @@ #!/bin/sh getDeploymentUrl() { - URL="http://localhost:8090" - if [ "${USE_TLS}" = 'true' ]; then - URL="https://localhost:4443" + schema="${1:-http}" + URL="$schema://localhost:7880" + if [ "${USE_HTTPS}" = 'true' ]; then + URL="${schema}s://localhost:7443" fi if [ "${LAN_MODE}" = 'true' ]; then LAN_DOMAIN=${LAN_DOMAIN:-"openvidu-local.dev"} @@ -11,7 +12,7 @@ getDeploymentUrl() { # Replace dots with dashes LAN_DOMAIN="$(echo "$LAN_PRIVATE_IP" | sed 's/\./-/g').openvidu-local.dev" fi - URL="https://${LAN_DOMAIN}:4443" + URL="${schema}s://${LAN_DOMAIN}:7443" fi echo "$URL" }