From 7ac710b94e58ef1e83b7f305ffbe6f005673b060 Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Wed, 24 Apr 2024 16:29:52 +0200 Subject: [PATCH] community and pro folders --- README.md | 56 +++- .env => community/.env | 0 .gitattributes => community/.gitattributes | 0 .gitignore => community/.gitignore | 0 .../caddy-proxy}/Dockerfile | 0 .../caddy-proxy}/README.md | 0 .../caddy-proxy}/entrypoint.sh | 0 {caddy-proxy => community/caddy-proxy}/go.mod | 0 .../caddy-proxy}/main.go | 0 .../caddy-proxy}/templates/app502.go | 0 .../caddy-proxy}/templates/caddy.go | 0 .../caddy-proxy}/templates/index.go | 0 .../configure_lan_private_ip_linux.sh | 0 .../configure_lan_private_ip_macos.sh | 0 .../configure_lan_private_ip_windows.bat | 0 .../custom-layout}/index.html | 0 .../docker-compose.override.yaml | 0 community/docker-compose.yaml | 199 ++++++++++++++ egress.yaml => community/egress.yaml | 0 ingress.yaml => community/ingress.yaml | 0 livekit.yaml => community/livekit.yaml | 0 .../scripts}/entrypoint_default_app.sh | 0 .../scripts}/entrypoint_openvidu.sh | 0 .../scripts}/entrypoint_v2comp.sh | 0 {scripts => community/scripts}/ready-check.sh | 0 {scripts => community/scripts}/setup.sh | 0 {scripts => community/scripts}/utils.sh | 0 pro/.env | 35 +++ pro/.gitattributes | 1 + pro/.gitignore | 3 + pro/caddy-proxy/Dockerfile | 23 ++ pro/caddy-proxy/README.md | 7 + pro/caddy-proxy/entrypoint.sh | 30 +++ pro/caddy-proxy/go.mod | 3 + pro/caddy-proxy/main.go | 249 ++++++++++++++++++ pro/caddy-proxy/templates/app502.go | 49 ++++ pro/caddy-proxy/templates/caddy.go | 160 +++++++++++ pro/caddy-proxy/templates/index.go | 100 +++++++ pro/configure_lan_private_ip_linux.sh | 16 ++ pro/configure_lan_private_ip_macos.sh | 27 ++ pro/configure_lan_private_ip_windows.bat | 34 +++ pro/custom-layout/index.html | 11 + pro/docker-compose.override.yaml | 26 ++ .../docker-compose.yaml | 4 +- pro/egress.yaml | 23 ++ pro/ingress.yaml | 19 ++ pro/livekit.yaml | 44 ++++ pro/scripts/entrypoint_default_app.sh | 8 + pro/scripts/entrypoint_openvidu.sh | 20 ++ pro/scripts/entrypoint_v2comp.sh | 8 + pro/scripts/ready-check.sh | 70 +++++ pro/scripts/setup.sh | 33 +++ pro/scripts/utils.sh | 18 ++ 53 files changed, 1267 insertions(+), 9 deletions(-) rename .env => community/.env (100%) rename .gitattributes => community/.gitattributes (100%) rename .gitignore => community/.gitignore (100%) rename {caddy-proxy => community/caddy-proxy}/Dockerfile (100%) rename {caddy-proxy => community/caddy-proxy}/README.md (100%) rename {caddy-proxy => community/caddy-proxy}/entrypoint.sh (100%) rename {caddy-proxy => community/caddy-proxy}/go.mod (100%) rename {caddy-proxy => community/caddy-proxy}/main.go (100%) rename {caddy-proxy => community/caddy-proxy}/templates/app502.go (100%) rename {caddy-proxy => community/caddy-proxy}/templates/caddy.go (100%) rename {caddy-proxy => community/caddy-proxy}/templates/index.go (100%) rename configure_lan_private_ip_linux.sh => community/configure_lan_private_ip_linux.sh (100%) rename configure_lan_private_ip_macos.sh => community/configure_lan_private_ip_macos.sh (100%) rename configure_lan_private_ip_windows.bat => community/configure_lan_private_ip_windows.bat (100%) rename {custom-layout => community/custom-layout}/index.html (100%) rename docker-compose.override.yml => community/docker-compose.override.yaml (100%) create mode 100644 community/docker-compose.yaml rename egress.yaml => community/egress.yaml (100%) rename ingress.yaml => community/ingress.yaml (100%) rename livekit.yaml => community/livekit.yaml (100%) rename {scripts => community/scripts}/entrypoint_default_app.sh (100%) rename {scripts => community/scripts}/entrypoint_openvidu.sh (100%) rename {scripts => community/scripts}/entrypoint_v2comp.sh (100%) rename {scripts => community/scripts}/ready-check.sh (100%) rename {scripts => community/scripts}/setup.sh (100%) rename {scripts => community/scripts}/utils.sh (100%) create mode 100644 pro/.env create mode 100644 pro/.gitattributes create mode 100644 pro/.gitignore create mode 100644 pro/caddy-proxy/Dockerfile create mode 100644 pro/caddy-proxy/README.md create mode 100644 pro/caddy-proxy/entrypoint.sh create mode 100644 pro/caddy-proxy/go.mod create mode 100644 pro/caddy-proxy/main.go create mode 100644 pro/caddy-proxy/templates/app502.go create mode 100644 pro/caddy-proxy/templates/caddy.go create mode 100644 pro/caddy-proxy/templates/index.go create mode 100755 pro/configure_lan_private_ip_linux.sh create mode 100755 pro/configure_lan_private_ip_macos.sh create mode 100755 pro/configure_lan_private_ip_windows.bat create mode 100644 pro/custom-layout/index.html create mode 100644 pro/docker-compose.override.yaml rename docker-compose.yaml => pro/docker-compose.yaml (98%) create mode 100644 pro/egress.yaml create mode 100644 pro/ingress.yaml create mode 100644 pro/livekit.yaml create mode 100644 pro/scripts/entrypoint_default_app.sh create mode 100644 pro/scripts/entrypoint_openvidu.sh create mode 100644 pro/scripts/entrypoint_v2comp.sh create mode 100644 pro/scripts/ready-check.sh create mode 100644 pro/scripts/setup.sh create mode 100644 pro/scripts/utils.sh diff --git a/README.md b/README.md index 7ae932d..a934834 100644 --- a/README.md +++ b/README.md @@ -9,34 +9,74 @@ On **Linux**: - **Docker** - **Docker Compose** -## Install +--- -### Windows +## OpenVidu COMMUNITY + +### Install OpenVidu COMMUNITY + +#### Windows ```sh git clone https://github.com/OpenVidu/openvidu-local-deployment -cd openvidu-local-deployment +cd openvidu-local-deployment/community .\configure_lan_private_ip_windows.bat ``` -### Mac +#### Mac ```sh git clone https://github.com/OpenVidu/openvidu-local-deployment -cd openvidu-local-deployment +cd openvidu-local-deployment/community ./configure_lan_private_ip_mac.sh ``` -### Linux +#### Linux ```sh git clone https://github.com/OpenVidu/openvidu-local-deployment -cd openvidu-local-deployment +cd openvidu-local-deployment/community ./configure_lan_private_ip_linux.sh ``` -## Run OpenVidu +### Run OpenVidu COMMUNITY ```sh docker compose up ``` + +--- + +## OpenVidu PRO + +### Install OpenVidu PRO + +#### Windows + +```sh +git clone https://github.com/OpenVidu/openvidu-local-deployment +cd openvidu-local-deployment/pro +.\configure_lan_private_ip_windows.bat +``` + +#### Mac + +```sh +git clone https://github.com/OpenVidu/openvidu-local-deployment +cd openvidu-local-deployment/pro +./configure_lan_private_ip_mac.sh +``` + +#### Linux + +```sh +git clone https://github.com/OpenVidu/openvidu-local-deployment +cd openvidu-local-deployment/pro +./configure_lan_private_ip_linux.sh +``` + +### Run OpenVidu PRO + +```sh +docker compose up +``` \ No newline at end of file diff --git a/.env b/community/.env similarity index 100% rename from .env rename to community/.env diff --git a/.gitattributes b/community/.gitattributes similarity index 100% rename from .gitattributes rename to community/.gitattributes diff --git a/.gitignore b/community/.gitignore similarity index 100% rename from .gitignore rename to community/.gitignore diff --git a/caddy-proxy/Dockerfile b/community/caddy-proxy/Dockerfile similarity index 100% rename from caddy-proxy/Dockerfile rename to community/caddy-proxy/Dockerfile diff --git a/caddy-proxy/README.md b/community/caddy-proxy/README.md similarity index 100% rename from caddy-proxy/README.md rename to community/caddy-proxy/README.md diff --git a/caddy-proxy/entrypoint.sh b/community/caddy-proxy/entrypoint.sh similarity index 100% rename from caddy-proxy/entrypoint.sh rename to community/caddy-proxy/entrypoint.sh diff --git a/caddy-proxy/go.mod b/community/caddy-proxy/go.mod similarity index 100% rename from caddy-proxy/go.mod rename to community/caddy-proxy/go.mod diff --git a/caddy-proxy/main.go b/community/caddy-proxy/main.go similarity index 100% rename from caddy-proxy/main.go rename to community/caddy-proxy/main.go diff --git a/caddy-proxy/templates/app502.go b/community/caddy-proxy/templates/app502.go similarity index 100% rename from caddy-proxy/templates/app502.go rename to community/caddy-proxy/templates/app502.go diff --git a/caddy-proxy/templates/caddy.go b/community/caddy-proxy/templates/caddy.go similarity index 100% rename from caddy-proxy/templates/caddy.go rename to community/caddy-proxy/templates/caddy.go diff --git a/caddy-proxy/templates/index.go b/community/caddy-proxy/templates/index.go similarity index 100% rename from caddy-proxy/templates/index.go rename to community/caddy-proxy/templates/index.go diff --git a/configure_lan_private_ip_linux.sh b/community/configure_lan_private_ip_linux.sh similarity index 100% rename from configure_lan_private_ip_linux.sh rename to community/configure_lan_private_ip_linux.sh diff --git a/configure_lan_private_ip_macos.sh b/community/configure_lan_private_ip_macos.sh similarity index 100% rename from configure_lan_private_ip_macos.sh rename to community/configure_lan_private_ip_macos.sh diff --git a/configure_lan_private_ip_windows.bat b/community/configure_lan_private_ip_windows.bat similarity index 100% rename from configure_lan_private_ip_windows.bat rename to community/configure_lan_private_ip_windows.bat diff --git a/custom-layout/index.html b/community/custom-layout/index.html similarity index 100% rename from custom-layout/index.html rename to community/custom-layout/index.html diff --git a/docker-compose.override.yml b/community/docker-compose.override.yaml similarity index 100% rename from docker-compose.override.yml rename to community/docker-compose.override.yaml diff --git a/community/docker-compose.yaml b/community/docker-compose.yaml new file mode 100644 index 0000000..77e0a63 --- /dev/null +++ b/community/docker-compose.yaml @@ -0,0 +1,199 @@ +services: + + caddy-proxy: + image: docker.io/wcm65pck/openvidu-caddy-local:main + container_name: caddy-proxy + restart: unless-stopped + extra_hosts: + - host.docker.internal:host-gateway + environment: + - LAN_DOMAIN=${LAN_DOMAIN:-} + - LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-} + - LAN_MODE=${LAN_MODE:-false} + - USE_HTTPS=${USE_HTTPS:-false} + - LIVEKIT_API_KEY=${LIVEKIT_API_KEY:-} + - LIVEKIT_API_SECRET=${LIVEKIT_API_SECRET:-} + - DASHBOARD_ADMIN_USERNAME=${DASHBOARD_ADMIN_USERNAME:-} + - DASHBOARD_ADMIN_PASSWORD=${DASHBOARD_ADMIN_PASSWORD:-} + - MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY:-} + - MINIO_SECRET_KEY=${MINIO_SECRET_KEY:-} + - OPENVIDU_SHIM_SECRET=${OPENVIDU_SHIM_SECRET:-} + volumes: + - ./custom-layout:/var/www/custom-layout + ports: + - 5443:5443 + - 6443:6443 + - 7443:7443 + - 7880:7880 + depends_on: + setup: + condition: service_completed_successfully + + redis: + image: redis:7.2.4-alpine + container_name: redis + restart: unless-stopped + ports: + - 6379:6379 + volumes: + - redis:/data + command: > + redis-server + --bind 0.0.0.0 + --requirepass ${REDIS_PASSWORD:-} + depends_on: + setup: + condition: service_completed_successfully + + minio: + 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:7880/minio-console + volumes: + - minio-data:/bitnami/minio/data + - minio-certs:/certs + depends_on: + setup: + condition: service_completed_successfully + + mongo: + image: bitnami/mongodb:7.0.6-debian-12-r0 + container_name: mongo + restart: unless-stopped + ports: + - 27017:27017 + volumes: + - mongo-data:/bitnami/mongodb + environment: + - MONGODB_ROOT_USER=${MONGO_ADMIN_USERNAME:-} + - MONGODB_ROOT_PASSWORD=${MONGO_ADMIN_PASSWORD:-} + - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=${EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU:-0} + depends_on: + setup: + condition: service_completed_successfully + + dashboard: + image: docker.io/wcm65pck/openvidu-dashboard:main + container_name: dashboard + restart: unless-stopped + environment: + - SERVER_PORT=5000 + - ADMIN_USERNAME=${DASHBOARD_ADMIN_USERNAME:-} + - ADMIN_PASSWORD=${DASHBOARD_ADMIN_PASSWORD:-} + - DATABASE_URL=mongodb://mongoadmin:mongoadmin@mongo:27017 + depends_on: + setup: + condition: service_completed_successfully + + openvidu: + image: docker.io/wcm65pck/openvidu-livekit:main + restart: unless-stopped + container_name: openvidu + extra_hosts: + - host.docker.internal:host-gateway + environment: + - LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-} + ports: + - 3478:3478/udp + - 7881:7881/tcp + - 7882-7892:7882-7892/udp + entrypoint: /bin/sh /scripts/entrypoint.sh + command: --config /etc/livekit.yaml + volumes: + - ./livekit.yaml:/tmp/livekit.yaml + - ./scripts/entrypoint_openvidu.sh:/scripts/entrypoint.sh + depends_on: + setup: + condition: service_completed_successfully + + ingress: + image: livekit/ingress:v1.2.0 + container_name: ingress + restart: unless-stopped + ports: + - 1935:1935 + - 8085:8085 + - 7895:7895/udp + environment: + - INGRESS_CONFIG_FILE=/etc/ingress.yaml + volumes: + - ./ingress.yaml:/etc/ingress.yaml + depends_on: + setup: + condition: service_completed_successfully + + egress: + image: livekit/egress:v1.8.2 + restart: unless-stopped + container_name: egress + extra_hosts: + - host.docker.internal:host-gateway + environment: + - EGRESS_CONFIG_FILE=/etc/egress.yaml + volumes: + - ./egress.yaml:/etc/egress.yaml + - egress-data:/home/egress + depends_on: + setup: + condition: service_completed_successfully + + ready-check: + image: curlimages/curl:8.6.0 + container_name: ready-check + restart: on-failure + environment: + - USE_HTTPS=${USE_HTTPS:-false} + - LAN_DOMAIN=${LAN_DOMAIN:-} + - LAN_MODE=${LAN_MODE:-false} + - LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-} + - OPENVIDU_SHIM_SECRET=${OPENVIDU_SHIM_SECRET:-} + - LIVEKIT_API_KEY=${LIVEKIT_API_KEY:-} + - LIVEKIT_API_SECRET=${LIVEKIT_API_SECRET:-} + - DASHBOARD_ADMIN_USERNAME=${DASHBOARD_ADMIN_USERNAME:-} + - DASHBOARD_ADMIN_PASSWORD=${DASHBOARD_ADMIN_PASSWORD:-} + - MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY:-} + - MINIO_SECRET_KEY=${MINIO_SECRET_KEY:-} + depends_on: + - openvidu + - ingress + - egress + - dashboard + - minio + - mongo + volumes: + - ./scripts/ready-check.sh:/scripts/ready-check.sh + - ./scripts/utils.sh:/scripts/utils.sh + command: /bin/sh /scripts/ready-check.sh + + setup: + image: busybox + container_name: setup + restart: "no" + volumes: + - minio-data:/minio + - mongo-data:/mongo + - egress-data:/egress + - ./scripts/setup.sh:/scripts/setup.sh + environment: + - USE_HTTPS=${USE_HTTPS:-false} + - LAN_MODE=${LAN_MODE:-false} + - LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-} + - RUN_WITH_SCRIPT=${RUN_WITH_SCRIPT:-false} + user: root + command: /bin/sh /scripts/setup.sh + +volumes: + minio-certs: + mongodb-config: + redis: + minio-data: + mongo-data: + egress-data: diff --git a/egress.yaml b/community/egress.yaml similarity index 100% rename from egress.yaml rename to community/egress.yaml diff --git a/ingress.yaml b/community/ingress.yaml similarity index 100% rename from ingress.yaml rename to community/ingress.yaml diff --git a/livekit.yaml b/community/livekit.yaml similarity index 100% rename from livekit.yaml rename to community/livekit.yaml diff --git a/scripts/entrypoint_default_app.sh b/community/scripts/entrypoint_default_app.sh similarity index 100% rename from scripts/entrypoint_default_app.sh rename to community/scripts/entrypoint_default_app.sh diff --git a/scripts/entrypoint_openvidu.sh b/community/scripts/entrypoint_openvidu.sh similarity index 100% rename from scripts/entrypoint_openvidu.sh rename to community/scripts/entrypoint_openvidu.sh diff --git a/scripts/entrypoint_v2comp.sh b/community/scripts/entrypoint_v2comp.sh similarity index 100% rename from scripts/entrypoint_v2comp.sh rename to community/scripts/entrypoint_v2comp.sh diff --git a/scripts/ready-check.sh b/community/scripts/ready-check.sh similarity index 100% rename from scripts/ready-check.sh rename to community/scripts/ready-check.sh diff --git a/scripts/setup.sh b/community/scripts/setup.sh similarity index 100% rename from scripts/setup.sh rename to community/scripts/setup.sh diff --git a/scripts/utils.sh b/community/scripts/utils.sh similarity index 100% rename from scripts/utils.sh rename to community/scripts/utils.sh diff --git a/pro/.env b/pro/.env new file mode 100644 index 0000000..577ae5a --- /dev/null +++ b/pro/.env @@ -0,0 +1,35 @@ + +# 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.52 + +# Expose OpenVidu with HTTPS. +USE_HTTPS=true + +# If true, you can access OpenVidu through your LAN +# If true, USE_HTTPS must be true +LAN_MODE=true + + +# LiveKit API Key and Secret. +LIVEKIT_API_KEY=devkey +LIVEKIT_API_SECRET=secret + +# Dashboard admin user and password. +DASHBOARD_ADMIN_USERNAME=admin +DASHBOARD_ADMIN_PASSWORD=admin + +# Redis password. +REDIS_PASSWORD=redispassword + +# Minio configuration. +MINIO_ACCESS_KEY=minioadmin +MINIO_SECRET_KEY=minioadmin + +# Mongo configuration. +MONGO_ADMIN_USERNAME=mongoadmin +MONGO_ADMIN_PASSWORD=mongoadmin + +# Openvidu v2 compatibility configuration +OPENVIDU_SHIM_SECRET=MY_SECRET diff --git a/pro/.gitattributes b/pro/.gitattributes new file mode 100644 index 0000000..94f480d --- /dev/null +++ b/pro/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf \ No newline at end of file diff --git a/pro/.gitignore b/pro/.gitignore new file mode 100644 index 0000000..f318709 --- /dev/null +++ b/pro/.gitignore @@ -0,0 +1,3 @@ +egress/ +minio/ +mongo/ diff --git a/pro/caddy-proxy/Dockerfile b/pro/caddy-proxy/Dockerfile new file mode 100644 index 0000000..c8b5adb --- /dev/null +++ b/pro/caddy-proxy/Dockerfile @@ -0,0 +1,23 @@ +FROM golang:1.22.1 as builder + +ARG TARGETOS +ARG TARGETPLATFORM +ARG TARGETARCH + +WORKDIR /workspace +COPY . . +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build + +FROM caddy/caddy:2.7.6-alpine + +ARG VERSION +RUN test -n "$VERSION" || (echo "VERSION arg is not set" && false) +ENV VERSION $VERSION + +COPY --from=builder /workspace/local-caddy-generate /usr/bin/local-caddy-generate +COPY --from=builder /workspace/entrypoint.sh /entrypoint.sh +RUN chmod +x /usr/bin/local-caddy-generate /entrypoint.sh + +# Run the binary. +ENTRYPOINT ["/entrypoint.sh"] +CMD ["/usr/bin/caddy", "run", "--config", "/config/caddy/Caddyfile"] diff --git a/pro/caddy-proxy/README.md b/pro/caddy-proxy/README.md new file mode 100644 index 0000000..8a5d447 --- /dev/null +++ b/pro/caddy-proxy/README.md @@ -0,0 +1,7 @@ +# OpenVidu Local Deployment - Cadddy Proxy + +If you want to modify any of the rules at the caddy-proxy container, just build the image again and run the local deployment with the new image. + +```bash +docker build --build-arg VERSION=custom -t caddy-proxy . +``` diff --git a/pro/caddy-proxy/entrypoint.sh b/pro/caddy-proxy/entrypoint.sh new file mode 100644 index 0000000..47b2ed3 --- /dev/null +++ b/pro/caddy-proxy/entrypoint.sh @@ -0,0 +1,30 @@ +#!/bin/sh +set -e + +# Generate Caddyfile and index.html +CURRENT_DIR="$(pwd)" +TMP_DIR="/tmp/caddy-local" +mkdir -p "$TMP_DIR" +cd "$TMP_DIR" +/usr/bin/local-caddy-generate +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/app502client.html ]; then + mkdir -p /var/www + 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 + cp "$TMP_DIR/Caddyfile" /config/caddy/Caddyfile +fi +cd "$CURRENT_DIR" +rm -rf /tmp/caddy-local + +# Start Caddy +exec "$@" diff --git a/pro/caddy-proxy/go.mod b/pro/caddy-proxy/go.mod new file mode 100644 index 0000000..d8863f0 --- /dev/null +++ b/pro/caddy-proxy/go.mod @@ -0,0 +1,3 @@ +module local-caddy-generate + +go 1.22.1 diff --git a/pro/caddy-proxy/main.go b/pro/caddy-proxy/main.go new file mode 100644 index 0000000..68b17bf --- /dev/null +++ b/pro/caddy-proxy/main.go @@ -0,0 +1,249 @@ +package main + +import ( + "bytes" + "fmt" + "local-caddy-generate/templates" + "os" + "strconv" + "strings" + "text/template" +) + +type TemplateData any + +var indexData = &templates.IndexData{} +var caddyData = &templates.CaddyData{} +var app502ClientData = &templates.App502Data{} +var app502ServerData = &templates.App502Data{} + +func main() { + err := Initialize() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + rawIndex, err := GenerateTemplate(templates.IndexTemplate, indexData) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = WriteStringToFile("index.html", rawIndex) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + rawCaddyfile, err := GenerateTemplate(templates.CaddyfileTemplate, caddyData) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = WriteStringToFile("Caddyfile", rawCaddyfile) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + rawAppClient502, err := GenerateTemplate(templates.App502Template, app502ClientData) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + 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) + } + +} + +func Initialize() error { + // 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") + } + + rawUseHTTPS := os.Getenv("USE_HTTPS") + if rawUseHTTPS == "" { + rawUseHTTPS = "false" + } + useTLS, err := strconv.ParseBool(rawUseHTTPS) + if err != nil { + return fmt.Errorf("USE_HTTPS is not a boolean") + } + + lanMode := os.Getenv("LAN_MODE") + if lanMode == "" { + lanMode = "false" + } + + lanPrivateIP := os.Getenv("LAN_PRIVATE_IP") + if lanPrivateIP == "" { + return fmt.Errorf("LAN_PRIVATE_IP is not set") + } + + lanDomain := os.Getenv("LAN_DOMAIN") + if lanDomain == "" { + lanDomain = "openvidu-local.dev" + } + + if lanPrivateIP != "none" && lanDomain == "openvidu-local.dev" { + ipDashes := strings.ReplaceAll(lanPrivateIP, ".", "-") + lanDomain = fmt.Sprintf("%s.%s", ipDashes, lanDomain) + } + + 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) + } + } + + livekitApiKey := os.Getenv("LIVEKIT_API_KEY") + if livekitApiKey == "" { + return fmt.Errorf("LIVEKIT_API_KEY is not set") + } + livekitApiSecret := os.Getenv("LIVEKIT_API_SECRET") + if livekitApiSecret == "" { + return fmt.Errorf("LIVEKIT_API_SECRET is not set") + } + openviduSecret := os.Getenv("OPENVIDU_SHIM_SECRET") + if openviduSecret == "" { + return fmt.Errorf("OPENVIDU_SHIM_SECRET is not set") + } + dashboadAdminUsername := os.Getenv("DASHBOARD_ADMIN_USERNAME") + if dashboadAdminUsername == "" { + return fmt.Errorf("DASHBOARD_ADMIN_USERNAME is not set") + } + dashboardAdminPassword := os.Getenv("DASHBOARD_ADMIN_PASSWORD") + if dashboardAdminPassword == "" { + return fmt.Errorf("DASHBOARD_ADMIN_PASSWORD is not set") + } + minioAccessKey := os.Getenv("MINIO_ACCESS_KEY") + if minioAccessKey == "" { + return fmt.Errorf("MINIO_ACCESS_KEY is not set") + } + minioSecretKey := os.Getenv("MINIO_SECRET_KEY") + if minioSecretKey == "" { + return fmt.Errorf("MINIO_SECRET_KEY is not set") + } + + indexData = &templates.IndexData{ + OpenViduVersion: version, + LanMode: lanMode == "true", + HttpUrl: httpUrl, + HttpsUrl: httpsUrl, + WsUrl: wsUrl, + WssUrl: wssUrl, + LiveKitApiKey: livekitApiKey, + LiveKitApiSecret: livekitApiSecret, + OpenViduSecret: openviduSecret, + DashboardAdminUsername: dashboadAdminUsername, + DashboardAdminPassword: dashboardAdminPassword, + MinioAdminKey: minioAccessKey, + MinioAdminSecret: minioSecretKey, + } + + caddyData = &templates.CaddyData{ + LanMode: lanMode == "true", + LanDomain: lanDomain, + // Main OpenVidu and LiveKit API ports + HttpPort: strconv.Itoa(httpPort), + HttpsPort: strconv.Itoa(httpsPort), + // 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, + } + + 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 + +} + +func GenerateTemplate(templateString string, data TemplateData) (string, error) { + funcs := map[string]any{ + "contains": strings.Contains, + "hasPrefix": strings.HasPrefix, + "hasSuffix": strings.HasSuffix} + + tmpl, err := template.New("template").Funcs(funcs).Parse(templateString) + if err != nil { + return "", err + } + + var buf bytes.Buffer + if err := tmpl.Execute(&buf, data); err != nil { + return "", err + } + + return buf.String(), nil +} + +func WriteStringToFile(filePath string, data string) error { + file, err := os.Create(filePath) + if err != nil { + return err + } + defer file.Close() + + _, err = file.WriteString(data) + if err != nil { + return err + } + + return nil +} diff --git a/pro/caddy-proxy/templates/app502.go b/pro/caddy-proxy/templates/app502.go new file mode 100644 index 0000000..c9cafec --- /dev/null +++ b/pro/caddy-proxy/templates/app502.go @@ -0,0 +1,49 @@ +package templates + +type App502Data struct { + Title string + Message string +} + +const App502Template = ` + + + + + 502 - Application Not Found + + + + + + +
+
+
502 - Bad Gateway
+

