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 = ` + +
+ + +{{ .Message }}
+OpenVidu Version: {{.OpenViduVersion}}
+OPENVIDUAPP{{.OpenViduSecret}}{{.LiveKitApiKey}}{{.LiveKitApiSecret}}{{.MinioAdminKey}}{{.MinioAdminSecret}}{{.DashboardAdminUsername}}{{.DashboardAdminPassword}}