First working openvidu local deployment

This commit is contained in:
cruizba 2024-03-16 21:59:54 +01:00
parent 4e53c1113e
commit ccc5a0de84
7 changed files with 367 additions and 1 deletions

27
.env Normal file
View File

@ -0,0 +1,27 @@
# Only openvidu-local.dev can be used.
# You can access the deployment also via https://localhost:4443
# but with a self-signed certificate.
LOCAL_DOMAIN=openvidu-local.dev
USE_TLS=true
# LiveKit API Key and Secret used for apps to connect to the LiveKit server.
LIVEKIT_API_KEY=key1
LIVEKIT_API_SECRET=abcdefghijklmnopqrstuvwxyz123456
# 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

3
.gitignore vendored Normal file
View File

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

View File

@ -1,2 +1,50 @@
# openvidu-local-deployment
# OpenVidu Local Deployment
Docker compose to run OpenVidu locally for development purposes
## Requirements
On **Windows** and **MacOS**:
- **Docker Desktop**
On **Linux**:
- **Docker**
- **Docker Compose**
## How to run
```sh
git clone https://github.com/OpenVidu/openvidu-local-deployment
docker compose up
```
When the deployment is ready you will see the following message in the logs:
```
readycheck | ------------------------
readycheck | OpenVidu is ready!
readycheck | Open https://openvidu-local.dev:4443/ in your browser
readycheck | ------------------------
```
## Additional Notes
### Using localhost
- This deployment is configured to use a domain name which points to `127.0.0.1` by default. If you want to use `localhost` instead, you can change the `LOCAL_DOMAIN` variable in the `.env` file.
### Enabling and Disabling TLS
- You can enable and disable TLS by setting `USE_TLS` to `true` or `false` in the `.env` file.
### LAN Access (Optional)
If you want to access the deployment in your LAN for Android or iOS devices, you need to do the following:
1. Get the private IP of your computer in your LAN.
2. Configure your Firewall to allow devices in your LAN to access your computer.
If your IP for example is `192.168.1.10`, the URL of your deployment in your LAN will be `https://192-168-1-10.openvidu-local.dev:4443/`.
### About `openvidu-local.dev`
This is a magic domain name like [nip.io](https://nip.io) or [traefik.me](https://traefik.me), which can resolve to any IP specified as a subdomain. It also offers a wildcard certificates which is automatically used by `caddy-proxy` in the local deployment to provide HTTPS for any subdomain.
This is useful for local development, as you can access your deployment using a domain name instead of an IP address, and you can use HTTPS without having to deal with self-signed certificates, **BUT it is not suitable for production environments.**

205
docker-compose.yaml Normal file
View File

@ -0,0 +1,205 @@
services:
caddy-proxy:
image: docker.io/wcm65pck/openvidu-caddy-local:main
container_name: caddy-proxy
restart: unless-stopped
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:-?}
ports:
- 4443:4443
- 9000:9000
redis:
image: redis:latest
container_name: redis
restart: unless-stopped
volumes:
- redis:/data
command: >
redis-server
--bind 0.0.0.0
--requirepass ${REDIS_PASSWORD:-?}
minio:
image: bitnami/minio:2024.3.15-debian-12-r0
container_name: minio
restart: unless-stopped
environment:
- LOCAL_DOMAIN=${LOCAL_DOMAIN:-?}
- MINIO_ROOT_USER=${MINIO_ACCESS_KEY:-?}
- MINIO_ROOT_PASSWORD=${MINIO_SECRET_KEY:-?}
- MINIO_DEFAULT_BUCKETS=openvidu
- MINIO_CONSOLE_SUBPATH=/minio-console
command: >
/bin/sh -c "
URL=https://$$LOCAL_DOMAIN:4443/minio-console/;
if [ \"$USE_TLS\" = 'false' ]; then
URL=$(echo $$URL | sed 's/https/http/');
fi &&
export MINIO_BROWSER_REDIRECT_URL=$$URL &&
/opt/bitnami/scripts/minio/run.sh"
volumes:
- ./minio/data:/bitnami/minio/data
- minio-certs:/certs
depends_on:
setup-volumes:
condition: service_completed_successfully
mongo:
image: bitnami/mongodb:7.0.6-debian-12-r0
container_name: mongo
restart: unless-stopped
volumes:
- ./mongo/data:/bitnami/mongodb/
environment:
- MONGODB_ROOT_USER=${MONGO_ADMIN_USERNAME:-?}
- MONGODB_ROOT_PASSWORD=${MONGO_ADMIN_PASSWORD:-?}
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
logging:
options:
max-size: "${DOCKER_LOGS_MAX_SIZE:-200M}"
openvidu:
image: docker.io/wcm65pck/openvidu-livekit:main
restart: unless-stopped
container_name: openvidu
environment:
- LIVEKIT_INGRESS_RTMP_BASE_URL=rtmp://${LOCAL_DOMAIN:-?}:1935/rtmp
- LIVEKIT_INGRESS_WHIP_BASE_URL=http://${LOCAL_DOMAIN:-?}:8080/whip
ports:
- "7880:7880"
- "3478:3478/udp"
command: --config /etc/livekit.yaml
volumes:
- ./livekit.yaml:/etc/livekit.yaml
ingress:
image: livekit/ingress:v1.2.0
container_name: ingress
restart: unless-stopped
ports:
- "1935:1935"
- "8080:8080"
- "7885:7885/udp"
environment:
- INGRESS_CONFIG_FILE=/etc/ingress.yaml
volumes:
- ./ingress.yaml:/etc/ingress.yaml
egress:
image: livekit/egress:v1.8.0
restart: unless-stopped
container_name: egress
environment:
- EGRESS_CONFIG_FILE=/etc/egress.yaml
volumes:
- ./egress.yaml:/etc/egress.yaml
- ./egress/home/egress:/home/egress/
depends_on:
setup-volumes:
condition: service_completed_successfully
ready-check:
image: curlimages/curl:8.6.0
container_name: readycheck
restart: on-failure
environment:
- LOCAL_DOMAIN=${LOCAL_DOMAIN:-?}
- USE_TLS=${USE_TLS:-?}
depends_on:
- openvidu
- ingress
- egress
- dashboard
- minio
- mongo
command: >
/bin/sh -c "
until $(curl --silent --head --fail http://openvidu:7880 > /dev/null); do
echo 'Waiting for OpenVidu to start...';
sleep 1;
done;
until $(curl --silent --head --fail http://ingress:9091 > /dev/null); do
echo 'Waiting for Ingress to start...';
sleep 1;
done;
until $(curl --silent --head --fail http://egress:9091 > /dev/null); do
echo 'Waiting for Ingress to start...';
sleep 1;
done;
until $(curl --silent --head --fail http://dashboard:5000 > /dev/null); do
echo 'Waiting for Dashboard to start...';
sleep 1;
done;
until $(curl --silent --head --fail http://minio:9000/minio/health/live > /dev/null); do
echo 'Waiting for Minio to start...';
sleep 1;
done;
until $(curl --silent --head --fail http://minio:9001/minio-console > /dev/null); do
echo 'Waiting for Mongo to start...';
sleep 1;
done;
until $(curl --connect-timeout 10 --silent http://mongo:27017 > /dev/null); do
echo 'Waiting for Mongo to start...';
sleep 1;
done;
URL=https://$$LOCAL_DOMAIN:4443/
if [ \"$USE_TLS\" = 'false' ]; then
URL=$(echo $$URL | sed 's/https/http/');
fi &&
sleep 10;
echo '';
echo '';
echo '------------------------';
echo 'OpenVidu is ready!';
echo \"Open $$URL in your browser\";
echo '------------------------';
echo '';
echo '';
"
setup-volumes:
image: busybox
container_name: setup-volumes
restart: on-failure
volumes:
- ./minio:/minio
- ./mongo:/mongo
- ./egress:/egress
user: root
command: >
/bin/sh -c "
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 1000:1000 /egress
chown 1000:1000 /egress/home
chown 1000:1000 /egress/home/egress
"
volumes:
minio-certs:
mongodb-config:
redis:

23
egress.yaml Normal file
View File

@ -0,0 +1,23 @@
redis:
address: redis:6379
username: ""
password: redispassword
db: 0
use_tls: false
api_key: key1
api_secret: abcdefghijklmnopqrstuvwxyz123456
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
ingress.yaml Normal file
View File

@ -0,0 +1,19 @@
redis:
address: redis:6379
username: ""
password: redispassword
db: 0
use_tls: false
api_key: key1
api_secret: abcdefghijklmnopqrstuvwxyz123456
ws_url: ws://openvidu:7880
rtmp_port: 1935
whip_port: 8080
http_relay_port: 9090
health_port: 9091
logging:
json: false
level: ""
development: false
rtc_config:
udp_port: 7885

41
livekit.yaml Normal file
View File

@ -0,0 +1,41 @@
# 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
port_range_start: 50000
port_range_end: 60000
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:
key1: abcdefghijklmnopqrstuvwxyz123456
webhook:
api_key: key1
urls:
- http://openvidu-shim:5443/openvidu/api/webhook
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