Deploy Cube

Semantic layer for BI, apps and AI: API, refresh worker, Cube Store

Deploy Cube

Just deployed

/var/lib/postgresql/data

Just deployed

/cube/data

Just deployed

Just deployed

/cube/data

Bucket

Bucket

Just deployed

Deploy and Host Cube on Railway

Cube is an open-source semantic layer. You define metrics, dimensions and joins once in a data model, and Cube serves them over REST, GraphQL and a Postgres-compatible SQL API to dashboards, BI tools, embedded analytics and AI agents. It caches results and builds pre-aggregations in its own engine, Cube Store.

About Hosting Cube

A production Cube deployment has four parts: the API that answers queries, a refresh worker that builds and refreshes pre-aggregations, and a Cube Store cluster (a router and at least one worker) that holds the cache, the job queue and the pre-aggregated data. Cube Store nodes need disk for their metastore and shared object storage that every node can read. This template wires all of it on Railway's private network: Cube API (public), Cube Refresh Worker, Cube Store Router and Worker (each on a volume), a Railway Bucket as shared storage, and Postgres as a sample data source with a ready-made orders model. Secrets are generated, and no prompts appear at deploy.

Common Use Cases

  • One set of metric definitions for every BI tool, notebook and app that speaks SQL, REST or GraphQL
  • Fast embedded analytics in your own product, with JWT-scoped access and pre-aggregations
  • A governed data layer that AI agents and LLM tools can query safely

Dependencies for Cube Hosting

  • Cube API and Cube Refresh Worker (cubejs/cube:v1.8.29)
  • Cube Store Router and Cube Store Worker (cubejs/cubestore:v1.8.29)
  • PostgreSQL (sample data source) and a Railway Bucket (Cube Store remote storage)

Deployment Dependencies

Implementation Details

Services in this template:

  • Cube API (public): REST at /cubejs-api/v1, GraphQL at /cubejs-api/graphql, health at /readyz. The SQL API listens on port 15432 on the private network (user cube, password in CUBEJS_SQL_PASSWORD); add a TCP proxy to port 15432 to reach it from outside.
  • Cube Refresh Worker: builds the orders_by_day pre-aggregation and keeps it fresh.
  • Cube Store Router: metastore, cache and queue, on a volume.
  • Cube Store Worker: stores partitions and runs queries, on a volume.
  • Postgres: holds cube_demo.orders (1,000 sample rows, created on first start).
  • Bucket: shared S3-compatible storage for Cube Store.

After deploy, every API call needs a JWT signed (HS256) with CUBEJS_API_SECRET from the Cube API service:

node -e "console.log(require('jsonwebtoken').sign({}, 'CUBEJS_API_SECRET-VALUE', {expiresIn: '30d'}))"
curl -G https://YOUR-DOMAIN/cubejs-api/v1/load -H "Authorization: YOUR-JWT" \
  --data-urlencode 'query={"measures":["orders.count"],"dimensions":["orders.city"]}'

To use your own warehouse, change CUBEJS_DB_* (and add CUBEJS_DB_TYPE, for example bigquery or snowflake) on both Cube API and Cube Refresh Worker, set CUBE_SAMPLE_DATA=false on Cube API, and replace the model in cube/model/ of your copy of the template repo. Updates: the images are pinned in the template repo; when a new Cube version is merged there, Railway shows an update notice on your project, and you apply it when you choose (read the repo's CHANGELOG first).

Why Deploy Cube on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Cube on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


Template Content

More templates in this category

View Template
Plausible WordPress
Cookie-free WordPress stats from your own Plausible

onepush
0
View Template
Typesense Multilingual
Locale-aware multilingual search with Typesense

onepush
0
View Template
Formbricks
Surveys, NPS and in-app feedback on your own Postgres, Hub and Cube

Two Workspaces
3