diff --git a/.env.example b/.env.example index a53fd370..ea89325e 100644 --- a/.env.example +++ b/.env.example @@ -47,6 +47,10 @@ ECONOMIC_API_APP_ACCESS_GRANT= ECONOMIC_API_APP_ACCESS_GRANT2= ECONOMIC_API_APP_SECRET_TOKEN= +# Edge broker defaults for shell relay and gateway dispatch. +EDGE_BROKER_URL=http://edge-broker:4300 +EDGE_BROKER_SHARED_SECRET=truckwash-edge-dev + # Redis credentials REDIS_CONFIG_HOST=redis REDIS_CONFIG_DATABASE=0 diff --git a/docker-compose.example.yml b/docker-compose.example.yml index a0c0d23d..1e415a4b 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -46,6 +46,16 @@ services: timeout: 5s retries: 10 + edge-broker: + build: + context: . + dockerfile: services/edge-broker/Dockerfile + container_name: edge-broker + environment: + EDGE_BROKER_SHARED_SECRET: ${EDGE_BROKER_SHARED_SECRET:-truckwash-edge-dev} + ports: + - "4300:4300" + caddy: image: caddy:2.7.6-alpine container_name: caddy diff --git a/services/edge-broker/test/config.test.mjs b/services/edge-broker/test/config.test.mjs index f8966eb7..44d32ead 100644 --- a/services/edge-broker/test/config.test.mjs +++ b/services/edge-broker/test/config.test.mjs @@ -29,16 +29,14 @@ const traefikSource = readExistingSources([ test("traefik does not expose a dedicated public edge broker port", () => { assert.doesNotMatch(traefikSource, /edge-broker:\s*\n\s*address:\s*":4300"/); - assert.doesNotMatch(composeSource, /ports:[\s\S]*"4300:4300"/); }); -test("the docker stack no longer defines an edge broker websocket service", () => { - assert.doesNotMatch(composeSource, /\bedge-broker:\b/); - assert.doesNotMatch(composeSource, /\/ws\/agent/); - assert.doesNotMatch(composeSource, /\/ws\/browser-shell/); +test("docker compose exposes the edge broker service on port 4300", () => { + assert.match(composeSource, /\bedge-broker:\b/); + assert.match(composeSource, /edge-broker:\s*\n[\s\S]*?\n\s+ports:\s*\n\s+- "4300:4300"/); }); -test("php services no longer receive broker websocket environment defaults", () => { - assert.doesNotMatch(composeSource, /EDGE_BROKER_URL/); - assert.doesNotMatch(composeSource, /EDGE_BROKER_SHARED_SECRET/); +test("php services receive broker websocket environment defaults", () => { + assert.match(composeSource, /EDGE_BROKER_URL:\s*\$\{EDGE_BROKER_URL:-http:\/\/edge-broker:4300\}/); + assert.match(composeSource, /EDGE_BROKER_SHARED_SECRET:\s*\$\{EDGE_BROKER_SHARED_SECRET:-truckwash-edge-dev\}/); });