Skip to content

Installation and configuration ​

Requirements ​

ComponentVersionNotes
PostgreSQL15 or newer (17 recommended)Needs the pgcrypto extension (part of standard PostgreSQL)
Node.js20 or newer.nvmrc pins the version used in development
Docker (optional)any recentFor the bundled development database

pgkiln does not need any other services; there is no separate web listener (like ORDS for APEX). For REST APIs you can run PostgREST next to it (chapter 13).

Hardware ​

pgkiln itself is light: one Node.js process and PostgreSQL. What a server needs depends mostly on your own data and queries.

CPUMemoryDisk
Trying it out, a small team1 core1 GB5 GB
Production, up to a few hundred users2 cores2–4 GB20 GB SSD, plus your data
Largermore instances behind a load balancer (Scaling), PostgreSQL on its own serversized by your data

Memory and disk on the smallest server leave room for the operating system; with Docker the images take about 1.3 GB (pgkiln 570 MB, postgres:17 with pg_cron 750 MB).

What we measured (October 2026, with the HR example, the Docker compose stack, on a desktop CPU; simulated users who sign in and request pages back to back, without pausing between clicks):

Idle5 users20 users50 users
Pages per second–212247242
Time per page (median / 99th percentile)–24 / 39 ms84 / 116 ms214 / 282 ms
pgkiln memory140 MB390 MB440 MB610 MB
PostgreSQL memory85 MB155 MB160 MB165 MB
pgkiln CPU~01.1 cores1.1 cores1.2 cores
  • One pgkiln process uses about one CPU core at most and served about 240 pages per second here. People pause between clicks, so that is far more than a team working normally generates; a smaller or shared CPU (a typical cloud server) is slower, so measure with your own pages.
  • The database of the example is under 50 MB (pgkiln's own meta schema about 6 MB); sessions, the activity log and uploaded files grow with use. Back up and size the disk for your own tables.
  • Each pgkiln instance opens up to 30 database connections with the default pool settings.

Quick start (development) ​

bash
git clone https://github.com/pgkiln/pgkiln.git
cd pgkiln
npm install
cp .env.example .env
npm run setup        # starts PostgreSQL 17 in Docker on port 5434 and installs pgkiln (the migrations)
npm run dev          # starts pgkiln on http://127.0.0.1:3100 and restarts on code changes

Open the builder at http://127.0.0.1:3100/builder, sign in as admin / admin (change the password on the Developers page straight away) and create your first application from a table (Create application), or follow the tutorial.

The example application (optional) ​

pgkiln comes with an example application, HR: employees, departments, leave requests with an approval task, a dashboard, a REST API, translations, documents and more, built the way you would build your own (examples/hr/). It is not part of pgkiln; install it to see the features at work:

bash
npm run example:hr   # http://127.0.0.1:3100/a/hr: king, blake, allen or demo (password = username)

The tests use it as their fixture: npm test and npm run test:e2e install it first.

Using your own PostgreSQL instead of Docker ​

  1. Create a database and an owner login (a superuser is simplest for development):
    sql
    create role pgkiln login password 'choose-a-password' superuser;
    create database pgkiln owner pgkiln;
  2. Point DATABASE_URL in .env at it, then run npm run db:migrate (and npm run example:hr for the example application).
  3. Set RUNTIME_DATABASE_URL for the pgkiln_runtime role that the first migration creates (see below).

(sprint 232) Installing pgkiln needs a superuser: two of its first migrations (166, 167) set the attributes of the workspaces' login roles in a way PostgreSQL only allows a superuser. Upgrades don't: once installed, the owner is better a role with CREATEROLE that owns the database and isn't a superuser. pgkiln admin demote-owner makes it one (below); npm run db:migrate as a role that isn't a superuser says so before it changes anything.

Installing into an existing database ​

pgkiln can live next to your own schemas: it adds the schema meta, three bookkeeping tables in public (pgkiln_migration, pgkiln_seed, pgkiln_install_log) and the login roles pgkiln_runtime, pgkiln_authenticator and pgkiln_anon (roles belong to the whole server). It changes nothing else. When the pgkiln owner is not the database's owner, a database administrator grants, once:

sql
create role pgkiln login createrole password 'choose-a-password';
grant connect, create on database shop to pgkiln;
grant create on schema public to pgkiln;   -- since PostgreSQL 15 only the database owner may by default

Applications run as a role of their own, which the builder grants rights on its parsing schema. For a schema the pgkiln owner doesn't own, its owner passes those rights on first:

sql
-- as the owner of the schema sales
grant usage on schema sales to pgkiln with grant option;
grant select, insert, update, delete on all tables in schema sales to pgkiln with grant option;
grant usage, select on all sequences in schema sales to pgkiln with grant option;

(or the administrator grants them to the application's role, app_<alias>, directly).

The two database connections ​

pgkiln deliberately uses two database logins:

ConnectionSettingRoleUsed for
OwnerDATABASE_URLthe owner of the meta schema (e.g. pgkiln)migrations, the builder; an administrator's audited Owner connection in the SQL Workshop
RuntimeRUNTIME_DATABASE_URLpgkiln_runtime (created by migration 001)running applications
Developer logins(none: derived from PGKILN_SECRET_KEY)pgkiln_ws<id>_dev_<suffix>, one per workspace (migration 166)the SQL Workshop and the tools that check a developer's SQL

(sprint 185) The SQL Workshop doesn't run as the owner: each workspace has a developer login with the rights of its applications' roles and schemas and none on meta's tables (chapter 3, Who the SQL Workshop runs as; sprint 201). pgkiln sets its password when it first opens a connection, derived from PGKILN_SECRET_KEY; without that key a single server process uses a password of its own (several processes need the key, or they change each other's password). The login connects to the database and host of RUNTIME_DATABASE_URL, so pg_hba.conf must let it sign in with a password there, like the runtime role.

The runtime role is least privilege. It can read application definitions and manage sessions, but it cannot read developer accounts, password hashes or instance secrets. It is NOINHERIT, so it reaches application data only by switching to an application's own database role (SET LOCAL ROLE) for the duration of a request. If RUNTIME_DATABASE_URL is missing, pgkiln falls back to the owner connection and prints a warning; don't run like that in production.

A non-superuser owner ​

(sprint 185) Instance settings → Lockout checks (and pgkiln admin check) warn when DATABASE_URL signs in as a superuser: then migrations, the builder and an administrator's Owner connection could also read files on the server, run programs and change every database of the PostgreSQL server. (sprint 232) The Docker setup doesn't run like that since 0.112.0 (Docker); on a server of your own, pgkiln admin demote-owner makes the owner a role without it. Stop pgkiln, then, with DATABASE_URL set to the owner pgkiln should use (a new role, e.g. pgkiln_owner, with its password; or the current owner when it isn't the server's bootstrap superuser) and SUPERUSER_DATABASE_URL to a superuser of the same server (its database part is ignored: the command works in DATABASE_URL's database):

bash
export DATABASE_URL=postgres://pgkiln_owner:a-long-random-password@db-server:5432/pgkiln
export SUPERUSER_DATABASE_URL=postgres://postgres:…@db-server:5432/pgkiln
pgkiln admin demote-owner --dry-run   # the statements, nothing changed
pgkiln admin demote-owner

In one transaction it

  • creates the role (LOGIN CREATEROLE, the password of DATABASE_URL), or takes SUPERUSER (and BYPASSRLS, REPLICATION) from it, and makes it own the database;
  • moves every object of the old owner (the owner of schema meta) in this database to it: schemas, tables, views, sequences, functions, types, foreign servers, large objects, one by one (REASSIGN OWNED can't move the objects of the bootstrap superuser, which also owns the system catalogs). Event triggers stay a superuser's;
  • repeats the old owner's default privileges (ALTER DEFAULT PRIVILEGES, the application schemas' grants for tables made later) for the new one;
  • (PostgreSQL 16 and later) gives it ADMIN OPTION on pgkiln's roles (pgkiln_runtime, pgkiln_app_code, pgkiln_authenticator, pgkiln_anon, the workspaces' logins, the applications' roles, the masking roles): a CREATEROLE role may only change, grant and set the password of roles it has that on. Memberships in those roles another role granted are granted again by the owner, so it can revoke them later; and createrole_self_grant = 'set, inherit' lets it switch to the roles it creates and gives it their privileges (REASSIGN OWNED and DROP OWNED, as Database Users' Drop runs, need them), as a superuser had;
  • moves pg_cron jobs that ran as the old owner to it, creates pg_cron when the server loads it for this database, grants usage on schema cron, pg_read_all_stats, pg_signal_backend and execute on pg_stat_statements_reset (Scheduling, Top SQL, Sessions), and creates the extensions in PGKILN_EXTENSIONS;
  • takes SUPERUSER and LOGIN from the old owner, unless it is the server's bootstrap superuser or SUPERUSER_DATABASE_URL's own role.

Before it commits, it checks that the owner can sign in, isn't a superuser, can create roles, owns the database, meta and its tables, and has ADMIN OPTION on pgkiln's roles; otherwise it rolls back and says what is wrong (nothing changed). Afterwards it signs in as DATABASE_URL. Running it again changes nothing. Then start pgkiln with the new DATABASE_URL, and keep SUPERUSER_DATABASE_URL out of its settings. Drop the old role once nothing needs it (drop owned by pgkiln; drop role pgkiln;).

Without the ADMIN OPTION grants (PostgreSQL 16 and later) the server can't set the workspace logins' passwords, so the SQL Workshop doesn't connect ("permission denied to alter role"), and a new application's role can't be given to the logins.

The owner needs CREATEROLE (application roles, workspace logins), ADMIN OPTION on those roles, and to own the database. It must be the owner of the meta schema and its tables itself, not a member of that role: row level security on pgkiln's tables lets the tables' owner see every workspace's rows, a member only some. A few things then need a superuser once (the Change Log's event triggers, create extension of an untrusted extension): pgkiln shows the statements to run. Splitting the owner into a migration role and a builder role that can't create roles is not done yet: DATABASE_URL is still used for both. Whichever role it is, the SQL Workshop never runs as it unless an administrator chooses the audited Owner connection: a developer who isn't an administrator is refused by the server (403), not only by the form.

