community and pro folders

This commit is contained in:
pabloFuente 2024-04-24 16:29:52 +02:00
parent 3675b6ad0e
commit 7ac710b94e
53 changed files with 1267 additions and 9 deletions

View File

@ -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
```

View File

View File

@ -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:

35
pro/.env Normal file
View File

@ -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

1
pro/.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
* text=auto eol=lf

3
pro/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
egress/
minio/
mongo/

View File

@ -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"]

View File

@ -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 .
```

View File

@ -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 "$@"

3
pro/caddy-proxy/go.mod Normal file
View File

@ -0,0 +1,3 @@
module local-caddy-generate
go 1.22.1

249
pro/caddy-proxy/main.go Normal file
View File

@ -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 <b>%d</b> and you will see it here", appClientPort),
}
app502ServerData = &templates.App502Data{
Title: "Application Server Not Found",
Message: fmt.Sprintf("Run your Application Server at port <b>%d</b> 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
}

View File

@ -0,0 +1,49 @@
package templates
type App502Data struct {
Title string
Message string
}
const App502Template = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>502 - Application Not Found</title>
<!-- Bootstrap CSS CDN -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<!-- Custom styles -->
<style>
body {
padding-top: 50px;
background-color: #f7f7f7;
}
.container {
padding: 40px;
background: #fff;
border-radius: 4px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
max-width: 600px;
margin: auto;
text-align: center;
}
.error-code {
font-size: 45px;
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<div>
<div class="error-code">502 - Bad Gateway</div>
<h1 class="display-5">{{.Title}}</h1>
<hr class="my-4">
<p>{{ .Message }}</p>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
`

View File

@ -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}}
`

View File

@ -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 = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OpenVidu Local Deployment</title>
<!-- Bootstrap CSS CDN -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" />
<!-- Custom styles -->
<style>
.container {
padding-top: 50px;
padding-left: 100px;
padding-right: 100px;
}
</style>
</head>
<body>
<div class="container">
<h1 class="display-4">Welcome to OpenVidu Local Deployment</h1>
<p class="lead">OpenVidu Version: <strong>{{.OpenViduVersion}}</strong></p>
<div class="alert alert-warning" role="alert">
<span>This deployment is only for development purposes.</span>
</div>
<hr class="my-4">
<h2>OpenVidu Server and LiveKit Server API:</h2>
<ul>
<li>From this machine:
<ul>
<li><a href="{{.HttpUrl}}" target="_blank">{{.HttpUrl}}</a></li>
<li><a href="{{.WsUrl}}" target="_blank">{{.WsUrl}}</a></li>
</ul>
</li>
{{- if .HttpsUrl }}
{{- if .LanMode }}
<li>From other devices in your LAN:
{{- else }}
<li>Using HTTPS:
{{- end }}
<ul>
<li><a href="{{.HttpsUrl}}" target="_blank">{{.HttpsUrl}}</a></li>
<li><a href="{{.WssUrl}}" target="_blank">{{.WssUrl}}</a></li>
</ul>
</li>
{{- end }}
</ul>
<hr class="my-4">
<h2>Services and passwords:</h2>
<ul>
<li><b>OpenVidu API:</b>
<ul>
<li>Username: <code>OPENVIDUAPP</code></li>
<li>Password: <code>{{.OpenViduSecret}}</code></li>
</ul>
</li>
<li>LiveKit API:
<ul>
<li>API Key: <code>{{.LiveKitApiKey}}</code></li>
<li>API Secret: <code>{{.LiveKitApiSecret}}</code></li>
</ul>
</li>
<li><a href="/minio-console" target="_blank">MinIO</a>
<ul>
<li>Username: <code>{{.MinioAdminKey}}</code></li>
<li>Password: <code>{{.MinioAdminSecret}}</code></li>
</ul>
</li>
<li><a href="/dashboard" target="_blank">OpenVidu Dashboard</a>
<ul>
<li>Username: <code>{{.DashboardAdminUsername}}</code></li>
<li>Password: <code>{{.DashboardAdminPassword}}</code></li>
</ul>
</li>
<li><a href="/openvidu-call" target="_blank">OpenVidu Call</a></li>
</ul>
</div>
</body>
</html>
`

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Recording custom layout</title>
</head>
<body>
Create here your custom layout
</body>
</html>

View File

@ -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

View File

@ -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

23
pro/egress.yaml Normal file
View File

@ -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

19
pro/ingress.yaml Normal file
View File

@ -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

44
pro/livekit.yaml Normal file
View File

@ -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

View File

@ -0,0 +1,8 @@
#!/bin/bash
. /scripts/utils.sh
URL=$(getDeploymentUrl)
export LIVEKIT_URL="${URL}"
/usr/local/bin/entrypoint.sh

View File

@ -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 "$@"

View File

@ -0,0 +1,8 @@
#!/bin/sh
set -e
. /scripts/utils.sh
URL=$(getDeploymentUrl)
export OPENVIDU_SHIM_URL="${URL}"
export LIVEKIT_URL="${URL}"
/bin/server

View File

@ -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 '========================================='

33
pro/scripts/setup.sh Normal file
View File

@ -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

18
pro/scripts/utils.sh Normal file
View File

@ -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"
}