Skip to content

Manual Setup

This guide walks through building and running Zori from source code.

Install the required tools:

Terminal window
git clone https://github.com/ZoriHQ/zori.git
cd zori

Start the required services. You can use Docker for these even when running the app manually:

Terminal window
# Start infrastructure services only
docker-compose -f run/tests/docker-compose.test.yaml up -d

Or install them natively:

  • PostgreSQL 15+
  • ClickHouse 24+
  • Redis 7+
  • NATS with JetStream enabled
Terminal window
# Copy the example environment file
cp example.env .env
# Edit with your settings
vim .env

Key settings for local development:

Terminal window
# Database
POSTGRES_URL=postgres://postgres:postgres@localhost:5434/postgres?sslmode=disable
CLICKHOUSE_URL=localhost:9000
CLICKHOUSE_USERNAME=default
CLICKHOUSE_PASSWORD=default
CLICKHOUSE_DATABASE=default
# Message Queue & Cache
NATS_STREAM_URL=nats://localhost:4222
REDIS_ADDRS=localhost:6379
# Security (generate your own for production!)
JWT_SECRET_KEY=your-secret-key-min-32-characters-long
ENCRYPTION_KEY=your-encryption-key-must-be-32-chars!
# Mode
ZORI_IS_OSS=true
Terminal window
# Run all database migrations
task migrate:up

This runs migrations for both PostgreSQL and ClickHouse.

You need to run two servers:

Terminal window
task server
# Starts on port 1323
Terminal window
task ingestion
# Starts on port 1324

Or use the quick start command:

Terminal window
task start
# Runs migrations and starts the API server
Terminal window
task --list
CommandDescription
task serverStart the API server (port 1323)
task ingestionStart the ingestion server (port 1324)
task migrate:upRun all pending migrations
task migrate:downRollback the last migration
task startRun migrations and start server
task testRun the test suite
task docsGenerate Swagger documentation
Terminal window
# Build the binary
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o zori .
# Run the API server
./zori server
# Run the ingestion server
./zori ingestion

The included Dockerfile builds a minimal production image:

Terminal window
# Build the image
docker build -f run/docker/Dockerfile -t zori:latest .
# Run the API server
docker run -p 1323:1323 --env-file .env zori:latest server
# Run the ingestion server
docker run -p 1324:1324 --env-file .env zori:latest ingestion

Test the API server:

Terminal window
curl http://localhost:1323/health

Test the ingestion endpoint:

Terminal window
curl http://localhost:1324/health

If migrations fail, check your database connections:

Terminal window
# Test PostgreSQL
psql $POSTGRES_URL -c "SELECT 1"
# Test ClickHouse
curl "http://localhost:8123/?query=SELECT%201"

Change the ports in your environment:

Terminal window
# In .env
TEST_SERVER_PORT=1325

Ensure JetStream is enabled:

Terminal window
nats -s nats://localhost:4222 stream ls