Linux only: Docker compose only works via initial scripts. Add LAN_MODE and LAN_PRIVATE_IP

This commit is contained in:
cruizba 2024-03-26 03:19:47 +01:00
parent 0578af22a9
commit 736808baab
17 changed files with 302 additions and 181 deletions

18
.env
View File

@ -1,15 +1,13 @@
# Only 'openvidu-local.dev', '*.openvidu-local.dev' or 'localhost' can be used.
# To access in a LAN environment using 'openvidu-local.dev', just add the IP as a
# subdomain. For example if your IP is 192.168.1.105, just use '192-168-1-105.openvidu-local.dev'.
# In this way, you can access from any device in your LAN.
LOCAL_DOMAIN=localhost
# If false, services will not run with TLS.
# Expose OpenVidu with HTTPS.
USE_TLS=false
# Announced IP for LAN access. If 'auto', best effort will be made to find
# the private IP of the machine.
# If the detected IP is not correct, you can set it manually.
PRIVATE_IP=auto
# If true, you can access OpenVidu through your LAN
# If true USE_TLS must be true
LAN_MODE=false
# LAN IP Address to expose OpenVidu
LAN_PRIVATE_IP=auto
# LiveKit API Key and Secret used for apps to connect to the LiveKit server.
LIVEKIT_API_KEY=key1

View File

@ -34,9 +34,9 @@ If you want to access the deployment in your LAN for Android or iOS devices, you
1. Get the private IP of your computer in your LAN.
2. Configure your Firewall to allow devices in your LAN to access your computer.
3. Change `LOCAL_DOMAIN` in the `.env` file to have the IP of your computer in your LAN.
3. Change `LAN_DOMAIN` in the `.env` file to have the IP of your computer in your LAN.
If your IP for example is `192.168.1.10`, `LOCAL_DOMAIN` should be `192-168-1-10.openvidu-local.dev`.
If your IP for example is `192.168.1.10`, `LAN_DOMAIN` should be `192-168-1-10.openvidu-local.dev`.
### About `openvidu-local.dev`

View File

