# Optional TURN relay for live view; Central uses its URL and shared secret to # issue short-lived browser credentials. Public reachability needs deployment # firewall/NAT validation. services: coturn: image: coturn/coturn:4.6 pull_policy: always # Local Compose secrets are read-only bind mounts and preserve the # installer's 0600 owner-only permissions. Read the mounted file as a # short-lived root initializer, write a private config into tmpfs, then # run turnserver as nobody. The upstream binary does not exec with a # reduced capability set; no-new-privileges still prevents elevation. user: "0:0" security_opt: - no-new-privileges:true tmpfs: - /run/coturn:rw,noexec,nosuid,nodev,size=1m,mode=0700 ports: - "${COTURN_PORT:-3478}:3478/tcp" - "${COTURN_PORT:-3478}:3478/udp" - "${COTURN_RELAY_PORT_MIN:-49160}-${COTURN_RELAY_PORT_MAX:-49200}:${COTURN_RELAY_PORT_MIN:-49160}-${COTURN_RELAY_PORT_MAX:-49200}/udp" entrypoint: ["/bin/sh", "-c"] command: - >- set -eu; umask 077; printf 'use-auth-secret\nstatic-auth-secret=%s\nrealm=%s\nfingerprint\nno-tlsv1\nno-tlsv1_1\nlog-file=stdout\nno-cli\nlistening-port=3478\nmin-port=%s\nmax-port=%s\n' "$$(cat /run/secrets/coturn_secret)" "${COTURN_REALM:-heimdall.local}" "${COTURN_RELAY_PORT_MIN:-49160}" "${COTURN_RELAY_PORT_MAX:-49200}" > /run/coturn/turnserver.conf; printf 'pidfile=/run/coturn/turnserver.pid\n' >> /run/coturn/turnserver.conf; if [ -n "$$COTURN_EXTERNAL_IP" ]; then printf 'external-ip=%s\n' "$$COTURN_EXTERNAL_IP" >> /run/coturn/turnserver.conf; fi; chown 65534:65534 /run/coturn /run/coturn/turnserver.conf; exec su -s /bin/sh -c 'exec /usr/bin/turnserver -c /run/coturn/turnserver.conf' nobody environment: COTURN_EXTERNAL_IP: ${COTURN_EXTERNAL_IP:-} secrets: - coturn_secret restart: unless-stopped secrets: coturn_secret: file: ./optional/secrets/coturn_secret