Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

2.1 KB
Raw Blame
# documentation: https://zero.rocicorp.dev/docs/deployment
# slogan: Query-driven sync engine for TypeScript apps backed by Postgres.
# category: backend
# tags: sync, realtime, postgres, typescript, local-first
# logo: svgs/zero.svg
# port: 4848

services:
  zero:
    image: rocicorp/zero:1.6.2
    # stop_grace_period: 10m
    environment:
      - SERVICE_URL_ZERO_4848
      - ZERO_UPSTREAM_DB=postgres://${SERVICE_USER_POSTGRES}:${SERVICE_PASSWORD_64_POSTGRES}@postgres:5432/${POSTGRES_DB}
      - ZERO_CVR_DB=postgres://${SERVICE_USER_POSTGRES}:${SERVICE_PASSWORD_64_POSTGRES}@postgres:5432/${POSTGRES_DB}
      - ZERO_CHANGE_DB=postgres://${SERVICE_USER_POSTGRES}:${SERVICE_PASSWORD_64_POSTGRES}@postgres:5432/${POSTGRES_DB}
      - ZERO_REPLICA_FILE=/data/replica.db
      - ZERO_ADMIN_PASSWORD=${SERVICE_PASSWORD_64_ADMIN}
      - ZERO_QUERY_URL=${ZERO_QUERY_URL:?Set the URL of your API /query endpoint}
      - ZERO_MUTATE_URL=${ZERO_MUTATE_URL:?Set the URL of your API /mutate endpoint}
      - ZERO_ENABLE_CRUD_MUTATIONS=${ZERO_ENABLE_CRUD_MUTATIONS:-false}
      - ZERO_NUM_SYNC_WORKERS=${ZERO_NUM_SYNC_WORKERS:-1}
      - ZERO_APP_ID=${ZERO_APP_ID:-zero}
      - ZERO_LOG_LEVEL=${ZERO_LOG_LEVEL:-info}
      - ZERO_ENABLE_TELEMETRY=${ZERO_ENABLE_TELEMETRY:-true}
      - ZERO_LAZY_STARTUP=${ZERO_LAZY_STARTUP:-false}
      - ZERO_QUERY_API_KEY=${ZERO_QUERY_API_KEY:-}
      - ZERO_MUTATE_API_KEY=${ZERO_MUTATE_API_KEY:-}
    volumes:
      - zero-data:/data
    healthcheck:
      test: ["CMD", "curl", "-f", "http://127.0.0.1:4848/keepalive"]
      interval: 5s
      timeout: 20s
      retries: 10
      start_period: 60s
    depends_on:
      postgres:
        condition: service_healthy

  postgres:
    image: postgres:18-alpine
    command: ["postgres", "-c", "wal_level=logical"]
    environment:
      - POSTGRES_USER=${SERVICE_USER_POSTGRES}
      - POSTGRES_PASSWORD=${SERVICE_PASSWORD_64_POSTGRES}
      - POSTGRES_DB=${POSTGRES_DB:-zero-db}
    volumes:
      - postgres-data:/var/lib/postgresql
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
      interval: 10s
      timeout: 20s
      retries: 10