@ -14,6 +14,7 @@ type TemplateData any
var indexData = &templates.IndexData{}
var caddyData = &templates.CaddyData{}
var app502Data = &templates.App502Data{}
func main() {
err := Initialize()
@ -21,6 +22,7 @@ func main() {
fmt.Println(err)
os.Exit(1)
}
rawIndex, err := GenerateTemplate(templates.IndexTemplate, indexData)
if err != nil {
fmt.Println(err)
@ -43,7 +45,7 @@ func main() {
os.Exit(1)
}
rawApp502, err := GenerateTemplate(templates.App502Template, nil)
rawApp502, err := GenerateTemplate(templates.App502Template, app502Data)
if err != nil {
fmt.Println(err)
os.Exit(1)
@ -57,25 +59,52 @@ func main() {
}
func Initialize() error {
httpPort := 8090
httpsPort := 4443
AppPort := 5442
version := os.Getenv("VERSION")
if version == "" {
return fmt.Errorf("VERSION is not set")
}
localDomain := os.Getenv("LOCAL_DOMAIN")
if localDomain == "" {
return fmt.Errorf("LOCAL_DOMAIN is not set")
}
rawUseTLS := os.Getenv("USE_TLS")
if rawUseTLS == "" {
return fmt.Errorf("USE_TLS is not set")
rawUseTLS = "false"
}
useTLS, err := strconv.ParseBool(rawUseTLS)
if err != nil {
return fmt.Errorf("USE_TLS 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 := ""
if useTLS {
httpsUrl = fmt.Sprintf("https://localhost:%d", httpsPort)
if lanMode == "true" {
httpsUrl = fmt.Sprintf("https://%s:%d", lanDomain, httpsPort)
}
}
livekitApiKey := os.Getenv("LIVEKIT_API_KEY")
if livekitApiKey == "" {
return fmt.Errorf("LIVEKIT_API_KEY is not set")
@ -107,9 +136,9 @@ func Initialize() error {
indexData = &templates.IndexData{
OpenViduVersion: version,
DomainName: localDomain,
IsLocalhost: localDomain == "localhost",
IsTLS: useTLS,
LanMode: lanMode == "true",
HttpUrl: httpUrl,
HttpsUrl: httpsUrl,
LiveKitApiKey: livekitApiKey,
LiveKitApiSecret: livekitApiSecret,
OpenViduSecret: openviduSecret,
@ -120,9 +149,17 @@ func Initialize() error {
}
caddyData = &templates.CaddyData{
DomainName: localDomain,
IsLocalhost: localDomain == "localhost",
IsTLS: useTLS,
LanMode: lanMode == "true",
LanDomain: lanDomain,
HttpUrl: httpUrl,
HttpsUrl: httpsUrl,
HttpPort: strconv.Itoa(httpPort),
HttpsPort: strconv.Itoa(httpsPort),
AppPort: strconv.Itoa(AppPort),
}
app502Data = &templates.App502Data{
AppPort: strconv.Itoa(AppPort),
}
return nil

View File

@ -1,5 +1,9 @@
package templates
type App502Data struct {
AppPort string
}
const App502Template = `<!DOCTYPE html>
<html lang="en">
<head>
@ -35,7 +39,7 @@ const App502Template = `<!DOCTYPE html>
<div class="error-code">502 - Bad Gateway</div>
<h1 class="display-5">OpenVidu Application Not Found</h1>
<hr class="my-4">
<p>If you are developing an application and <b>run it locally at port 5442</b>, you will see here your application, under
<p>If you are developing an application and <b>run it locally at port {{.AppPort}}</b>, you will see here your application, under
the same domain and TLS certificate as OpenVidu.</p>
</div>
</div>

View File

@ -1,35 +1,25 @@
package templates
type CaddyData struct {
DomainName string
IsLocalhost bool
IsTLS bool
LanMode bool
LanDomain string
HttpUrl string
HttpsUrl string
HttpPort string
HttpsPort string
AppPort string
}
const CaddyfileTemplate = `
# Minio
{{- if hasSuffix .DomainName ".openvidu-local.dev" }}
http{{if .IsTLS}}s{{end}}://*.openvidu-local.dev:9000, http{{if .IsTLS}}s{{end}}://openvidu-local.dev:9000 {
{{- else }}
http{{if .IsTLS}}s{{end}}://{{.DomainName}}:9000 {
{{- end }}
{{if .IsTLS}}{{if hasSuffix .DomainName "openvidu-local.dev"}}tls internal {
get_certificate http https://certs.openvidu-local.dev/caddy.pem
}{{else}}tls internal{{end}}{{end}}
reverse_proxy http://minio:9000
(index) {
# Default /
handle_path /* {
root * /var/www/
file_server
}
}
# General
{{- if hasSuffix .DomainName ".openvidu-local.dev" }}
http{{if .IsTLS}}s{{end}}://*.openvidu-local.dev:4443, http{{if .IsTLS}}s{{end}}://openvidu-local.dev:4443 {
{{- else }}
http{{if .IsTLS}}s{{end}}://{{.DomainName}}:4443 {
{{- end }}
{{if .IsTLS}}{{if hasSuffix .DomainName "openvidu-local.dev"}}tls internal {
get_certificate http https://certs.openvidu-local.dev/caddy.pem
}{{else}}tls internal{{end}}{{end}}
# API
(general_rules) {
# LiveKit API
@openvidu path /twirp/* /rtc/* /rtc
handle @openvidu {
reverse_proxy http://openvidu:7880
@ -62,22 +52,8 @@ http{{if .IsTLS}}s{{end}}://{{.DomainName}}:4443 {
reverse_proxy http://default-app:5442
}
# Default /
handle_path /* {
root * /var/www/
file_server
}
}
# Your OpenVidu App
{{- if hasSuffix .DomainName ".openvidu-local.dev" }}
http{{if .IsTLS}}s{{end}}://*.openvidu-local.dev:8000, http{{if .IsTLS}}s{{end}}://openvidu-local.dev:8000 {
{{- else }}
http{{if .IsTLS}}s{{end}}://{{.DomainName}}:8000 {
{{- end }}
{{if .IsTLS}}{{if hasSuffix .DomainName "openvidu-local.dev"}}tls internal {
get_certificate http https://certs.openvidu-local.dev/caddy.pem
}{{else}}tls internal{{end}}{{end}}
(custom_app) {
handle_errors {
@502 expression {http.error.status_code} == 502
rewrite @502 /app502.html
@ -85,7 +61,36 @@ http{{if .IsTLS}}s{{end}}://{{.DomainName}}:8000 {
root /var/www
}
}
reverse_proxy http://host.docker.internal:5442
reverse_proxy http://host.docker.internal:{{ .AppPort }}
}
# 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 custom_app
}
{{- else }}
https://*:{{.HttpsPort}} {
tls internal
import general_rules
import custom_app
}
{{- end }}
{{- end}}
`

View File

@ -2,9 +2,9 @@ package templates
type IndexData struct {
OpenViduVersion string
DomainName string
IsLocalhost bool
IsTLS bool
LanMode bool
HttpUrl string
HttpsUrl string
DashboardAdminUsername string
DashboardAdminPassword string
MinioAdminKey string
@ -14,14 +14,15 @@ type IndexData struct {
OpenViduSecret string
}
const IndexTemplate = `<!DOCTYPE html>
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" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" />
<!-- Custom styles -->
<style>
.container {
@ -31,6 +32,7 @@ const IndexTemplate = `<!DOCTYPE html>
}
</style>
</head>
<body>
<div class="container">
<div>
@ -40,47 +42,76 @@ const IndexTemplate = `<!DOCTYPE html>
<span>This deployment is only for development purposes.</span>
</div>
<hr class="my-4">
{{- if .HttpsUrl }}
<h2>HTTPS URLs</h2>
{{- if .LanMode }}
<div class="alert alert-info" role="alert">
<span>You can access from any device in your local network using the following URLs:</span>
</div>
{{- end}}
<ul>
<li><strong>OpenVidu API URL:</strong> <a href="http{{if .IsTLS}}s{{end}}://{{ .DomainName }}:4443" target="_blank">http{{if .IsTLS}}s{{end}}://{{ .DomainName }}:4443</a>
<li><strong>OpenVidu and Livekit API: </strong><a href="{{ .HttpsUrl }}"
target="_blank">{{ .HttpsUrl }}</a></li>
<li><strong>OpenVidu Dashboard: </strong><a href="{{ .HttpsUrl }}/dashboard"
target="_blank">{{ .HttpsUrl }}/dashboard</a></li>
<li><strong>Minio Console: </strong><a href="{{ .HttpsUrl }}/minio-console"
target="_blank">{{ .HttpsUrl }}/minio-console</a></li>
<li><strong>OpenVidu Call: </strong><a href="{{ .HttpsUrl }}/openvidu-call"
target="_blank">{{ .HttpsUrl }}/openvidu-call</a></li>
<li><strong>Your App: </strong><span>Any App you deploy at port 5442 will be available here: </span>
<ul>
<li><strong>Secret:</strong> <code>{{ .OpenViduSecret }}</code></li>
<li><a href="{{ .HttpsUrl }}"
target="_blank">{{ .HttpsUrl }}</a></li>
</ul>
</li>
<li><strong>LiveKit API URL:</strong> <a href="http{{if .IsTLS}}s{{end}}://{{ .DomainName }}:4443" target="_blank">http{{if .IsTLS}}s{{end}}://{{ .DomainName }}:4443</a>
<ul>
<li><strong>API Key:</strong> <code>{{ .LiveKitApiKey }}</code></li>
<li><strong>API Secret:</strong> <code>{{ .LiveKitApiSecret }}</code></li>
</ul>
</li>
<li><strong>OpenVidu Dashboard:</strong> <a href="http{{if .IsTLS}}s{{end}}://{{ .DomainName }}:4443/dashboard" target="_blank">http{{if .IsTLS}}s{{end}}://{{ .DomainName }}:4443/dashboard</a>
<ul>
<li><strong>Username:</strong> <code>{{ .DashboardAdminUsername }}</code></li>
<li><strong>Password:</strong> <code>{{ .DashboardAdminPassword }}</code></li>
</ul>
</li>
<li><strong>Minio:</strong> <a href="http{{if .IsTLS}}s{{end}}://{{ .DomainName }}:4443/minio-console" target="_blank">http{{if .IsTLS}}s{{end}}://{{ .DomainName }}:4443/minio-console</a>
<ul>
<li><strong>Minio Admin User:</strong> <code>{{ .MinioAdminKey }}</code></li>
<li><strong>Minio Admin Password:</strong> <code>{{ .MinioAdminSecret }}</code></li>
</ul>
</li>
<li><strong>OpenVidu Call (Default App):</strong> <a href="http{{if .IsTLS}}s{{end}}://{{ .DomainName }}:4443/openvidu-call" target="_blank">http{{if .IsTLS}}s{{end}}://{{ .DomainName }}:4443/openvidu-call</a></li>
<hr class="my-4">
<li><strong>Your App:</strong> <a href="http{{if .IsTLS}}s{{end}}://{{ .DomainName }}:8000" target="_blank">http{{if .IsTLS}}s{{end}}://{{ .DomainName }}:8000</a>:
<span>If you are developing an application and run it locally at port 5442, you will see your application here, under the same domain and TLS certificate as OpenVidu.</span></li>
</ul>
<hr class="my-4">
{{- if not .IsLocalhost }}
<p>If you want to access this deployment with <code>http(s)://localhost:4443</code>, just change the <code>LOCAL_DOMAIN</code> variable to <code>localhost</code> in the <code>.env</code> file.</p>
{{- else }}
<p>If you want to access this deployment with <code>http(s)://openvidu-local.dev:4443</code>, just change the <code>LOCAL_DOMAIN</code> variable to <code>openvidu-local.dev</code> in the <code>.env</code> file.</p>
{{- end }}
{{- if .IsTLS }}
<p>If you want to disable TLS, just change the <code>USE_TLS</code> variable to <code>false</code> in the <code>.env</code> file.</p>
{{- else }}
<p>If you want to enable TLS, just change the <code>USE_TLS</code> variable to <code>true</code> in the <code>.env</code> file.</p>
{{- end }}
<h2>HTTP URLs</h2>
<ul>
<li><strong>OpenVidu and Livekit API: </strong><a href="{{ .HttpUrl }}"
target="_blank">{{ .HttpUrl }}</a></li>
<li><strong>OpenVidu Dashboard: </strong><a href="{{ .HttpUrl }}/dashboard"
target="_blank">{{ .HttpUrl }}/dashboard</a></li>
<li><strong>Minio Console: </strong><a href="{{ .HttpUrl }}/minio-console"
target="_blank">{{ .HttpUrl }}/minio-console</a></li>
{{- if not .HttpsUrl }}
<li><strong>OpenVidu Call: </strong><a href="http://localdomain.com:4443/openvidu-call"
target="_blank">http://localdomain.com:4443/openvidu-call</a></li>
{{- end }}
</ul>
<hr class="my-4">
<!-- Section with Credentials -->
<h2>Credentials</h2>
<ul>
<li><strong>OpenVidu (Basic auth):</strong>
<ul>
<li>Username: <code>OPENVIDUAPP</code></li>
<li>Password: <code>{{ .OpenViduSecret }}</code></li>
</ul>
</li>
<li><strong>LiveKit API:</strong>
<ul>
<li>API Key: <code>{{ .LiveKitApiKey }}</code></li>
<li>API Secret: <code>{{ .LiveKitApiSecret }}</code></li>
</ul>
</li>
<li><strong>OpenVidu Dashboard: </strong>
<ul>
<li>Username: <code>{{ .DashboardAdminUsername }}</code></li>
<li>Password: <code>{{ .DashboardAdminPassword }}</code></li>
</ul>
</li>
<li><strong>Minio: </strong>
<ul>
<li>User: <code>{{ .MinioAdminKey }}</code></li>
<li>Password: <code>{{ .MinioAdminSecret }}</code></li>
</ul>
</li>
</ul>
</div>
</div>
</body>
</html>`
</html>
`

View File

@ -4,9 +4,11 @@ services:
container_name: openvidu-call
restart: on-failure
environment:
- USE_TLS=${USE_TLS:-false}
- LAN_MODE=${LAN_MODE:-false}
- LAN_DOMAIN=${LAN_DOMAIN:-}
- LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-}
- SERVER_PORT=5442
- USE_TLS=${USE_TLS:-?}
- LIVEKIT_URL=wss://${LOCAL_DOMAIN:-?}:4443/
- LIVEKIT_URL_PRIVATE=ws://openvidu:7880/
- LIVEKIT_API_KEY=${LIVEKIT_API_KEY}
- LIVEKIT_API_SECRET=${LIVEKIT_API_SECRET}
@ -15,6 +17,10 @@ services:
- 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

@ -7,19 +7,20 @@ services:
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
- LOCAL_DOMAIN=${LOCAL_DOMAIN:-?}
- USE_TLS=${USE_TLS:-?}
- 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:-?}
- LAN_DOMAIN=${LAN_DOMAIN:-}
- LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-}
- LAN_MODE=${LAN_MODE:-false}
- USE_TLS=${USE_TLS:-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:-}
ports:
- 4443:4443
- 9000:9000
- 8000:8000
- 8090:8090
depends_on:
setup:
condition: service_completed_successfully
@ -33,7 +34,7 @@ services:
command: >
redis-server
--bind 0.0.0.0
--requirepass ${REDIS_PASSWORD:-?}
--requirepass ${REDIS_PASSWORD:-}
depends_on:
setup:
condition: service_completed_successfully
@ -42,10 +43,11 @@ services:
image: bitnami/minio:2024.3.15-debian-12-r0
container_name: minio
restart: unless-stopped
ports:
- 9000:9000
environment:
- LOCAL_DOMAIN=${LOCAL_DOMAIN:-?}
- MINIO_ROOT_USER=${MINIO_ACCESS_KEY:-?}
- MINIO_ROOT_PASSWORD=${MINIO_SECRET_KEY:-?}
- MINIO_ROOT_USER=${MINIO_ACCESS_KEY:-}
- MINIO_ROOT_PASSWORD=${MINIO_SECRET_KEY:-}
- MINIO_DEFAULT_BUCKETS=openvidu
- MINIO_CONSOLE_SUBPATH=/minio-console
- MINIO_BROWSER_REDIRECT_URL=http://localhost:4443/minio-console/
@ -63,8 +65,8 @@ services:
volumes:
- ./mongo/data:/bitnami/mongodb/
environment:
- MONGODB_ROOT_USER=${MONGO_ADMIN_USERNAME:-?}
- MONGODB_ROOT_PASSWORD=${MONGO_ADMIN_PASSWORD:-?}
- MONGODB_ROOT_USER=${MONGO_ADMIN_USERNAME:-}
- MONGODB_ROOT_PASSWORD=${MONGO_ADMIN_PASSWORD:-}
depends_on:
setup:
condition: service_completed_successfully
@ -75,8 +77,8 @@ services:
restart: unless-stopped
environment:
- SERVER_PORT=5000
- ADMIN_USERNAME=${DASHBOARD_ADMIN_USERNAME:-?}
- ADMIN_PASSWORD=${DASHBOARD_ADMIN_PASSWORD:-?}
- ADMIN_USERNAME=${DASHBOARD_ADMIN_USERNAME:-}
- ADMIN_PASSWORD=${DASHBOARD_ADMIN_PASSWORD:-}
- DATABASE_URL=mongodb://mongoadmin:mongoadmin@mongo:27017
depends_on:
setup:
@ -87,14 +89,14 @@ services:
restart: unless-stopped
container_name: openvidu
environment:
- PRIVATE_IP=${PRIVATE_IP:-}
- LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-}
ports:
- "3478:3478/udp"
entrypoint: /bin/sh /entrypoint_openvidu.sh
entrypoint: /bin/sh /scripts/entrypoint.sh
command: --config /etc/livekit.yaml
volumes:
- ./livekit.yaml:/tmp/livekit.yaml
- ./scripts/entrypoint_openvidu.sh:/entrypoint_openvidu.sh
- ./scripts/entrypoint_openvidu.sh:/scripts/entrypoint.sh
depends_on:
setup:
condition: service_completed_successfully
@ -105,7 +107,7 @@ services:
restart: unless-stopped
ports:
- "1935:1935"
- "8080:8080"
- "8085:8085"
- "7885:7885/udp"
environment:
- INGRESS_CONFIG_FILE=/etc/ingress.yaml
@ -132,34 +134,29 @@ services:
image: docker.io/wcm65pck/openvidu-v2compatibility:main
restart: unless-stopped
container_name: openvidu-v2compatibility
command: >
/bin/sh -c "
OV_URL=https://$$LOCAL_DOMAIN:4443/;
LK_URL=wss://$$LOCAL_DOMAIN:4443/;
if [ \"$USE_TLS\" = 'false' ]; then
OV_URL=$(echo $$OV_URL | sed 's/https/http/');
LK_URL=$(echo $$LK_URL | sed 's/wss/ws/');
fi &&
export OPENVIDU_SHIM_URL=$$OV_URL &&
export LIVEKIT_URL=$$LK_URL &&
node dist/server.js"
entrypoint: /bin/sh /scripts/entrypoint.sh
environment:
- USE_TLS=${USE_TLS:-?}
- LOCAL_DOMAIN=${LOCAL_DOMAIN:-?}
- USE_TLS=${USE_TLS:-false}
- LAN_DOMAIN=${LAN_DOMAIN:-}
- LAN_MODE=${LAN_MODE:-false}
- LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-}
- SERVER_PORT=4443
- OPENVIDU_SHIM_SECRET=${OPENVIDU_SHIM_SECRET:-?}
- OPENVIDU_SHIM_SECRET=${OPENVIDU_SHIM_SECRET:-}
- LIVEKIT_URL_PRIVATE=ws://openvidu:7880
- LIVEKIT_API_KEY=${LIVEKIT_API_KEY:-?}
- LIVEKIT_API_SECRET=${LIVEKIT_API_SECRET:-?}
- LIVEKIT_API_KEY=${LIVEKIT_API_KEY:-}
- LIVEKIT_API_SECRET=${LIVEKIT_API_SECRET:-}
- OPENVIDU_PRO_AWS_S3_BUCKET=openvidu
- OPENVIDU_PRO_AWS_S3_SERVICE_ENDPOINT=http://minio:9000
- OPENVIDU_PRO_AWS_S3_ACCESS_KEY=${MINIO_ACCESS_KEY:-?}
- OPENVIDU_PRO_AWS_S3_SECRET_KEY=${MINIO_SECRET_KEY:-?}
- OPENVIDU_PRO_AWS_S3_ACCESS_KEY=${MINIO_ACCESS_KEY:-}
- OPENVIDU_PRO_AWS_S3_SECRET_KEY=${MINIO_SECRET_KEY:-}
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=${REDIS_PASSWORD:-?}
- REDIS_PASSWORD=${REDIS_PASSWORD:-}
- REDIS_DB=0
- OPENVIDU_WEBHOOK=false
volumes:
- ./scripts/entrypoint_v2comp.sh:/scripts/entrypoint.sh
- ./scripts/utils.sh:/scripts/utils.sh
depends_on:
setup:
condition: service_completed_successfully
@ -169,8 +166,10 @@ services:
container_name: ready-check
restart: on-failure
environment:
- LOCAL_DOMAIN=${LOCAL_DOMAIN:-?}
- USE_TLS=${USE_TLS:-?}
- USE_TLS=${USE_TLS:-false}
- LAN_DOMAIN=${LAN_DOMAIN:-}
- LAN_MODE=${LAN_MODE:-false}
- LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-}
depends_on:
- openvidu
- ingress
@ -179,8 +178,9 @@ services:
- minio
- mongo
volumes:
- ./scripts/ready-check.sh:/ready-check.sh
command: /bin/sh /ready-check.sh
- ./scripts/ready-check.sh:/scripts/ready-check.sh
- ./scripts/utils.sh:/scripts/utils.sh
command: /bin/sh /scripts/ready-check.sh
setup:
image: busybox
@ -190,14 +190,14 @@ services:
- ./minio:/minio
- ./mongo:/mongo
- ./egress:/egress
- ./scripts/setup.sh:/setup.sh
- ./scripts/setup.sh:/scripts/setup.sh
environment:
- USE_TLS=${USE_TLS:-false}
- LAN_MODE=${LAN_MODE:-false}
- LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-}
- RUN_WITH_SCRIPT=${RUN_WITH_SCRIPT:-false}
- PRIVATE_IP=${PRIVATE_IP:-?}
user: root
command: /bin/sh -c "/setup.sh"
command: /bin/sh scripts/setup.sh
volumes:
minio-certs:

View File

@ -8,7 +8,7 @@ api_key: key1
api_secret: abcdefghijklmnopqrstuvwxyz123456
ws_url: ws://openvidu:7880
rtmp_port: 1935
whip_port: 8080
whip_port: 8085
http_relay_port: 9090
health_port: 9091
logging:

View File

@ -33,7 +33,7 @@ webhook:
- http://openvidu-v2compatibility:4443/openvidu/api/webhook
ingress:
rtmp_base_url: rtmp://localhost:1935/rtmp
whip_base_url: http://localhost:8080/whip
whip_base_url: http://localhost:8085/whip
logging:
# Logging level for the LiveKit server.
# Values: "debug", "info" (default), "warn", "error".

View File

@ -61,21 +61,21 @@ if [ "$START" = "true" ]; then
export $(grep -v '^#' .env | xargs)
fi
if [ "$PRIVATE_IP" = "auto" ]; then
PRIVATE_IP="$(getPrivateIp)"
if [ -z "$PRIVATE_IP" ]; then
PRIVATE_IP=none
if [ "$LAN_PRIVATE_IP" = "auto" ]; then
LAN_PRIVATE_IP="$(getPrivateIp)"
if [ -z "$LAN_PRIVATE_IP" ]; then
LAN_PRIVATE_IP=none
fi
export PRIVATE_IP
export LAN_PRIVATE_IP
fi
echo "Starting OpenVidu..."
export RUN_WITH_SCRIPT=true
docker compose down
docker compose down --volumes
docker compose up
fi
if [ "$STOP" = "true" ]; then
echo "Stopping OpenVidu"
docker compose down
docker compose down --volumes
fi

View File

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

View File

@ -2,17 +2,17 @@
set -e
CONFIG_FILE_TMP="/tmp/livekit.yaml"
CONFIG_FILE="/etc/livekit.yaml"
PRIVATE_IP="${PRIVATE_IP:-}"
LAN_PRIVATE_IP="${LAN_PRIVATE_IP:-}"
cp ${CONFIG_FILE_TMP} ${CONFIG_FILE}
if [ "$PRIVATE_IP" != "none" ]; then
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: $PRIVATE_IP" "$CONFIG_FILE"
sed -i "/^rtc:/a \ node_ip: $LAN_PRIVATE_IP" "$CONFIG_FILE"
else
echo "rtc:" >> "$CONFIG_FILE"
echo " node_ip: $PRIVATE_IP" >> "$CONFIG_FILE"
echo " node_ip: $LAN_PRIVATE_IP" >> "$CONFIG_FILE"
fi
fi
fi

View File

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

View File

@ -1,5 +1,7 @@
#!/bin/sh
. /scripts/utils.sh
wait_for_service() {
SERVICE_NAME=$1
SERVICE_URL=$2
@ -26,10 +28,7 @@ wait_for_service 'Minio' 'http://minio:9000/minio/health/live'
wait_for_service 'Minio Console' 'http://minio:9001/minio-console'
wait_for_service 'Mongo' 'http://mongo:27017' --connect-timeout 10 --silent
URL=https://$LOCAL_DOMAIN:4443/
if [ "$USE_TLS" = 'false' ]; then
URL=$(echo $URL | sed 's/https/http/')
fi
URL=$(getDeploymentUrl)
for i in $(seq 1 10); do
echo 'Starting OpenVidu... Please be patient...'

16
scripts/setup.sh Executable file → Normal file
View File

@ -6,18 +6,26 @@ if [ "$RUN_WITH_SCRIPT" = 'false' ]; then
echo 'Do not run this docker-compose file via "docker compose up" directly.'
echo 'Please run it via the provided scripts.'
echo ''
echo ' - Linux: ./openvidu_linux.sh'
echo ' - MacOS: ./openvidu_macos.sh'
echo ' - Linux: ./openvidu_linux.sh start'
echo ' - MacOS: ./openvidu_macos.sh start'
echo ' - Windows: ./openvidu_windows.ps1'
echo ''
echo '------------------------'
exit 1
fi
if [ "$PRIVATE_IP" = '?' ]; then
echo 'PRIVATE_IP is required'
if [ -z "$LAN_PRIVATE_IP" ]; then
echo 'LAN_PRIVATE_IP is required'
echo 'Valid values are: "none", "auto" or a valid IP address'
echo 'Define it in the .env file'
exit 1
fi
if [ "$LAN_MODE" = 'true' ] && [ "$USE_TLS" = 'false' ]; then
echo 'LAN_MODE cannot be "true" if USE_TLS is "false"'
exit 1
fi
# Prepare volumes
mkdir -p /minio/data &&
mkdir -p /mongo/data &&
mkdir -p /mongo/data/ &&

17
scripts/utils.sh Normal file
View File

@ -0,0 +1,17 @@
#!/bin/sh
getDeploymentUrl() {
URL="http://localhost:8090"
if [ "${USE_TLS}" = 'true' ]; then
URL="https://localhost:4443"
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="https://${LAN_DOMAIN}:4443"
fi
echo "$URL"
}