The migration creates pgkiln_runtime with the password pgkiln_runtime. Change it:

sql
alter role pgkiln_runtime password 'a-long-random-password';

Configuration reference ​

All settings are environment variables. They can also be placed in .env in the project root, which is read at startup; real environment variables take precedence.

VariableDefaultMeaning
DATABASE_URLpostgres://pgkiln:pgkiln@localhost:5434/pgkilnOwner connection (builder, migrations; not the SQL Workshop since sprint 185: see above). Not a superuser, ideally (a non-superuser owner)
SUPERUSER_DATABASE_URL(none)(0.112) A superuser of the same server, for the Docker start and pgkiln admin demote-owner only (never the server): it makes DATABASE_URL's role the owner without SUPERUSER. Its database part is ignored
PGKILN_EXTENSIONS(none)(0.112) Extensions the Docker start (or demote-owner) creates as the superuser, comma-separated, e.g. postgres_fdw for Remote databases; the owner can't create untrusted ones
RUNTIME_DATABASE_URL(falls back to DATABASE_URL)Least-privilege connection that runs applications
PORT3100HTTP port
HOST127.0.0.1Interface to listen on; use 0.0.0.0 in a container
PUBLIC_URLhttp://127.0.0.1:<PORT>The address users reach pgkiln at (e.g. https://apps.example.com). Single sign-on redirect URIs are built from it, and developers' passkeys belong to its host name. (sprint 250) The server records it at start-up for absolute links built in SQL (meta.page_url(…, p_absolute => true), meta.app_url(): links in mail)
MAIL_REDIRECT_TO(none)(sprint 250) One e-mail address: every mail of the installation goes only there, with [TEST] before the subject and the original recipients in X-Original-To/-Cc/-Bcc and at the top of the body. Wins over an application's Redirect all mail to; for test and acceptance servers (redirect all mail). A value that is not one address stops all mail
PGKILN_RP_IDthe host of PUBLIC_URL(0.61) A parent domain for developers' passkeys (example.com when the builder is at builder.example.com), so one passkey works on its sub-domains. Ignored unless it is the host or a parent of it
API_URLhttp://127.0.0.1:3000Where PostgREST serves the REST API (chapter 13)
API_JWT_SECRET(none)Signs REST API tokens; at least 32 characters, the same as PostgREST's jwt-secret. Without it, tokens can't be issued
COOKIE_SECUREfalsetrue behind HTTPS: marks cookies Secure and sends HSTS
TRUST_PROXYfalseBehind a reverse proxy, so client IPs (used by login throttling) come from X-Forwarded-For: true for one proxy, a number for several in a row (e.g. a CDN in front of nginx: 2), or the proxies' addresses or subnets (10.0.0.0/8,192.168.1.10). Only the entries those proxies added are believed, never the ones a client sends along
PGKILN_AUTH_HEADER_PROXIES(none)Comma-separated IPs and CIDRs (e.g. 10.0.0.5, 192.168.10.0/24) of the reverse proxies whose user header apps with HTTP header authentication trust; checked against the connection's own address, never X-Forwarded-For. Unset: header sign-in is refused (chapter 8)
SESSION_IDLE_MINUTES60A session ends after this long without requests. This and the next four can also be set in the builder (Workspace utilities → Instance settings), which wins over the variable
SESSION_MAX_HOURS8A session ends this long after sign-in, whatever the activity
LOGIN_WINDOW_MINUTES15Window for counting failed sign-ins
LOGIN_MAX_FAILURES_PER_USER5Failed sign-ins per username (since their last success) before a lock
LOGIN_MAX_FAILURES_PER_IP50Failed sign-ins per IP address before a lock
STATEMENT_TIMEOUT30sMaximum run time of any application SQL statement
DB_POOL_SIZE10Connections per pool (there are two pools)
DB_NESTED_POOL_SIZE5Connections per pool for queries a request makes while it holds a connection of that pool (opened only when needed)
DB_ACQUIRE_TIMEOUT_MS30000How long a request waits for a free connection before it fails with an error
DB_IDLE_IN_TRANSACTION_MS300000The database ends a transaction left idle this long (milliseconds), so a hung request frees its connection
MAX_UPLOAD_MB10Largest file a file item accepts (an item's max_mb can only lower it)
PGKILN_PG_BIN(searched)(sprint 103) The directory of pg_dump and pg_restore for Schema Export / Import (the server's major version or newer)
PGKILN_DUMP_DIR<temp>/pgkiln-dumpsWhere Schema Export / Import keeps its files (the Docker image: /app/dumps, a volume)
PGKILN_DUMP_KEEP_DAYS7Days an export or upload is kept
PGKILN_DUMP_MAX_MB2048Largest dump an administrator uploads
DATA_LOAD_MAX_MB50Largest file for SQL Workshop → Load Data and Create → From a file
DATA_LOAD_MAX_ROWS100000Most rows loaded from one file
PDF_MAX_ROWS5000Most rows in a report PDF (1 to 100,000; read with a cursor in batches)
DOWNLOAD_MAX_ROWS1000000Most rows in a report's CSV or Excel download and in a SQL Workshop → Unload Data file (streamed; at most 1,048,575)
SAMPLE_DATA_STATEMENT_TIMEOUT5minStatement timeout of SQL Workshop → Sample Data (each insert of a preview or a run)
SAMPLE_DATA_MAX_ROWS100000Most rows one Sample Data run generates (all tables together)
UNLOAD_STATEMENT_TIMEOUT5minStatement timeout of SQL Workshop → Unload Data (each statement: the cursor and every batch of rows)
WORKSHEET_TXN_IDLE_SECONDS300SQL Worksheet transaction mode: seconds without a run before an open transaction is rolled back (10 to 86400)
WORKSHEET_TXN_MAX_PER_DEVELOPER3Open worksheet transactions per developer (each holds a database connection)
WORKSHEET_TXN_MAX20Open worksheet transactions on the server
REGION_CACHE_MAX_ENTRIES1000Most regions in the region cache of one server process (0 turns caching off)
REGION_CACHE_MAX_MB64Memory for the region cache of one server process
AUTOMATIONSonoff stops this server from running automations
SCHEDULER_INTERVAL_S30How often the automation scheduler looks for due runs
BACKGROUND_PROCESSESonoff stops this server from running background execution chains (another server runs them)
PROCESS_JOB_INTERVAL_S10How often a server looks for queued background chains (besides being woken by NOTIFY)
QUEUE_RETRY_S30(sprint 177) The wait before the second attempt of a queued web request, its callback or a webhook event; it doubles with each attempt
QUEUE_RETRY_MAX_S3600The longest wait between two attempts (also the most a Retry-After header is honoured)
WEBHOOKSonoff stops this server from processing webhook events (it still receives them; another server processes them). Queued web requests follow AUTOMATIONS
GEOCODER_URL, GEOCODER_KEY(none)A Nominatim-compatible search API for geocoded address items, e.g. your own Nominatim; GEOCODER_KEY is sent as key (LocationIQ). Without it address items are plain text items
PDF_FONT, PDF_FONT_BOLD(none)TrueType fonts for report PDFs, for text beyond Western European (e.g. DejaVuSans.ttf)
ANTHROPIC_API_KEY(none)Default API key of AI services with the provider Claude that have no key of their own
OPENAI_API_KEY(none)Default API key of AI services with the provider OpenAI that have no key of their own
GEMINI_API_KEY(none)(sprint 111) Default API key of AI services with the provider Gemini that have no key of their own
OPENAI_COMPATIBLE_API_KEY(none)(sprint 111) Default API key of OpenAI-compatible AI services (Ollama, vLLM, Azure OpenAI) that have no key of their own; without either, no key is sent (none)
PGKILN_SECRET_KEY(none)Encrypts the secrets of web credentials and the API keys of AI services; at least 32 characters (e.g. openssl rand -base64 32). Keep it outside the database; change it with pgkiln admin rotate-key (chapter 3), otherwise the secrets must be entered again
PGKILN_OLD_SECRET_KEY(none)(0.67) Only for pgkiln admin rotate-key: the key the secrets are stored with now
PGKILN_REST_ALLOWED_HOSTS(none: no outgoing calls)Hosts REST data sources and invoke_api may call: api.example.com, *.example.com, host:8443, * (any public host) (chapter 19); a workspace's network access list can narrow it, and the SMTP server of a workspace's own mail service must be on it
PGKILN_REST_PRIVATE_HOSTS(none)Hosts that may resolve to private, loopback or link-local addresses (also allows them)
PGKILN_SERVER_<NAME>(none)(sprint 141) The base URL of a remote server that names this variable, e.g. PGKILN_SERVER_CRM=https://crm.example.com: it wins over the URL stored with the server, so each environment (development, test, production) sets its own. Only names starting PGKILN_SERVER_ can be used
PGKILN_PUSH_HOSTSthe browsers' push servicesThe hosts push notifications may be posted to: fcm.googleapis.com,updates.push.services.mozilla.com,web.push.apple.com,*.notify.windows.com when unset (chapter 17)
PGKILN_PUSH_SUBJECTPUBLIC_URL when it is httpsThe contact the push services see (mailto:ops@example.com or an https URL); Apple refuses notifications without one
PGKILN_PUSH_PRIVATE_HOSTS(none)For tests only: a push service on a private or loopback address, also over plain http
PGKILN_REST_MAX_BYTES5000000Largest web service response read (also after decompression)
PGKILN_REST_MAX_UPLOAD_BYTES26214400(sprint 243) Largest binary body meta.web_request(..., p_body_blob) sends, 25 MB (chapter 9)
MIGRATE_ON_STARTfalsetrue applies missing migrations when the server starts. Without it, a server whose database lacks migrations answers every request with 503 and names the missing files until they are applied (npm run db:migrate or pgkiln migrate; no restart needed)
LOG_LEVELinfofatal, error, warn, info, debug, trace
PGKILN_RELEASE_CHECKoffon: the server asks GitHub once a day for a newer pgkiln release and the Workspace home announces it. Administrators can also set it in the builder (Instance settings → New versions), which wins over the variable. Keep it off where the server may not reach the internet
PGKILN_RELEASE_URLGitHub's releases APIFor tests and mirrors only: the address of a JSON document like GitHub's releases/latest
OTEL_EXPORTER_OTLP_ENDPOINT(none)(0.72) The OpenTelemetry Collector's OTLP/HTTP address (e.g. http://otel-collector:4318): pgkiln sends traces, logs and metrics there. Workspace utilities → OpenTelemetry wins over it and over the other OTEL_* variables below
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, …_LOGS_ENDPOINT, …_METRICS_ENDPOINTthe endpoint + /v1/traces …A full URL per signal (only when the builder sets no collector URL)
OTEL_EXPORTER_OTLP_HEADERS(none)Headers sent to the collector, name=value,name2=value2 (an API key)
OTEL_SERVICE_NAME, OTEL_RESOURCE_ATTRIBUTESpgkiln, (none)The service.name and other resource attributes (deployment.environment=prod)
OTEL_TRACES_SAMPLER, OTEL_TRACES_SAMPLER_ARGalways ontraceidratio with a ratio from 0 to 1 sends that share of traces; a trace with an error is always sent
OTEL_TRACES_EXPORTER, OTEL_LOGS_EXPORTER, OTEL_METRICS_EXPORTERotlpnone leaves that signal out
OTEL_METRIC_EXPORT_INTERVAL60000Milliseconds between metric exports (5 s to 1 h)
OTEL_SDK_DISABLEDfalsetrue turns the instance's export off, whatever the builder says
PGKILN_METRICS, PGKILN_METRICS_TOKENoff, (none)on opens GET /metrics (Prometheus) for administrators and for scrapers that send Authorization: Bearer <PGKILN_METRICS_TOKEN>

npm scripts ​

ScriptWhat it does
npm run devStart with auto-restart on changes
npm startStart (production)
npm run setupStart the Docker database and apply the migrations
npm run db:upStart the Docker database
npm run db:migrateApply pending migrations (db/migrations/*.sql)
npm run example:hrApply migrations, then install the HR example application (examples/hr/*.sql)
npm run db:resetDelete the Docker database and set it up again
npm run typecheckTypeScript type check
npm testUnit and security tests (need the database; install the HR example first, as their fixture)
npm run test:e2eBrowser tests at phone, tablet and desktop widths (run npx playwright install chromium once)

Docker ​

The quickest way to run pgkiln: the image pgkiln/pgkiln (also ghcr.io/pgkiln/pgkiln, for amd64 and arm64) and a compose file with PostgreSQL 17. Docker is all you need; no checkout of the source. (sprint 213) The bundled PostgreSQL has pg_cron: the compose file builds it from the official postgres:17 image plus the postgresql-17-cron package on the first up (a minute, once), and pgkiln creates the extension at start-up, so SQL Workshop → Scheduling works right away:

bash
mkdir pgkiln && cd pgkiln
curl -fsSLO https://raw.githubusercontent.com/pgkiln/pgkiln/main/deploy/compose.yaml
curl -fsSL -o .env https://raw.githubusercontent.com/pgkiln/pgkiln/main/deploy/.env.example
# fill in POSTGRES_PASSWORD, OWNER_PASSWORD, RUNTIME_PASSWORD, PGKILN_SECRET_KEY (e.g. `openssl rand -hex 24` each)
# and PGKILN_ADMIN_PASSWORD (12+ characters) in .env
docker compose up -d

From a checkout of the source, cd deploy && cp .env.example .env, then docker compose up -d --build builds the image from your copy instead.

Open http://127.0.0.1:3100/builder and sign in as admin with PGKILN_ADMIN_PASSWORD.

Three database roles (sprint 232, 0.112.0): the bundled database's superuser postgres (POSTGRES_PASSWORD), which only the start signs in as; pgkiln_owner (OWNER_PASSWORD), which owns pgkiln's database, runs the migrations and the builder, and is not a superuser; and pgkiln_runtime (RUNTIME_PASSWORD), which runs the applications. The start makes pgkiln_owner and keeps it as it should be (a non-superuser owner: it is a superuser only while it installs pgkiln, which needs one), creates pg_cron and the extensions of PGKILN_EXTENSIONS, then starts the server without the superuser's URL and password (scripts/docker-entrypoint.sh): not even a program the server runs (pg_dump for Schema Export) gets them. On your own server, set SUPERUSER_DATABASE_URL for the same, or leave it out when an administrator has made the owner already.

What happens at each start (scripts/docker-start.ts): the container checks the settings and lists everything missing at once (it doesn't start on empty or too short secrets), waits for the database, makes the owner (see above), applies new migrations as it (with a lock, so several containers migrate once), and replaces the builder's admin / admin with PGKILN_ADMIN_PASSWORD (a password changed later in the builder is kept). pgkiln_runtime gets the password in RUNTIME_DATABASE_URL unless it already signs in with it; pgkiln_authenticator (PostgREST) gets PGKILN_AUTHENTICATOR_PASSWORD, or else a random one while it has its well-known default. Roles the start creates get their passwords straight away. PostgreSQL roles belong to the whole server, not to one database: other pgkiln databases on the same server share them, and with them these passwords. When the server doesn't check passwords for the container's connection (trust in pg_hba.conf), the start can't tell whether an older role has the password you configured. The same holds when the check fails for another reason, such as a network error. The start then leaves that password alone (other databases may use it), says so in the log, and you set it yourself. Without PGKILN_AUTHENTICATOR_PASSWORD, checking the authenticator's default costs one failed sign-in in the server log per start; setting it avoids that. GET /healthz answers ok when the database is reachable; the image's health check uses it.

POSTGRES_PASSWORD counts at the first start only: the bundled database keeps it in the volume pgdata. To change it later, change it in the database first (docker compose exec db psql -U postgres -d pgkiln -c "\password postgres"; -U pgkiln and \password pgkiln for a volume made by 0.111.0 or older), then in .env. A wrong password stops the container at once with a message saying so. OWNER_PASSWORD can change any time: the start sets it.

Settings go in deploy/.env: the ones in .env.example, and any other setting of the configuration reference.

SettingDefaultMeaning
COMPOSE_PROFILESdbdb: the bundled PostgreSQL (its data is in the volume pgdata). Remove it to use your own server; add https for Caddy
DATABASE_URL, RUNTIME_DATABASE_URLthe bundled databaseYour own PostgreSQL (existing database); a server on the Docker host itself is host.docker.internal
PGKILN_PORT, PGKILN_BIND3100, 127.0.0.1Only this machine can connect by default; PGKILN_BIND=0.0.0.0 opens plain HTTP to the network
PGKILN_DOMAINWith the https profile: Caddy gets a certificate for this name (its DNS must point at the machine, ports 80 and 443 open). Set PUBLIC_URL=https://…, COOKIE_SECURE=true and TRUST_PROXY=true with it. Installing apps on phones and push notifications need HTTPS
PGKILN_EXAMPLEhr installs the HR example (its demo users have weak passwords: not on a public server)
PGKILN_IMAGEpgkiln/pgkiln:latestThe image to run, e.g. a fixed version (pgkiln/pgkiln:0.31.0) or ghcr.io/pgkiln/pgkiln
OWNER_PASSWORD(0.112) The password of pgkiln_owner, pgkiln's database owner without SUPERUSER; required with the bundled database
POSTGRES_SUPERUSERpostgres(0.112) The bundled database's superuser. A volume made by pgkiln 0.111.0 or older has pgkiln (the start tries that one when postgres doesn't exist; setting it skips the try)
SUPERUSER_DATABASE_URLthe bundled database's superuserYour own server's superuser, for the start only (a non-superuser owner)
PGKILN_EXTENSIONSExtensions the start creates as the superuser, e.g. postgres_fdw (Remote databases)
PGKILN_CRON_TIMEZONEUTCThe bundled database's cron.timezone: the time zone of pg_cron's schedules (e.g. Europe/Amsterdam)

Upgrading from 0.111.0 or older (sprint 232): in those versions the bundled database's superuser pgkiln was also pgkiln's owner. Back up first (docker compose exec db pg_dump -U pgkiln pgkiln > backup.sql), take the current deploy/compose.yaml, add OWNER_PASSWORD (a new secret, openssl rand -hex 24) to .env, and docker compose up -d: the start signs in as pgkiln with POSTGRES_PASSWORD (the superuser it finds there), makes pgkiln_owner, moves pgkiln's schemas, tables, functions and pg_cron jobs to it in one transaction, and from then on pgkiln runs as pgkiln_owner; pgkiln stays the database's superuser (the server's first role can't lose that). The log lists what it did, and Instance settings → Lockout checks no longer warns "DATABASE_URL is a superuser". With the old compose.yaml pgkiln keeps running as before, with that warning.

Upgrading: with the published image: docker compose pull, then docker compose up -d (with a fixed version in PGKILN_IMAGE, change it first); up -d replaces the container when the image changed, so --force-recreate isn't needed. Built from a checkout: git pull, then docker compose up -d --build. The new container migrates the database before it starts serving. A compose.yaml from pgkiln 0.51.0 or older has pull_policy: missing under pgkiln, which makes docker compose pull skip an image that is already present: delete that line (or take the current deploy/compose.yaml) before the first upgrade this way. A compose.yaml from before 0.106.0 runs plain postgres:17, without pg_cron: take the current one to get it (same PostgreSQL major version and data volume; docker compose up -d builds the database image and restarts the database). The database image is built, not pulled: docker compose pull skips it, and docker compose build --pull db takes a newer PostgreSQL 17 minor release. Back up first (docker compose exec db pg_dump -U postgres pgkiln > backup.sql; -U pgkiln for a volume made by 0.111.0 or older). Keep PGKILN_SECRET_KEY: without it, stored secrets (web credentials, AI keys, push keys, authenticator apps) can't be decrypted. Keep a copy outside the server and confirm it on Instance settings; to change it, use pgkiln admin rotate-key (chapter 3).

Upgrading ​

Every schema change ships as a new, numbered file in db/migrations/. The runner records applied files in public.pgkiln_migration and applies only new ones, each in its own transaction:

bash
git pull
npm ci
npm run db:migrate
# restart the server

Back up the database before upgrading. Released migrations are never modified.

Each run that applies a file (or fails) is recorded in public.pgkiln_install_log; administrators see it, with the applied migrations and any the database still misses, under Builder → Workspace utilities → Installation.

Production deployment ​

A typical setup: pgkiln runs as a service behind a reverse proxy that terminates HTTPS.

Browser ──HTTPS──> nginx / Caddy / Traefik ──HTTP──> pgkiln (node) ──> PostgreSQL
  1. Database
    • Use a dedicated owner role (it doesn't need to be a superuser once migrations have run, but it must own the meta schema and be allowed to create roles if developers create apps in the builder).
    • Set a strong password for pgkiln_runtime.
    • Enable regular backups (pg_dump or your provider's snapshots). Everything, including application definitions, lives in the database.
  2. Environment
    bash
    NODE_ENV=production
    HOST=0.0.0.0
    PORT=3100
    DATABASE_URL=postgres://pgkiln_owner:...@db:5432/pgkiln
    RUNTIME_DATABASE_URL=postgres://pgkiln_runtime:...@db:5432/pgkiln
    COOKIE_SECURE=true
    TRUST_PROXY=true
    PUBLIC_URL=https://apps.example.com
    # only with a REST API (PostgREST):
    API_URL=https://api.example.com
    API_JWT_SECRET=<48+ random characters, same as PostgREST's jwt-secret>
  3. Process manager. Run npm start under systemd, a container orchestrator or pm2. Example systemd unit:
    ini
    [Service]
    WorkingDirectory=/opt/pgkiln
    EnvironmentFile=/opt/pgkiln/.env
    ExecStart=/usr/bin/npm start
    Restart=always
    User=pgkiln
  4. Reverse proxy (nginx example):
    nginx
    location / {
      proxy_pass http://127.0.0.1:3100;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
    }
  5. Restrict the builder. /builder is for developers. Consider allowing it only from your office network or VPN at the proxy (for example an nginx location /builder { allow …; deny all; }).
  6. Change default passwords: admin in the builder (Developers page), and the demo users if the sample is installed. (NX-S3) With a public PUBLIC_URL the server refuses to start while a developer still has a default password (admin, or the user name): pgkiln users password admin --developer sets a new one. Don't install the example application in production: npm run db:migrate installs pgkiln only.
  7. Walk through the checklist at the end of SECURITY.md.

Scaling ​

pgkiln keeps no state in memory between requests (sessions live in meta.session), so you can run several instances behind a load balancer. Each instance opens up to 2 × (DB_POOL_SIZE + DB_NESTED_POOL_SIZE) database connections (30 with the defaults); keep the sum of all instances below PostgreSQL's max_connections (100 by default).

Monitoring with OpenTelemetry ​

(0.72; APEX: Workspace Utilities → OpenTelemetry) pgkiln sends traces, logs and metrics to your own monitoring over OTLP, the OpenTelemetry protocol: Grafana (Tempo, Loki, Mimir), Jaeger, Datadog, Honeycomb, New Relic, Elastic, OCI APM and the rest, normally through an OpenTelemetry Collector. It sends OTLP over HTTP as JSON (http/json), which every Collector accepts on port 4318. No agent and no extra package are needed, and nothing runs while no collector is set.

Administrators set it up in Workspace utilities → OpenTelemetry (/builder/telemetry), or with the standard OTEL_* variables of the configuration reference (a value set in the builder wins):

  • Collector URL: the OTLP/HTTP base address; /v1/traces, /v1/logs and /v1/metrics are added. Headers (an API key) are stored encrypted with PGKILN_SECRET_KEY (rotated by pgkiln admin rotate-key) and never shown again, only their names. Send a test span sends one span and shows what the collector answered; Status shows what each server process sent, dropped, and the last problem.
  • What is traced. Every application request is a trace: a server span GET /a/:alias/:page with the application, page, HTTP status, route and the user (see below), and a child span for each SQL statement (db.query.text, rows, SQLSTATE on errors; transaction control left out), each outgoing web call (REST data sources, invoke_api, meta.web_request, web credential token requests: HTTP GET with the host, path and status; a 4xx/5xx answer is an error span), each AI request (gen_ai.*: provider, model, input and output tokens) and each AI tool call of an assistant or agent. A W3C traceparent header goes along with every outgoing web call, so the called service joins the same trace, and an incoming traceparent (from a proxy or another service) is continued. Background work has traces of its own: each mail sending attempt and each workflow step (with the invoke_api call inside it). Trace builder requests too adds /builder requests (to the instance's collector only).
  • Sample ratio: the share of traces sent (0 to 1). pgkiln keeps a trace's spans until it ends, so a trace with an error (an HTTP 5xx, a failing statement, a REST call answered with 500) is always sent.
  • Values stay out unless Include values is on: SQL statements are sent with their literals replaced by ? (where ename = ?), bind values, the query string, the full URL of outgoing calls and AI tool arguments are left out, and quoted values, Key (col)=(value), e-mail addresses and long numbers are removed from error messages. With Include values, statements go as run, with db.query.parameter.N.
  • User: Hashed (the default) sends enduser.id as a keyed hash (the same user always gives the same value, the name is not sent), User name sends the name, Not sent leaves it out.
  • Logs: errors (also unhandled server errors), refused access and failed or locked sign-ins, as log records tied to the request's trace, with the application and page.
  • Metrics, every 60 seconds (OTEL_METRIC_EXPORT_INTERVAL): pgkiln.http.server.duration (a histogram in milliseconds per application, method and status class), pgkiln.errors, pgkiln.access_denied, pgkiln.signin_failures, pgkiln.ai.requests, pgkiln.ai.tokens (per provider, model, input/output), pgkiln.mail.sent, and the levels pgkiln.mail.queue, pgkiln.jobs.queue, pgkiln.workflows, pgkiln.ai.requests.pending, pgkiln.embeddings.queue, pgkiln.db.pool.connections, process.memory.rss, process.uptime; pgkiln.telemetry.dropped counts what could not be sent.
  • Browser spans (optional): a page whose trace is sent carries a signed <meta name="pgkiln-trace">, and app.js reports the page's load timings and its Ajax calls to POST /a/<alias>/telemetry; pgkiln adds them to the page's trace (browser page load, browser POST). The browser never sees the collector or its headers, and the token is bound to the trace, the application and 30 minutes.
  • Prometheus: Prometheus endpoint /metrics (or PGKILN_METRICS=on) answers GET /metrics in the Prometheus text format, for administrators signed in to the builder and for scrapers with the metrics token (Make a token, shown once; or PGKILN_METRICS_TOKEN). It works without a collector.

Each workspace chooses on its page → Mail and network access → OpenTelemetry (/builder/workspaces/<id>/telemetry, its administrators): As the instance does (the default), Nothing (its applications send nothing, not even to the instance's collector), or Also to our own collector: an OTLP/HTTP URL with its own headers and its own Include values, reached like any outgoing call of the workspace, through the installation's allow-list (PGKILN_REST_ALLOWED_HOSTS) and the workspace's network access list. Its resource carries pgkiln.workspace.id. Metrics go to the instance's collector only.

A Collector that sends traces to Jaeger, for a first look (docker compose):

yaml
services:
  jaeger:
    image: jaegertracing/all-in-one:1.62.0     # the UI on http://localhost:16686
    environment: { COLLECTOR_OTLP_ENABLED: "true" }
  otel-collector:
    image: otel/opentelemetry-collector-contrib:0.114.0
    command: ["--config=/etc/otel.yaml"]
    volumes: ["./otel.yaml:/etc/otel.yaml:ro"]
    ports: ["4318:4318"]
yaml
# otel.yaml
receivers:
  otlp: { protocols: { http: { endpoint: 0.0.0.0:4318 } } }
exporters:
  otlp/jaeger: { endpoint: jaeger:4317, tls: { insecure: true } }
  debug: {}
service:
  pipelines:
    traces: { receivers: [otlp], exporters: [otlp/jaeger] }
    logs: { receivers: [otlp], exporters: [debug] }
    metrics: { receivers: [otlp], exporters: [debug] }

Set OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 (or the URL in the builder), open a page, and its trace shows in Jaeger under the service pgkiln. A Prometheus scrape job for /metrics:

yaml
scrape_configs:
  - job_name: pgkiln
    metrics_path: /metrics
    authorization: { credentials: "<the metrics token>" }
    static_configs: [{ targets: ["apps.example.com:443"] }]
    scheme: https

Every server process sends what it saw: with several instances, each is a service.instance.id (host and process). A collector that is down costs a failed request per batch every few seconds, never a user's request; what doesn't fit the queue (8,192 spans per collector) is dropped and counted.

Backups and moving applications ​

  • Everything is in PostgreSQL: application definitions (meta.*), sessions and your data. A normal pg_dump backs it all up.
  • To move a single application between environments (development → test → production), use Builder → App → Export, which downloads JSON, then Builder → Import on the target, or in SQL:
    sql
    select meta.export_app('hr');                  -- returns jsonb
    select meta.import_app('<the json>', 'hr');    -- returns the new app id
    The export contains the application only, not your tables, functions, roles or users. Ship those as SQL migrations in your own project, and create users on the target.

Released under the Apache-2.0 license. Not affiliated with Oracle; Oracle and APEX are trademarks of Oracle.