Configuration

The Postgres image is configured entirely through AUTOPG_* environment variables, alongside the standard POSTGRES_* ones from the official image. Everything below is optional. With no configuration at all, autopg detects the host and tunes for a web workload.

Tuning inputs

These steer the auto-tuning. Anything you leave unset is detected from the host.

VariableDefaultValuesDescription
AUTOPG_DB_TYPEWEBWEB, OLTP, DW, DESKTOP, MIXEDWorkload shape.
AUTOPG_TOTAL_MEMORY_MBDetectedInteger (MB)Memory the database should plan for.
AUTOPG_CPU_COUNTDetectedIntegerCPU count for parallelism.
AUTOPG_PRIMARY_DISK_TYPEDetectedSSD, HDD, SANStorage type for I/O costing.
AUTOPG_NUM_CONNECTIONSPer workloadIntegerMax concurrent connections.

pg_stat_statements

VariableDefaultDescription
AUTOPG_ENABLE_PG_STAT_STATEMENTStruePreload and create the pg_stat_statements extension.

When enabled, the extension is added to shared_preload_libraries, created on first boot, and set to track all statements. This is what the diagnostics dashboard reads from.

Diagnostics dashboard

VariableDefaultDescription
AUTOPG_ENABLE_WEBAPPfalseServe the diagnostics dashboard.
AUTOPG_WEBAPP_HOST127.0.0.1Dashboard bind address.
AUTOPG_WEBAPP_PORT8000Dashboard port.
AUTOPG_DB_HOSTlocalhostPostgres host the dashboard reads.
AUTOPG_DB_PORT5432Postgres port.
AUTOPG_DB_NAMEpostgresDatabase to inspect.
AUTOPG_DB_USERpostgresDashboard database user.
AUTOPG_DB_PASSWORDunsetPassword for that user.

See Diagnostics for what the dashboard surfaces.

Custom postgresql.conf

When you need a setting autopg does not manage, or want to pin one of its values, mount your own config:

services:
  postgres:
    image: ghcr.io/piercefreeman/autopg:pg18-latest
    volumes:
      - ./postgresql.conf:/etc/postgresql/postgresql.conf

Your file is layered on top of the generated one, so you only need to specify the values you care about. The original generated config is preserved as postgresql.conf.base for reference.

Precedence

When the same setting could come from more than one place, autopg resolves it in this order, highest priority first:

  1. A value in your mounted postgresql.conf.
  2. An AUTOPG_* environment override.
  3. A value detected from the host.
  4. The built-in default for the workload type.