Configuration Overview
Cube.js is designed to work with different configuration sources. There are two
ways you can set configuration options; via a configuration file,
commonly known as the cube.js
file, and environment
variables.
When using Docker, ensure that the cube.js
configuration file and your
schema/
folder are mounted to /cube/conf
within the Docker container.
In Cube.js, values specified in cube.js
take precedence over environment
variables.
Cube.js can be run in an insecure, development mode by setting the
CUBEJS_DEV_MODE
environment variable to true
. Putting Cube.js in development
mode does the following:
- Disables authentication checks
- Enables Cube Store in single instance mode
- Enables background refresh for in-memory cache and scheduled pre-aggregations
- Allows another log level to be set (
trace
) - Enables Developer Playground on
http://localhost:4000
- Uses
memory
instead ofredis
as the default cache/queue engine - Logs incorrect/invalid configuration for
externalRefresh
/waitForRenew
instead of throwing errors
The Cube.js REST API supports Cross-Origin Resource Sharing (CORS) for all API
requests. By default, the middleware allows requests from any origin (*
). To
change the allowed domain, you can do the following:
module.exports = {
http: {
cors: {
origin: 'https://myapp.com',
},
},
};
Please consult the Configuration Reference for more options.
Since v0.23
, Cube.js CLI uses the docker
template
instead of express
as a default for project creation, and it is the
recommended route for production. To migrate you should move all Cube.js
dependencies in package.json
to devDependencies
and leave dependencies that
you use to configure Cube.js in dependencies
.
For example, your existing package.json
might look something like:
{
"name": "cubejs-app",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "node index.js"
},
"dependencies": {
"@cubejs-backend/postgres-driver": "^0.20.0",
"@cubejs-backend/server": "^0.20.0"
}
}
It should become:
{
"name": "cubejs-app",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "./node_modules/.bin/cubejs-server server"
},
"dependencies": {
},
"devDependencies": {
"@cubejs-backend/postgres-driver": "^0.23.6",
"@cubejs-backend/server": "^0.23.7"
}
}
You should also rename your index.js
file to cube.js
and replace the
CubejsServer.create()
call with export of configuration using
module.exports
.
For an index.js
like the following:
const CubejsServer = require('@cubejs-backend/server');
const server = new CubejsServer({
logger: (msg, params) => {
console.log(`${msg}: ${JSON.stringify(params)}`);
},
});
server
.listen()
.then(({ version, port }) => {
console.log(`🚀 Cube.js server (${version}) is listening on ${port}`);
})
.catch((e) => {
console.error('Fatal error during server start: ');
console.error(e.stack || e);
});
It should be renamed to cube.js
and its' contents should look like:
module.exports = {
logger: (msg, params) => {
console.log(`${msg}: ${JSON.stringify(params)}`);
},
};
Finally, add a docker-compose.yml
file alongside the cube.js
configuration
file:
version: '2.2'
services:
cube:
image: cubejs/cube:latest
ports:
- 4000:4000
env_file: .env
volumes:
- .:/cube/conf
Did you find this page useful?