m
Hi
t
Thanks for reaching out, Daivik. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi — thanks for saying hello! I’m here to help. Could you tell me what you need help with today? A few examples to pick from: • Trouble joining or hosting a room (share room ID or error message) • Issues with audio/video quality or screen share • SDK or API questions (which SDK and code snippet if possible) • Billing, plan, or account questions • Something else — describe the problem or goal If you’re not sure where to start, briefly describe what you’re trying to accomplish and any errors or unexpected behavior you’re seeing. I’ll guide you through the next steps.
m
Hi i am using self hosting. I want to know how can i store the sip trunk and dispatch rule to the database as redis is not good for storing such things as we need it permanently for whole livekit instance and server.
t
Thanks — I understand you’re self-hosting LiveKit and want to persist SIP trunk and dispatch rule configuration permanently (not in Redis). Good question. Short answer: SIP trunks and dispatch rules are stored persistently in LiveKit’s primary database (typically PostgreSQL) for self-hosted deployments. Redis is used only for ephemeral state and signaling — you don’t need to add separate persistence for those SIP resources. What this means for you: • When you create SIP trunks or dispatch rules via the LiveKit API or CLI, those records are written to the primary database and survive server restarts. • The server SDKs and API calls that create these resources (for example
CreateSIPInboundTrunkRequest
and
CreateSIPDispatchRuleRequest
) persist them automatically. • To remove them you would explicitly call the delete endpoints (for example
delete_sip_trunk()
or
delete_sip_dispatch_rule()
). If you’d like, I can help with next steps: • Explain which API/CLI call or SDK method to use for creating trunks or rules in your language (tell me which SDK you’re using: Go, Python, JS, etc.). • Walk through validating that entries exist in your PostgreSQL database (which tables/columns to check) if you want to confirm persistence. • Show an example payload for a trunk or dispatch rule and how to create it programmatically. Which of those would be most helpful right now? Sources: sip | livekit/livekit_composite | DeepWiki | Python SDKs | livekit/livekit_composite | DeepWiki
m
can you give me sample docker-compose file including redis, postgres db, livekit server and sip server for self hosting
t
Thanks — I can create a tailored docker-compose.yml that includes Redis, PostgreSQL, LiveKit server, and a SIP server. To make the file match your needs, could you tell me a few quick details? 1. Which SIP server do you want in the compose file? (Common choices: FreeSWITCH, Asterisk, Kamailio, OpenSIPS.) 2. Which LiveKit server image/version should I use? (If you don’t care, I’ll pick the latest official
livekit/livekit-server
image.) 3. Will you terminate TLS/WSS externally (reverse proxy / LB) or do you want TLS configured in the compose file? 4. Do you want a TURN server included (coturn) for NAT traversal? 5. Any required ports, credentials, or volume paths you must use? Or should I include example credentials and named volumes you can replace? 6. Do you want SIP trunks/dispatch rules preconfigured in the database, or is starting the runtime services enough for now? 7. For SIP networking, do you prefer
host
network mode (often needed for SIP RTP) or the default Docker bridge? If you prefer, I can start with a sensible default set (FreeSWITCH, latest LiveKit image, no TLS, include coturn, example creds, and bridge networking) and you can adjust after. Which option do you want me to use?
m
i will choose that for now just include the redis and postgres with the livekit server using v1.9.7
t
Thanks — I’ll provide a sensible, ready-to-run docker-compose.yml that includes Redis, PostgreSQL, and LiveKit server v1.9.7. This will use example credentials and named volumes you can replace. It does not include TLS termination, TURN, or a SIP server (you requested just Redis + Postgres + LiveKit v1.9.7). If you want TLS, coturn, or a SIP server added later, tell me and I’ll extend it. Notes before you run: • LiveKit stores SIP trunks and dispatch rules in the primary DB (Postgres), not in Redis. Records created via the LiveKit API/CLI are persisted automatically. • Replace example passwords, keys, and secrets before using in production. • For production deployments, secure credentials via environment variables or a secrets manager, enable TLS, and adjust resource limits. Sample docker-compose.yml
Copy code
version: "3.8"

services:
  redis:
    image: redis:7-alpine
    container_name: livekit_redis
    restart: unless-stopped
    volumes:
      - redis_data:/data
    command: ["redis-server", "--save", "900", "1", "--appendonly", "yes"]
    networks:
      - livekit_net

  postgres:
    image: postgres:15-alpine
    container_name: livekit_postgres
    restart: unless-stopped
    environment:
      POSTGRES_DB: livekit
      POSTGRES_USER: livekit
      POSTGRES_PASSWORD: livekitpassword
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - livekit_net

  livekit:
    image: livekit/livekit-server:v1.9.7
    container_name: livekit_server
    restart: unless-stopped
    depends_on:
      - redis
      - postgres
    ports:
      - "7880:7880"   # API / mixed (plaintext)
      - "7881:7881"   # internal grpc-web, optional
      - "7882:7882"   # optional additional port if needed
    environment:
      # Keys and secrets - replace in production
      - LIVEKIT_API_KEY=example_api_key
      - LIVEKIT_API_SECRET=example_api_secret

      # Storage / DB config
      - LIVEKIT_DB=<postgres://livekit:livekitpassword@postgres:5432/livekit?sslmode=disable>

      # Redis URL for ephemeral state/signaling (LiveKit uses Redis for ephemeral)
      - LIVEKIT_REDIS=<http://redis:6379>

      # Prometheus metrics - optional
      - LIVEKIT_PROMETHEUS=true

      # Logging level
      - LOG_LEVEL=info

      # Optional: allow all origins for easy local testing (restrict in production)
      - LIVEKIT_ALLOW_ORIGINS=*

    volumes:
      - livekit_data:/var/lib/livekit
    networks:
      - livekit_net

volumes:
  redis_data:
  postgres_data:
  livekit_data:

networks:
  livekit_net:
    driver: bridge
Quick verification steps after starting: 1. Start services: a. docker-compose up -d 1. Confirm containers are healthy: a. docker-compose ps 1. Confirm LiveKit can reach Postgres and Redis by checking logs: a. docker logs -f livekit_server b. Look for messages about successful DB connection and Redis connection. How to create SIP trunks / dispatch rules (brief) • Use the LiveKit API/CLI or server SDKs to create SIP trunks and dispatch rules. Those are persisted automatically into Postgres for self-hosted deployments and will survive restarts. If you want: • I can add a sample init script that seeds example SIP trunk and dispatch rule records into Postgres (tell me which SDK or API you prefer). • I can add coturn, TLS reverse proxy (Traefik or Nginx), or a SIP server (FreeSWITCH / Asterisk) to the compose file. • I can adjust the Postgres and Redis config for production readiness (auth, backups, persistence options). Which addition would you like next?