Databases

Postgres and Valkey: containers, the server, or a managed service.

Zerodot needs two services:

  • Postgres 13 or newer. It keeps workflows, runs, users and credentials.
  • Valkey or Redis. It keeps the job queue.

This page tells where they can run, and what each place needs.

The script asks where each one runs. The menu shows only the choices that fit the server:

Choice Docker mode Native mode
Own container Always No
On this server When the script finds it When it runs
Install on this server No When there is none
Another server (a URL) Always Always

If you pick a URL, the script asks for it. With --yes, set DATABASE_URL or VALKEY_URL in place of the question.

Place Docker mode Native mode
Own containers Default No
Postgres and Valkey on the server --postgres host --valkey host Default
Another server or a managed service DATABASE_URL, VALKEY_URL DATABASE_URL, VALKEY_URL

Own containers (Docker mode)

This is the default of Docker mode. The install starts two containers:

  • postgres: Postgres 17. Data in the volume postgres-data.
  • valkey: Valkey 8, with appendonly yes. Data in the volume valkey-data.

The installer writes random passwords to .env: ZERODOT_DB_PASSWORD and ZERODOT_VALKEY_PASSWORD. Neither container publishes a port. Only the containers of the install can reach them.

Postgres reads ZERODOT_DB_PASSWORD only at the first start. A change later has no effect on the database. To change the password, see Change the database password.

max_connections of the container is 200. To change it, set ZERODOT_DB_MAX_CONNECTIONS in .env.

Postgres and Valkey on the server (Docker mode)

Docker mode can use the Postgres and Valkey that run on the server:

sudo bash install.sh zerodot.example.com --docker --postgres host --valkey host

You can use one and not the other. For example, --postgres host with the Valkey container.

The script makes changes to Postgres and Valkey, so that the containers can reach them. It asks first. For each change, the manual steps and the undo, see Postgres and Valkey on the server.

External or managed database

Set DATABASE_URL and VALKEY_URL before you run the script. Both modes use them as they are. The script does not make a database, and Docker mode does not start the containers.

sudo DATABASE_URL='postgres://zerodot:<password>@db.example.com:5432/zerodot?sslmode=require' \
  VALKEY_URL='rediss://default:<password>@cache.example.com:6379/0' \
  bash install.sh zerodot.example.com --docker

The script writes the values to .env. An update keeps them.

In Docker mode, the script tests the connection from a container before it starts the app.

If the URL points to localhost or 127.0.0.1, Docker mode changes the address to host.docker.internal. The containers reach the server at this address. Then the script treats the database as a database on the server.

Postgres URL

postgres://USER:PASSWORD@HOST:PORT/DATABASE?sslmode=require
  • A hosted Postgres (Amazon RDS, Neon, Supabase, others) usually needs ?sslmode=require.
  • Do not use a pooler in transaction mode. Example: the Supabase pooler on port 6543. Use the session pooler or a direct connection.
  • The user must own the database, or be able to make tables in it.

Valkey URL

redis://USER:PASSWORD@HOST:PORT/DB
rediss://USER:PASSWORD@HOST:PORT/DB
  • rediss:// uses TLS.
  • DB is the database number, 0 to 15.
  • Without a user, write redis://:PASSWORD@HOST:PORT/DB.

Special characters in passwords

Encode these characters in a password in a URL:

Character Write
@ %40
: %3A
/ %2F
# %23
? %3F
% %25

Example: the password p@ss:1 is p%40ss%3A1 in the URL.

The queue and eviction

The job queue needs maxmemory-policy noeviction. With another policy, Valkey can delete jobs when its memory is full. Then runs are lost.

  • A managed Redis or Valkey: set the policy to noeviction in the settings of the service.
  • Serverless Redis (for example Upstash) is a poor fit. It has request limits and can evict keys. Use a normal Valkey or Redis.
  • A Valkey or Redis on the server that evicts keys: the script asks before it sets noeviction. Other apps that use it as a cache then get errors when the memory is full. If you say no, use the Valkey container.
  • If the policy is not noeviction but maxmemory is 0, Valkey evicts nothing. The script only shows a warning. If somebody sets maxmemory later, jobs can be lost.

Connections

Each process of Zerodot opens a pool of connections to Postgres:

Process Connections
worker About ZERODOT_WORKER_CONCURRENCY + ZERODOT_SYSTEM_CONCURRENCY + 5. With the defaults: about 30.
web 10
api 10

One worker, web and api use about 50 connections. Add about 30 for each more worker. Other apps share max_connections of the database. With less than 150, the script shows a warning.

To limit the pool of a worker, set ZERODOT_DB_POOL_MAX in .env.

Native mode

Native mode uses Postgres and Valkey on the server.

Postgres

  • Postgres runs (13 or newer). The script makes a new user and a new database with the name of the instance (zerodot, or zerodot_staging for zerodot-staging). The password is random. Other databases are not touched.
  • No Postgres. The script installs the Postgres package of the system and starts it.
  • Postgres is installed but stopped. The script stops. It does not start Postgres. Start it, or set DATABASE_URL.
  • Postgres is older than 13. The script stops. Use Docker mode, or set DATABASE_URL.
  • A user with the name of the instance exists. The script stops. Pick another --name, or set DATABASE_URL.

The script needs to log in as the postgres system user (runuser -u postgres -- psql).

On Fedora and RHEL, pg_hba.conf uses ident for 127.0.0.1. A password login then fails. The script adds two lines for the Zerodot user and database only, before the other rules:

host zerodot zerodot 127.0.0.1/32 scram-sha-256
host zerodot zerodot ::1/128 scram-sha-256

When the script installs Postgres on Fedora, RHEL or Arch, it makes a new data folder. The new folder uses peer for local logins and scram-sha-256 for TCP logins.

Valkey

  • Valkey or Redis runs on port 6379. The script uses the first empty database number from 1 to 15. Other apps keep database 0.

  • No Valkey or Redis. The script installs Valkey (or Redis, if the system has no Valkey). It adds these lines to the new config file:

    maxmemory-policy noeviction
    appendonly yes
    bind 127.0.0.1 -::1
    
  • Valkey is installed but stopped. The script stops. It does not start Valkey. Start it, or set VALKEY_URL.

  • Valkey needs a password. The script stops. Set VALKEY_URL=redis://:PASSWORD@127.0.0.1:6379/N.

Use your own database in native mode

sudo DATABASE_URL='postgres://zerodot:<password>@127.0.0.1:5432/zerodot' \
  VALKEY_URL='redis://127.0.0.1:6379/1' \
  bash install.sh zerodot.example.com --native

Back up and move

See Back up and move.

Change this page on GitHub