---
title: "Deploy Cube"
description: "Semantic layer for BI, apps and AI: API, refresh worker, Cube Store"
category: "Analytics"
url: https://railway.com/deploy/cube-1
---

# Deploy Cube

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

**[Deploy Cube on Railway](https://railway.com/template/cube-1)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/cube-1/manifest.json

- **Creator:** Agaz Self-Host
- **Category:** Analytics

## Template content

### Cube API https://raw.githubusercontent.com/cube-js/cube/v1.8.29/packages/cubejs-playground/public/apple-touch-icon.png

- **Source:** https://github.com/aalfath/cube-railway-template
- **Health check:** /readyz
- **Public domain:** Yes

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### Cube Store Worker https://raw.githubusercontent.com/cube-js/cube/v1.8.29/packages/cubejs-playground/public/apple-touch-icon.png

- **Source:** https://github.com/aalfath/cube-railway-template

### Cube Refresh Worker https://raw.githubusercontent.com/cube-js/cube/v1.8.29/packages/cubejs-playground/public/apple-touch-icon.png

- **Source:** https://github.com/aalfath/cube-railway-template
- **Health check:** /readyz

### Cube Store Router https://raw.githubusercontent.com/cube-js/cube/v1.8.29/packages/cubejs-playground/public/apple-touch-icon.png

- **Source:** https://github.com/aalfath/cube-railway-template
- **Health check:** /readyz

## Buckets

- **Bucket**

## Documentation

# 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

* Cube on GitHub: https://github.com/cube-js/cube (release v1.8.29)
* Cube's Docker deployment guide: https://cube.dev/docs/product/deployment/core
* Template source and changelog: https://github.com/aalfath/cube-railway-template

### 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:

```bash
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.



## Similar templates

- [Plausible WordPress](https://railway.com/deploy/deploy-plausible-for-wordpress-sites) — Cookie-free WordPress stats from your own Plausible
- [Typesense Multilingual](https://railway.com/deploy/deploy-typesense-multilingual-search) — Locale-aware multilingual search with Typesense
- [Formbricks](https://railway.com/deploy/formbricks-surveys) — Surveys, NPS and in-app feedback on your own Postgres, Hub and Cube

Open this page in a browser: https://railway.com/deploy/cube-1
