diff --git a/docs/examples/analytics/compose.yaml b/docs/examples/analytics/compose.yaml index 6686a48a8..ea521e3f9 100644 --- a/docs/examples/analytics/compose.yaml +++ b/docs/examples/analytics/compose.yaml @@ -25,8 +25,10 @@ services: ports: ["127.0.0.1:8300:3000"] edge: image: nginx:1.30.6-alpine + # Docker Desktop/OrbStack provide this name; native Linux needs this mapping. + extra_hosts: ["host.docker.internal:host-gateway"] environment: - SKILLHUB_WEB_UPSTREAM: ${SKILLHUB_WEB_UPSTREAM:-host.docker.internal:8080} + SKILLHUB_WEB_UPSTREAM: ${SKILLHUB_WEB_UPSTREAM:-host.docker.internal:80} UMAMI_UPSTREAM: umami:3000 NGINX_ENVSUBST_FILTER: ^(SKILLHUB_WEB_UPSTREAM|UMAMI_UPSTREAM)$$ volumes: diff --git a/docs/examples/analytics/nginx.conf b/docs/examples/analytics/nginx.conf index 967baa959..e64ce3363 100644 --- a/docs/examples/analytics/nginx.conf +++ b/docs/examples/analytics/nginx.conf @@ -7,6 +7,8 @@ upstream skillhub_analytics_umami { server ${UMAMI_UPSTREAM}; } server { listen 8081; server_name localhost; + # Preserve the standard Web upload limit on every application proxy route. + client_max_body_size 100M; # Install ONLY the three .mjs files here, not declarations or other files. # A single versioned prefix serves the entry AND its relative imports. diff --git a/web/analytics-umami-example.test.ts b/web/analytics-umami-example.test.ts index 7b21462a7..28882c4e5 100644 --- a/web/analytics-umami-example.test.ts +++ b/web/analytics-umami-example.test.ts @@ -15,6 +15,44 @@ afterEach(() => { document.head.replaceChildren(); vi.useRealTimers(); vi.restor const website = '4398de8e-40df-4483-9eea-ed213643525f' const intent = { id: 'skill.example.open', event: 'click' } +describe('optional edge deployment defaults', () => { + const nginx = readFileSync('../docs/examples/analytics/nginx.conf', 'utf8') + const compose = readFileSync('../docs/examples/analytics/compose.yaml', 'utf8') + + it('inherits the standard 100 MiB limit on all proxied application routes', () => { + // Tokenize quoted strings as units so braces/semicolons in responses do not + // affect scope. Track blocks instead of accepting a location-only limit. + const tokens = nginx.replace(/#.*$/gm, '').match(/"[^"\n]*"|'[^'\n]*'|[{};]|[^\s{};]+/g) ?? [] + const blocks: string[] = [], statement: string[] = [] + const limits: Array<{ scope: string[]; value: string }> = [] + for (const token of tokens) { + if (token === '{') { blocks.push(statement.join(' ')); statement.length = 0 } + else if (token === '}') { blocks.pop(); statement.length = 0 } + else if (token === ';') { + if (statement[0] === 'client_max_body_size') limits.push({ scope: [...blocks], value: statement[1] }) + statement.length = 0 + } else statement.push(token) + } + expect(limits).toContainEqual({ scope: ['server'], value: '100M' }) + // A collector-only restriction is allowed; application locations must inherit. + expect(limits.filter(limit => limit.scope.some(scope => scope.startsWith('location') && !scope.includes('/_skillhub-umami/')))).toEqual([]) + expect(limits.filter(limit => limit.scope.length === 1)).toEqual([{ scope: ['server'], value: '100M' }]) + }) + + it('defaults to the release Web entry, not the development port', () => { + const release = readFileSync('../compose.release.yml', 'utf8') + expect(release).toContain('${WEB_PORT:-80}:80') + expect(compose).toContain('SKILLHUB_WEB_UPSTREAM: ${SKILLHUB_WEB_UPSTREAM:-host.docker.internal:80}') + expect(compose).not.toContain('host.docker.internal:8080') + }) + + it('maps the host gateway on native Linux for the edge service', () => { + const edge = compose.split('\n edge:\n')[1] + expect(edge).toBeDefined() + expect(edge).toContain('extra_hosts: ["host.docker.internal:host-gateway"]') + }) +}) + describe('product ID grammar parity', () => { it.each([4, 5, 6])('accepts a published %i-segment ID in rules and the final payload', segments => { const id = publishedIds.find(id => id.split('.').length === segments)!