Getting Started with Docker
This guide will help you get Cube.js running as a Docker container using Docker Compose.
docker-compose.yml file with the following content.
version: '2.2' services: cube: image: cubejs/cube:latest ports: # 4000 is a port for Cube.js API - 4000:4000 # 3000 is a port for Playground web server # it is available only in dev mode - 3000:3000 env_file: .env volumes: - ./schema:/cube/conf/schema
We'll configure the database connection via environment variables. You can learn more about setting credentials for different databases in the Connecting to the Database guide.
The example below is for a Postgres instance running locally.
# Create an .env file with the following content CUBEJS_DB_TYPE=postgres # For Mac CUBEJS_DB_HOST=host.docker.internal # For Windows CUBEJS_DB_HOST=docker.for.win.localhost # For Linux CUBEJS_DB_HOST=localhost CUBEJS_DB_NAME=databasename CUBEJS_DB_USER=databaseuser CUBEJS_DB_PASS=secret CUBEJS_WEB_SOCKETS=true CUBEJS_DEV_MODE=true CUBEJS_API_SECRET=SECRET
For Linux, add the following line to your
$ docker-compose up -d
Check if the container is running:
$ docker ps
Head to http://localhost:4000 to open the Playground.
You can generate Data Schema files using the Playground. Once schema files are generated you can execute queries on the Build tab in the Playground.
Generating Data Schema files in the Playground is a good first step to start modelling your data. You can learn more about Cube.js Data Schema for complex data modelling techniques.
When using the
cube.js file for configuration, you need to add it
volumes definition in your
volumes: - ./schema:/cube/conf/schema - ./cube.js:/cube/conf/cube.js