Recipes

CockroachDB

Self-hosted single-node Cockroach — COCKROACH_* env, port 26257, DB Console on :8080, driver stays postgres.

CockroachDB speaks Postgres wire closely enough that drivers.store.sql stays postgres. Pin cockroachdb/cockroach as store.sql and oke docker derives a single-node compose service — credentials, healthcheck, and DATABASE_URL.

The one rule

The driver id stays postgres — vendor choice lives in images["store.sql"], not in drivers.store.sql. Host maps :5432 → container :26257 so local apps keep the usual Postgres port.

Quick start

Pin the image

oke.config.ts
images: {
  "store.sql": "cockroachdb/cockroach:v25.2.0", // pin a real tag
},

Bring the stack up

oke dev

oke docker injects COCKROACH_USER / COCKROACH_PASSWORD / COCKROACH_DATABASE from OKE_STORE_SQL_*, starts start-single-node --accept-sql-without-tls, and publishes SQL on host :5432 plus the DB Console on :8080.

Connect

echo "$DATABASE_URL"
# postgres://oke:…@127.0.0.1:5432/oke?sslmode=require

Required env

VariableWho sets itMeaning
OKE_STORE_SQL_USERoke docker → composeCOCKROACH_USER (first boot only)
OKE_STORE_SQL_PASSWORDoke docker → composeCOCKROACH_PASSWORD
OKE_STORE_SQL_DBoke docker → composeCOCKROACH_DATABASE
DATABASE_URLstack env for the appIncludes sslmode=require

Data and backup

PathWhat lives there
/cockroach/cockroach-dataNamed volume store-sql-data — cluster store

Backup means: volume backup of store-sql-data, or Cockroach's backup tooling against a running node. Losing that volume loses the cluster.

Production note

This recipe is a single-node cluster — fine for local and small self-hosted apps, not multi-region HA. For managed multi-region, use the CockroachDB provider. Prefer a pinned tag, not latest.

What the recipe configures

FieldValue
Container port26257 (host publishes 5432)
Extra port8080 — DB Console
Commandstart-single-node --accept-sql-without-tls
HealthcheckGET /health?ready=1 on :8080
Connection URLpostgres://…?sslmode=require
Statspg_stat_statements unsupported

Query performance

Store → Performance returns PgStatStatementsUnsupported. oke does not shim Cockroach statement_statistics.

Troubleshooting

Learn more

Next

On this page