From 063914af04bf293d1c24e0c26b22d5aabd731d29 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Tue, 23 Apr 2024 11:06:41 -0700 Subject: [PATCH] chore: get websocket service to start in docker-compose (#28135) --- docker-compose.yml | 4 ++++ docker/superset-websocket/config.json | 22 ++++++++++++++++++++++ superset-websocket/src/index.ts | 13 +++++++++++-- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 docker/superset-websocket/config.json diff --git a/docker-compose.yml b/docker-compose.yml index 579295fb7..18622eb0a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -120,6 +120,10 @@ services: - ./superset-websocket:/home/superset-websocket - /home/superset-websocket/node_modules - /home/superset-websocket/dist + + # Mounting a config file that contains a dummy secret required to boot up. + # do no not use this docker-compose in production + - ./docker/superset-websocket/config.json:/home/superset-websocket/config.json environment: - PORT=8080 - REDIS_HOST=redis diff --git a/docker/superset-websocket/config.json b/docker/superset-websocket/config.json new file mode 100644 index 000000000..8f6afdcc2 --- /dev/null +++ b/docker/superset-websocket/config.json @@ -0,0 +1,22 @@ +{ + "port": 8080, + "logLevel": "info", + "logToFile": false, + "logFilename": "app.log", + "statsd": { + "host": "127.0.0.1", + "port": 8125, + "globalTags": [] + }, + "redis": { + "port": 6379, + "host": "127.0.0.1", + "password": "", + "db": 0, + "ssl": false + }, + "redisStreamPrefix": "async-events-", + "jwtAlgorithms": ["HS256"], + "jwtSecret": "CHANGE-ME-IN-PRODUCTION-GOTTA-BE-LONG-AND-SECRET", + "jwtCookieName": "async-token" +} diff --git a/superset-websocket/src/index.ts b/superset-websocket/src/index.ts index ced46f18b..96d056a92 100644 --- a/superset-websocket/src/index.ts +++ b/superset-websocket/src/index.ts @@ -94,8 +94,17 @@ export const statsd = new StatsD({ }); // enforce JWT secret length -if (startServer && opts.jwtSecret.length < 32) - throw new Error('Please provide a JWT secret at least 32 bytes long'); +if (startServer && opts.jwtSecret.length < 32) { + console.error('ERROR: Please provide a JWT secret at least 32 bytes long'); + process.exit(1); +} + +if (startServer && opts.jwtSecret.startsWith('CHANGE-ME')) { + console.warn( + 'WARNING: it appears you secret in your config.json is insecure', + ); + console.warn('DO NOT USE IN PRODUCTION'); +} export const buildRedisOpts = (baseConfig: RedisConfig) => { const redisOpts: RedisOptions = {