{{.Title}}

+
+

{{ .Message }}

+
+
+ + + +` diff --git a/pro/caddy-proxy/templates/caddy.go b/pro/caddy-proxy/templates/caddy.go new file mode 100644 index 0000000..0818fb0 --- /dev/null +++ b/pro/caddy-proxy/templates/caddy.go @@ -0,0 +1,160 @@ +package templates + +type CaddyData struct { + LanMode bool + LanDomain string + // Main OpenVidu and LiveKit API ports + HttpPort string + HttpsPort 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 = ` +(index) { + # Default / + handle_path /* { + root * /var/www/ + file_server + } +} +(general_rules) { + # LiveKit API + @openvidu path /twirp/* /rtc/* /rtc + handle @openvidu { + reverse_proxy http://openvidu:7880 + } + + # OpenVidu v2 API + @openvidu_v2 path /openvidu/api/* /openvidu/ws/* + handle @openvidu_v2 { + reverse_proxy http://host.docker.internal:4443 + } + + # OpenVidu v2 Custom layout + redir /openvidu/layouts /openvidu/layouts/ + handle_path /openvidu/layouts/* { + uri strip_prefix /openvidu/layouts + root * /var/www/custom-layout + file_server + } + + # Minio console + redir /minio-console /minio-console/ + handle_path /minio-console/* { + uri strip_prefix /minio-console + reverse_proxy http://minio:9001 + } + + # OpenVidu Dashboard + redir /dashboard /dashboard/ + handle_path /dashboard/* { + rewrite * {path} + reverse_proxy http://dashboard:5000 + } + + # OpenVidu Call (Default App) + redir /openvidu-call /openvidu-call/ + handle_path /openvidu-call/* { + rewrite * {path} + reverse_proxy http://default-app:5442 + } + +} +(application_client) { + handle_errors { + @502 expression {http.error.status_code} == 502 + rewrite @502 /app502client.html + file_server { + root /var/www + } + } + 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 +:{{.HttpPort}} { + import general_rules + import index +} + +{{- if .HttpsUrl }} + +{{- if .LanMode }} + +{{ .HttpsUrl }} { + {{- if hasSuffix .LanDomain ".openvidu-local.dev" }} + tls internal { + get_certificate http https://certs.openvidu-local.dev/caddy.pem + } + {{- else }} + tls internal + {{- end }} + import general_rules + 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 index +} + +https://*:{{.HttpsAppClientPort}} { + tls internal + import application_client +} + +https://*:{{.HttpsAppServerPort}} { + tls internal + import application_server +} + +{{- end }} + +{{- end}} +` diff --git a/pro/caddy-proxy/templates/index.go b/pro/caddy-proxy/templates/index.go new file mode 100644 index 0000000..65ff1a5 --- /dev/null +++ b/pro/caddy-proxy/templates/index.go @@ -0,0 +1,100 @@ +package templates + +type IndexData struct { + OpenViduVersion string + LanMode bool + HttpUrl string + HttpsUrl string + WsUrl string + WssUrl string + DashboardAdminUsername string + DashboardAdminPassword string + MinioAdminKey string + MinioAdminSecret string + LiveKitApiKey string + LiveKitApiSecret string + OpenViduSecret string +} + +const IndexTemplate = ` + + + + + + OpenVidu Local Deployment + + + + + + + +
+

Welcome to OpenVidu Local Deployment

+

OpenVidu Version: {{.OpenViduVersion}}

+ +
+

OpenVidu Server and LiveKit Server API:

+ +
+

Services and passwords:

+ +
+ + + +` diff --git a/pro/configure_lan_private_ip_linux.sh b/pro/configure_lan_private_ip_linux.sh new file mode 100755 index 0000000..b4662a9 --- /dev/null +++ b/pro/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/pro/configure_lan_private_ip_macos.sh b/pro/configure_lan_private_ip_macos.sh new file mode 100755 index 0000000..fdb8a37 --- /dev/null +++ b/pro/configure_lan_private_ip_macos.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +getPrivateIp() { + interface=$(route -n get default | grep interface | awk '{print $2}') + ip=$(ipconfig getifaddr "$interface") + 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'' -e "s/LAN_PRIVATE_IP=.*/LAN_PRIVATE_IP=$LAN_PRIVATE_IP/g" .env + +# If sillicon mac, enable EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU flag +if [ "$(uname -m)" = "arm64" ]; then + if ! grep -q "EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU" .env; then + echo "# Enable this flag to run Docker Desktop on Apple Silicon Macs" >> .env + echo "EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1" >> .env + else + sed -i'' -e "s/EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=.*/EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1/g" .env + fi +fi diff --git a/pro/configure_lan_private_ip_windows.bat b/pro/configure_lan_private_ip_windows.bat new file mode 100755 index 0000000..8704548 --- /dev/null +++ b/pro/configure_lan_private_ip_windows.bat @@ -0,0 +1,34 @@ +@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 "delims=" %%i in ('findstr /n "^" ".env"') do ( + set "line=%%i" + set "line=!line:*:=!" + if "!line:~0,15!"=="LAN_PRIVATE_IP=" ( + echo LAN_PRIVATE_IP=%ip% + ) 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/pro/custom-layout/index.html b/pro/custom-layout/index.html new file mode 100644 index 0000000..fbb8350 --- /dev/null +++ b/pro/custom-layout/index.html @@ -0,0 +1,11 @@ + + + + + + Recording custom layout + + + Create here your custom layout + + diff --git a/pro/docker-compose.override.yaml b/pro/docker-compose.override.yaml new file mode 100644 index 0000000..712a4cb --- /dev/null +++ b/pro/docker-compose.override.yaml @@ -0,0 +1,26 @@ +services: + default-app: + image: docker.io/wcm65pck/openvidu-call-demo:main + container_name: openvidu-call + restart: on-failure + environment: + - USE_HTTPS=${USE_HTTPS:-false} + - LAN_MODE=${LAN_MODE:-false} + - LAN_DOMAIN=${LAN_DOMAIN:-} + - LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-} + - SERVER_PORT=5442 + - LIVEKIT_URL_PRIVATE=ws://openvidu:7880/ + - LIVEKIT_API_KEY=${LIVEKIT_API_KEY} + - LIVEKIT_API_SECRET=${LIVEKIT_API_SECRET} + - CALL_PRIVATE_ACCESS=DISABLED + - CALL_USER=${CALL_USER:-} + - CALL_SECRET=${CALL_SECRET:-} + - CALL_ADMIN_SECRET=${CALL_ADMIN_SECRET:-} + - CALL_RECORDING=${CALL_RECORDING:-} + volumes: + - ./scripts/entrypoint_default_app.sh:/scripts/entrypoint.sh + - ./scripts/utils.sh:/scripts/utils.sh + entrypoint: /bin/sh /scripts/entrypoint.sh + depends_on: + setup: + condition: service_completed_successfully diff --git a/docker-compose.yaml b/pro/docker-compose.yaml similarity index 98% rename from docker-compose.yaml rename to pro/docker-compose.yaml index 02b69b0..cb65306 100644 --- a/docker-compose.yaml +++ b/pro/docker-compose.yaml @@ -94,13 +94,15 @@ services: condition: service_completed_successfully openvidu: - image: docker.io/wcm65pck/openvidu-livekit:main + image: docker.io/wcm65pck/openvidu-pro-livekit:main restart: unless-stopped container_name: openvidu extra_hosts: - host.docker.internal:host-gateway environment: - LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-} + - OPENVIDU_DEPLOYMENT_TYPE=local + - OPENVIDU_ENVIRONMENT=on_premise ports: - 3478:3478/udp - 7881:7881/tcp diff --git a/pro/egress.yaml b/pro/egress.yaml new file mode 100644 index 0000000..45f5bec --- /dev/null +++ b/pro/egress.yaml @@ -0,0 +1,23 @@ +redis: + address: redis:6379 + username: "" + password: redispassword + db: 0 + use_tls: false +api_key: devkey +api_secret: secret +ws_url: ws://openvidu:7880 +health_port: 9091 + +# files will be moved here when uploads fail. +backup_storage: /home/egress/backup_storage + +# Storage for recordings +s3: + access_key: minioadmin + secret: minioadmin + # Default region for minio + region: us-east-1 + endpoint: http://minio:9000 + bucket: openvidu + force_path_style: true diff --git a/pro/ingress.yaml b/pro/ingress.yaml new file mode 100644 index 0000000..3afefc4 --- /dev/null +++ b/pro/ingress.yaml @@ -0,0 +1,19 @@ +redis: + address: redis:6379 + username: "" + password: redispassword + db: 0 + use_tls: false +api_key: devkey +api_secret: secret +ws_url: ws://openvidu:7880 +rtmp_port: 1935 +whip_port: 8085 +http_relay_port: 9090 +health_port: 9091 +logging: + json: false + level: "" +development: false +rtc_config: + udp_port: 7895 diff --git a/pro/livekit.yaml b/pro/livekit.yaml new file mode 100644 index 0000000..f714e39 --- /dev/null +++ b/pro/livekit.yaml @@ -0,0 +1,44 @@ +# OpenVidu configuration +openvidu: + analytics: + enabled: true + interval: 10s + expiration: 768h # 32 days + mongo_url: mongodb://mongoadmin:mongoadmin@mongo:27017 + +# LiveKit configuration +port: 7880 +bind_addresses: + - "" +rtc: + tcp_port: 7881 + udp_port: 7882-7892 +redis: + address: redis:6379 + username: "" + password: redispassword + db: 0 + use_tls: false +turn: + enabled: true + udp_port: 3478 + relay_range_start: 40000 + relay_range_end: 50000 +keys: + devkey: secret +webhook: + api_key: devkey + urls: + # - http://openvidu-v2compatibility:5080/livekit + - http://host.docker.internal:4443/livekit/webhook +ingress: + rtmp_base_url: rtmp://localhost:1935/rtmp + whip_base_url: http://localhost:8085/whip +logging: + # Logging level for the LiveKit server. + # Values: "debug", "info" (default), "warn", "error". + level: info + + # Logging level for the Pion WebRTC engine. + # Values: "trace", "debug", "info", "warn", "error" (default). + pion_level: error diff --git a/pro/scripts/entrypoint_default_app.sh b/pro/scripts/entrypoint_default_app.sh new file mode 100644 index 0000000..dcfbbcc --- /dev/null +++ b/pro/scripts/entrypoint_default_app.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +. /scripts/utils.sh + +URL=$(getDeploymentUrl) +export LIVEKIT_URL="${URL}" + +/usr/local/bin/entrypoint.sh diff --git a/pro/scripts/entrypoint_openvidu.sh b/pro/scripts/entrypoint_openvidu.sh new file mode 100644 index 0000000..bf30db0 --- /dev/null +++ b/pro/scripts/entrypoint_openvidu.sh @@ -0,0 +1,20 @@ +#!/bin/sh +set -e +CONFIG_FILE_TMP="/tmp/livekit.yaml" +CONFIG_FILE="/etc/livekit.yaml" +LAN_PRIVATE_IP="${LAN_PRIVATE_IP:-}" + +cp ${CONFIG_FILE_TMP} ${CONFIG_FILE} + +if [ "$LAN_PRIVATE_IP" != "none" ]; then + if ! grep -q "^[[:space:]]*node_ip:.*" "$CONFIG_FILE"; then + if grep -q "^rtc:" "$CONFIG_FILE"; then + sed -i "/^rtc:/a \ node_ip: $LAN_PRIVATE_IP" "$CONFIG_FILE" + else + echo "rtc:" >> "$CONFIG_FILE" + echo " node_ip: $LAN_PRIVATE_IP" >> "$CONFIG_FILE" + fi + fi +fi + +./livekit-server "$@" diff --git a/pro/scripts/entrypoint_v2comp.sh b/pro/scripts/entrypoint_v2comp.sh new file mode 100644 index 0000000..17608f8 --- /dev/null +++ b/pro/scripts/entrypoint_v2comp.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -e +. /scripts/utils.sh + +URL=$(getDeploymentUrl) +export OPENVIDU_SHIM_URL="${URL}" +export LIVEKIT_URL="${URL}" +/bin/server diff --git a/pro/scripts/ready-check.sh b/pro/scripts/ready-check.sh new file mode 100644 index 0000000..994c256 --- /dev/null +++ b/pro/scripts/ready-check.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +. /scripts/utils.sh + +trap 'handle_sigint' SIGINT + +handle_sigint() { + echo "SIGINT signal received, exiting..." + exit 1 +} + +wait_for_service() { + SERVICE_NAME=$1 + SERVICE_URL=$2 + shift 2 + EXTRA=$@ + if [ -n "$EXTRA" ]; then + until curl $EXTRA $SERVICE_URL > /dev/null; do + echo "Waiting for $SERVICE_NAME to start..."; + sleep 1; + done; + else + until curl --silent --head --fail $SERVICE_URL > /dev/null; do + echo "Waiting for $SERVICE_NAME to start..."; + sleep 1; + done; + fi; +} + +wait_for_service 'OpenVidu' 'http://openvidu:7880' +wait_for_service 'Ingress' 'http://ingress:9091' +wait_for_service 'Egress' 'http://egress:9091' +wait_for_service 'Dashboard' 'http://dashboard:5000' +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 + +LAN_HTTP_URL=$(getDeploymentUrl http) +LAN_WS_URL=$(getDeploymentUrl ws) + +for i in $(seq 1 10); do + echo 'Starting OpenVidu... Please be patient...' + sleep 1 +done; +echo '' +echo '' +echo '=========================================' +echo '🎉 OpenVidu is ready! 🎉' +echo '=========================================' +echo '' +echo 'OpenVidu Server && LiveKit Server URLs:' +echo '' +echo ' - From this machine:' +echo '' +echo ' - http://localhost:7880' +echo ' - ws://localhost:7880' +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/pro/scripts/setup.sh b/pro/scripts/setup.sh new file mode 100644 index 0000000..1c270b8 --- /dev/null +++ b/pro/scripts/setup.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +if [ -z "$LAN_PRIVATE_IP" ]; then + echo '------------------------' + echo '' + 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: ./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 [ "$LAN_MODE" = 'true' ] && [ "$USE_HTTPS" = 'false' ]; then + echo 'LAN_MODE cannot be "true" if USE_HTTPS is "false"' + exit 1 +fi + +# Prepare volumes +mkdir -p /minio/data +mkdir -p /mongo/data +mkdir -p /mongo/data/ +mkdir -p /egress/home/egress +chown 1001:1001 /minio /minio/data +chown 1001:1001 /mongo /mongo/data +chown 1001:1001 /egress +chown 1001:1001 /egress/home +chown 1001:1001 /egress/home/egress \ No newline at end of file diff --git a/pro/scripts/utils.sh b/pro/scripts/utils.sh new file mode 100644 index 0000000..206efa0 --- /dev/null +++ b/pro/scripts/utils.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +getDeploymentUrl() { + 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"} + if [ "$LAN_PRIVATE_IP" != 'none' ] && [ "${LAN_DOMAIN}" = 'openvidu-local.dev' ]; then + # Replace dots with dashes + LAN_DOMAIN="$(echo "$LAN_PRIVATE_IP" | sed 's/\./-/g').openvidu-local.dev" + fi + URL="${schema}s://${LAN_DOMAIN}:7443" + fi + echo "$URL" +}