matrix
matrix copied to clipboard
Error when using custom ROOMs (docker compose env)
Description
When I start the app in standard mode everything works perfectly, however when trying to use custom ROOMs an error occurs.
It appears that the app is not recognizing the environment variables.
After a lot of struggle I noticed that the problem was in the way the array of objects is written in the variable ROOMS_DATA this must be written on the same line.
It would be interesting to put this notice in the documentation.
Steps to Reproduce
git clone https://github.com/ResultadosDigitais/matrix.git
cd matrix
mv variables.exampla.env variable.env
vi variable.env
GOOGLE_CLIENT_ID=888888888888-jajajajajajajjajaja.apps.googleusercontent.com
GOOGLE_SECRET=DIHOIHDIHWIHDWIOWD
GOOGLE_CALLBACK_URL=https://dominio.com.br/auth/google/callback
COOKIE_SESSION_SECRET=matrix-session
COOKIE_SESSION_MAX_AGE=2592000000
ENFORCE_SSL=false
WHITELIST_DOMAINS="["dominio.com.br"]"
ROOMS_SOURCE=ENVIRONMENT
ROOMS_DATA=[
{
"id":"${UUID}",
"name":"Lounge",
"disableMeeting":true
},
{
"id":"${UUID}",
"name":"WAR ROOM CDP"
},
]
vi docker-compose.yml
version: '3'
services:
web:
working_dir: /var/app
env_file:
- variables.env
restart: always
ports:
- '8090:8080'
#- '8080:8080'
#entrypoint: 'sh /docker-entrypoint.sh npm run start'
build:
context: ./
docker-compose -f docker-compose.yml up --build
Versions
docker-compose --version docker-compose version 1.24.0, build 0aa59064 docker --version Docker version 18.09.6, build 481bc77156
Current Behavior
[root@server matrix]# docker-compose -f docker-compose.yml up --build Creating network "matrix_default" with the default driver Creating matrix_web_1 ... done Attaching to matrix_web_1 web_1 | web_1 | > matrix-backend@ start-backend /var/app/backend web_1 | > NODE_ENV=production node ./dist/index.js web_1 | web_1 | undefined:1 web_1 | [ web_1 | web_1 | web_1 | SyntaxError: Unexpected end of JSON input web_1 | at JSON.parse (<anonymous>) web_1 | at fetchFromEnvironment (/var/app/backend/dist/controllers/rooms.controller.js:59:26) web_1 | at fetchRooms (/var/app/backend/dist/controllers/rooms.controller.js:69:14) web_1 | at Object.<anonymous> (/var/app/backend/dist/app.server.js:59:23) web_1 | at Module._compile (internal/modules/cjs/loader.js:776:30) web_1 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10) web_1 | at Module.load (internal/modules/cjs/loader.js:653:32) web_1 | at tryModuleLoad (internal/modules/cjs/loader.js:593:12) web_1 | at Function.Module._load (internal/modules/cjs/loader.js:585:3) web_1 | at Module.require (internal/modules/cjs/loader.js:690:17) web_1 | npm ERR! code ELIFECYCLE web_1 | npm ERR! errno 1 web_1 | npm ERR! matrix-backend@ start-backend:
NODE_ENV=production node ./dist/index.jsweb_1 | npm ERR! Exit status 1 web_1 | npm ERR! web_1 | npm ERR! Failed at the matrix-backend@ start-backend script. web_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above. web_1 | web_1 | npm ERR! A complete log of this run can be found in: web_1 | npm ERR! /root/.npm/_logs/2020-04-06T14_15_41_002Z-debug.log
Solution
Written on the same line.
ROOMS_DATA=[ { "id":"${UUID}", "name":"Lounge", "disableMeeting":true }, { "id":"${UUID}", "name":"WAR ROOM CDP" }]
A suggestion, if is possible, could be to read the rooms directly from a separate JSON file. That way it is easier to configure and view.
Hi @Leonardoperrella I created this PR add a remote room file option #299 What do you think about this solution?
Very good!!