From 9a0c5ba79731f40296aec632a429f0de193ede5e Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Wed, 24 Apr 2024 16:49:02 +0200 Subject: [PATCH] Remove docker-compose.override files and caddy-proxy folders --- community/caddy-proxy/Dockerfile | 23 -- community/caddy-proxy/README.md | 7 - community/caddy-proxy/entrypoint.sh | 30 --- community/caddy-proxy/go.mod | 3 - community/caddy-proxy/main.go | 249 ---------------------- community/caddy-proxy/templates/app502.go | 49 ----- community/caddy-proxy/templates/caddy.go | 160 -------------- community/caddy-proxy/templates/index.go | 100 --------- community/docker-compose.override.yaml | 26 --- community/docker-compose.yaml | 27 ++- 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/docker-compose.override.yaml | 26 --- pro/docker-compose.yaml | 27 ++- 20 files changed, 52 insertions(+), 1296 deletions(-) delete mode 100644 community/caddy-proxy/Dockerfile delete mode 100644 community/caddy-proxy/README.md delete mode 100644 community/caddy-proxy/entrypoint.sh delete mode 100644 community/caddy-proxy/go.mod delete mode 100644 community/caddy-proxy/main.go delete mode 100644 community/caddy-proxy/templates/app502.go delete mode 100644 community/caddy-proxy/templates/caddy.go delete mode 100644 community/caddy-proxy/templates/index.go delete mode 100644 community/docker-compose.override.yaml delete mode 100644 pro/caddy-proxy/Dockerfile delete mode 100644 pro/caddy-proxy/README.md delete mode 100644 pro/caddy-proxy/entrypoint.sh delete mode 100644 pro/caddy-proxy/go.mod delete mode 100644 pro/caddy-proxy/main.go delete mode 100644 pro/caddy-proxy/templates/app502.go delete mode 100644 pro/caddy-proxy/templates/caddy.go delete mode 100644 pro/caddy-proxy/templates/index.go delete mode 100644 pro/docker-compose.override.yaml diff --git a/community/caddy-proxy/Dockerfile b/community/caddy-proxy/Dockerfile deleted file mode 100644 index c8b5adb..0000000 --- a/community/caddy-proxy/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -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/community/caddy-proxy/README.md b/community/caddy-proxy/README.md deleted file mode 100644 index 8a5d447..0000000 --- a/community/caddy-proxy/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# 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/community/caddy-proxy/entrypoint.sh b/community/caddy-proxy/entrypoint.sh deleted file mode 100644 index 47b2ed3..0000000 --- a/community/caddy-proxy/entrypoint.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/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/community/caddy-proxy/go.mod b/community/caddy-proxy/go.mod deleted file mode 100644 index d8863f0..0000000 --- a/community/caddy-proxy/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module local-caddy-generate - -go 1.22.1 diff --git a/community/caddy-proxy/main.go b/community/caddy-proxy/main.go deleted file mode 100644 index 68b17bf..0000000 --- a/community/caddy-proxy/main.go +++ /dev/null @@ -1,249 +0,0 @@ -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/community/caddy-proxy/templates/app502.go b/community/caddy-proxy/templates/app502.go deleted file mode 100644 index c9cafec..0000000 --- a/community/caddy-proxy/templates/app502.go +++ /dev/null @@ -1,49 +0,0 @@ -package templates - -type App502Data struct { - Title string - Message string -} - -const App502Template = ` - - - - - 502 - Application Not Found - - - - - - -
-
-
502 - Bad Gateway
-

{{.Title}}

-
-

{{ .Message }}

-
-
- - - -` diff --git a/community/caddy-proxy/templates/caddy.go b/community/caddy-proxy/templates/caddy.go deleted file mode 100644 index 0818fb0..0000000 --- a/community/caddy-proxy/templates/caddy.go +++ /dev/null @@ -1,160 +0,0 @@ -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/community/caddy-proxy/templates/index.go b/community/caddy-proxy/templates/index.go deleted file mode 100644 index 65ff1a5..0000000 --- a/community/caddy-proxy/templates/index.go +++ /dev/null @@ -1,100 +0,0 @@ -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/community/docker-compose.override.yaml b/community/docker-compose.override.yaml deleted file mode 100644 index 712a4cb..0000000 --- a/community/docker-compose.override.yaml +++ /dev/null @@ -1,26 +0,0 @@ -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/community/docker-compose.yaml b/community/docker-compose.yaml index 77e0a63..5d33586 100644 --- a/community/docker-compose.yaml +++ b/community/docker-compose.yaml @@ -1,5 +1,4 @@ services: - caddy-proxy: image: docker.io/wcm65pck/openvidu-caddy-local:main container_name: caddy-proxy @@ -145,6 +144,32 @@ services: setup: condition: service_completed_successfully + 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 + ready-check: image: curlimages/curl:8.6.0 container_name: ready-check diff --git a/pro/caddy-proxy/Dockerfile b/pro/caddy-proxy/Dockerfile deleted file mode 100644 index c8b5adb..0000000 --- a/pro/caddy-proxy/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -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 deleted file mode 100644 index 8a5d447..0000000 --- a/pro/caddy-proxy/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# 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 deleted file mode 100644 index 47b2ed3..0000000 --- a/pro/caddy-proxy/entrypoint.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/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 deleted file mode 100644 index d8863f0..0000000 --- a/pro/caddy-proxy/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module local-caddy-generate - -go 1.22.1 diff --git a/pro/caddy-proxy/main.go b/pro/caddy-proxy/main.go deleted file mode 100644 index 68b17bf..0000000 --- a/pro/caddy-proxy/main.go +++ /dev/null @@ -1,249 +0,0 @@ -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 deleted file mode 100644 index c9cafec..0000000 --- a/pro/caddy-proxy/templates/app502.go +++ /dev/null @@ -1,49 +0,0 @@ -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 deleted file mode 100644 index 0818fb0..0000000 --- a/pro/caddy-proxy/templates/caddy.go +++ /dev/null @@ -1,160 +0,0 @@ -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 deleted file mode 100644 index 65ff1a5..0000000 --- a/pro/caddy-proxy/templates/index.go +++ /dev/null @@ -1,100 +0,0 @@ -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/docker-compose.override.yaml b/pro/docker-compose.override.yaml deleted file mode 100644 index 712a4cb..0000000 --- a/pro/docker-compose.override.yaml +++ /dev/null @@ -1,26 +0,0 @@ -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/pro/docker-compose.yaml b/pro/docker-compose.yaml index cb65306..3897ec5 100644 --- a/pro/docker-compose.yaml +++ b/pro/docker-compose.yaml @@ -1,5 +1,4 @@ services: - caddy-proxy: image: docker.io/wcm65pck/openvidu-caddy-local:main container_name: caddy-proxy @@ -147,6 +146,32 @@ services: setup: condition: service_completed_successfully + 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 + openvidu-v2compatibility: image: docker.io/wcm65pck/openvidu-v2compatibility:main restart: unless-stopped