name: livesync-browser-apps-interop

services:
    nostr-relay:
        image: ghcr.io/hoytech/strfry:latest
        entrypoint: sh
        command:
            - -lc
            - |
                cat > /tmp/strfry.conf <<'EOF'
                db = "./strfry-db/"

                relay {
                  bind = "0.0.0.0"
                  port = 7777
                  nofiles = 65536

                  info {
                    name = "livesync browser application test relay"
                    description = "local relay for the browser application interoperability test"
                  }

                  maxWebsocketPayloadSize = 131072
                  autoPingSeconds = 55

                  writePolicy {
                    plugin = ""
                  }
                }
                EOF
                exec /app/strfry --config /tmp/strfry.conf relay
        tmpfs:
            - /app/strfry-db:rw,size=256m,mode=1777
        healthcheck:
            test: ["CMD-SHELL", "nc -z 127.0.0.1 7777"]
            interval: 2s
            timeout: 5s
            retries: 30

    coturn:
        image: coturn/coturn:latest
        command:
            - --log-file=stdout
            - --listening-port=3478
            - --user=testuser:testpass
            - --realm=livesync.test

    browser-apps-interop:
        build:
            context: ../..
            dockerfile: test/browser-apps/Dockerfile.interop
        depends_on:
            nostr-relay:
                condition: service_healthy
            coturn:
                condition: service_started
        environment:
            BROWSER_APPS_P2P_RELAY_URL: ws://nostr-relay:7777/
            BROWSER_APPS_P2P_TURN_SERVERS: turn:coturn:3478
            BROWSER_APPS_P2P_TURN_USERNAME: testuser
            BROWSER_APPS_P2P_TURN_CREDENTIAL: testpass
        init: true
        ipc: host
        volumes:
            - ../..:/workspace
