refactor(docker): align echo.ts with the shared sendkit config

Make resources/js/echo.ts byte-identical to the sendkit Echo setup
(VITE_REVERB_* read directly, no window.location derivation). The release
workflow now bakes only VITE_REVERB_APP_KEY, and compose.prod.yaml restores
the 8080 host port so the published image's Reverb client (baked at
localhost:8080) works for local docker compose. A custom-domain deploy needs
the image rebuilt with VITE_REVERB_HOST/PORT/SCHEME set.
This commit is contained in:
Paulo Castellano 2026-05-27 15:17:47 -03:00
parent 48727c80cd
commit 09fa97d539
3 changed files with 10 additions and 18 deletions

View file

@ -63,13 +63,8 @@ jobs:
target: production
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
# Bake a fixed public Reverb key; leave host/port/scheme empty so the
# frontend derives them from window.location (works on any domain).
build-args: |
VITE_REVERB_APP_KEY=trypost-reverb-key
VITE_REVERB_HOST=
VITE_REVERB_PORT=
VITE_REVERB_SCHEME=
cache-from: type=gha,scope=${{ env.PLATFORM_PAIR }}
cache-to: type=gha,mode=max,scope=${{ env.PLATFORM_PAIR }}
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true

View file

@ -40,11 +40,11 @@ services:
BROADCAST_CONNECTION: reverb
# ===== WebSockets (Reverb) =====
# These are the INTERNAL server->Reverb connection — leave as-is even on a
# domain. The browser derives the WebSocket host from its own URL, and the
# in-container nginx proxies it on /app, so it just works on any domain.
# The published image bakes the client at localhost:8080. For a custom
# domain, rebuild the image with --build-arg VITE_REVERB_HOST=<domain>
# VITE_REVERB_PORT=443 VITE_REVERB_SCHEME=https.
REVERB_APP_ID: "1001"
REVERB_APP_KEY: trypost-reverb-key # matches the key baked into the published image
REVERB_APP_KEY: trypost-reverb-key # must match the key baked into the published image
REVERB_APP_SECRET: change-me-reverb-secret # <- change me
REVERB_HOST: localhost
REVERB_PORT: "8080"
@ -105,7 +105,8 @@ services:
# ANTHROPIC_API_KEY: ""
# GEMINI_API_KEY: ""
ports:
- "8000:80" # app (nginx); WebSocket rides this same port via /app
- "8000:80" # app (nginx)
- "8080:8080" # Reverb WebSocket
volumes:
- storage:/var/www/html/storage/app
depends_on:

View file

@ -1,15 +1,11 @@
import { configureEcho } from '@laravel/echo-vue';
const scheme = import.meta.env.VITE_REVERB_SCHEME || (window.location.protocol === 'https:' ? 'https' : 'http');
const forceTLS = scheme === 'https';
const port = Number(import.meta.env.VITE_REVERB_PORT || window.location.port || (forceTLS ? 443 : 80));
configureEcho({
broadcaster: 'reverb',
key: import.meta.env.VITE_REVERB_APP_KEY,
wsHost: import.meta.env.VITE_REVERB_HOST || window.location.hostname,
wsPort: port,
wssPort: port,
forceTLS,
wsHost: import.meta.env.VITE_REVERB_HOST,
wsPort: import.meta.env.VITE_REVERB_PORT ?? 80,
wssPort: import.meta.env.VITE_REVERB_PORT ?? 443,
forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
enabledTransports: ['ws', 'wss'],
});