Manual Setup
This guide walks through building and running Zori from source code.
Prerequisites
Section titled “Prerequisites”Install the required tools:
- Go 1.24+: golang.org/dl
- Task: taskfile.dev
- goose:
go install github.com/pressly/goose/v3/cmd/goose@latest
Clone the Repository
Section titled “Clone the Repository”git clone https://github.com/ZoriHQ/zori.gitcd zoriSet Up Infrastructure
Section titled “Set Up Infrastructure”Start the required services. You can use Docker for these even when running the app manually:
# Start infrastructure services onlydocker-compose -f run/tests/docker-compose.test.yaml up -dOr install them natively:
- PostgreSQL 15+
- ClickHouse 24+
- Redis 7+
- NATS with JetStream enabled
Configure Environment
Section titled “Configure Environment”# Copy the example environment filecp example.env .env
# Edit with your settingsvim .envKey settings for local development:
# DatabasePOSTGRES_URL=postgres://postgres:postgres@localhost:5434/postgres?sslmode=disableCLICKHOUSE_URL=localhost:9000CLICKHOUSE_USERNAME=defaultCLICKHOUSE_PASSWORD=defaultCLICKHOUSE_DATABASE=default
# Message Queue & CacheNATS_STREAM_URL=nats://localhost:4222REDIS_ADDRS=localhost:6379
# Security (generate your own for production!)JWT_SECRET_KEY=your-secret-key-min-32-characters-longENCRYPTION_KEY=your-encryption-key-must-be-32-chars!
# ModeZORI_IS_OSS=trueRun Migrations
Section titled “Run Migrations”# Run all database migrationstask migrate:upThis runs migrations for both PostgreSQL and ClickHouse.
Start the Servers
Section titled “Start the Servers”You need to run two servers:
Terminal 1: API Server
Section titled “Terminal 1: API Server”task server# Starts on port 1323Terminal 2: Ingestion Server
Section titled “Terminal 2: Ingestion Server”task ingestion# Starts on port 1324Or use the quick start command:
task start# Runs migrations and starts the API serverAvailable Task Commands
Section titled “Available Task Commands”task --list| Command | Description |
|---|---|
task server | Start the API server (port 1323) |
task ingestion | Start the ingestion server (port 1324) |
task migrate:up | Run all pending migrations |
task migrate:down | Rollback the last migration |
task start | Run migrations and start server |
task test | Run the test suite |
task docs | Generate Swagger documentation |
Building for Production
Section titled “Building for Production”# Build the binaryCGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o zori .
# Run the API server./zori server
# Run the ingestion server./zori ingestionUsing the Dockerfile
Section titled “Using the Dockerfile”The included Dockerfile builds a minimal production image:
# Build the imagedocker build -f run/docker/Dockerfile -t zori:latest .
# Run the API serverdocker run -p 1323:1323 --env-file .env zori:latest server
# Run the ingestion serverdocker run -p 1324:1324 --env-file .env zori:latest ingestionVerifying the Setup
Section titled “Verifying the Setup”Test the API server:
curl http://localhost:1323/healthTest the ingestion endpoint:
curl http://localhost:1324/healthTroubleshooting
Section titled “Troubleshooting”Migration Errors
Section titled “Migration Errors”If migrations fail, check your database connections:
# Test PostgreSQLpsql $POSTGRES_URL -c "SELECT 1"
# Test ClickHousecurl "http://localhost:8123/?query=SELECT%201"Port Already in Use
Section titled “Port Already in Use”Change the ports in your environment:
# In .envTEST_SERVER_PORT=1325NATS Connection Issues
Section titled “NATS Connection Issues”Ensure JetStream is enabled:
nats -s nats://localhost:4222 stream lsNext Steps
Section titled “Next Steps”- Environment Variables - Full configuration reference
- Docker Setup - Containerized deployment