Self-hosted DBtune on Docker Compose
Overview
DBtune can be self-hosted on a single VM using Docker Compose. This is the simplest deployment option, recommended if you are not running Kubernetes.
If you are running a Kubernetes cluster, see the Kubernetes self-hosted guide instead. For general background on self-hosting, see the self-hosted deployment overview.
How to host
The self-hosted platform ships as a single offline bundle — dbtune-self-hosted-<version>.tar — that already contains every image alongside the compose stack. No container registry access is required, which makes it suitable for air-gapped environments.
Once DBtune has enabled self-hosting for your organization, the bundle is available to download directly from the platform: open your organization page and download the latest self-hosted release. That single archive is everything you need.
- Setup requirements
dbtune-self-hosted-<version>.tar— the bundle downloaded from your organization page. It contains all images plusdocker-compose.yml,.env.self-hosted,load-images.shandsetup-self-hosted.sh.- A Linux host (
x86_64). docker(Engine 24+ with the Compose v2docker composesubcommand), orpodmanwithpodman-compose— runs the stack and configures volumes and networking.
- Download and extract the bundle
- Download
dbtune-self-hosted-<version>.tarfrom your organization page in the platform, copy it to your server, then unpack it:tar -xf dbtune-self-hosted-<version>.tar
cd dbtune-self-hosted-<version>
- Load the bundled images
- Every image ships inside the bundle, so there is no registry login or
docker pull../load-images.sh docker # or: ./load-images.sh podman
- Run the setup helper (recommended)
- Generates secure values (e.g.
DJANGO_SECRET_KEY,DJANGO_SUPERUSER_API_KEY) and prompts for required fields (FRONTEND_URL, superuser email and password).chmod +x ./setup-self-hosted.sh
./setup-self-hosted.sh
- Configure environment variables
- Open the included
.env.self-hostedfile. - Read the comments in that file and fill in the
CHANGEMEfields with your actual values. - Pay special attention to:
- Database, password, and secret key settings.
- SMTP/email settings for password reset and notifications.
- Start the platform
- The bundle already pins every image version, so no manual tag editing is required.
docker compose --env-file .env.self-hosted up -d - Only the main web interface (default port
8000) is open externally. You may optionally exposeinfluxdbandprefect-serverto access their UIs. - All other components communicate privately inside Docker.
- Access the application
- Visit http://your-server:8000 (replace with your server address or port).
- Log in with your configured superuser (see
.env.self-hosted).
System Requirements
The images used are the following:
postgres- Primary database for most operations.influx- Timeseries database.redis- KV cachedbtune-platform- The main platform applicationdbtuner- The optimization servicedbtune-indigo- Index recommendation engine (self-contained; runs its own ephemeral PostgreSQL internally, no external database required)prefect- Distributed task scheduling
System requirements primarily scale according to the number of connected databases, and concurrent tuning sessions. Services gracefully degrade under load spikes, but monitoring is advised.
An air-gapped setup for 5-10 databases with 1-2 concurrent tuning sessions, where gaurantee of low latency is not a concern when under load.
- Minimal: (2vCPU, 8GB RAM)
- Recommended: (4vCPU, 16GB RAM)
When scaling for your requirements, please monitor usage and adjust accordingly.
Email/SMTP Setup
- Real email (SMTP) is required for password resets and notifications.
- Enter your SMTP provider's details in the environment file. Example for Gmail:
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USE_TLS=True
EMAIL_FROM=your@email.com
EMAIL_HOST_PASSWORD=your-app-password - If your organization uses another provider (Exchange, Office365, SES, etc.) fill in those corresponding details.
- We do not recommend using test relays or Mailpit in production.
Other notes
- Ensure required ports are open (default:
8000for web). - For advanced features, SSO, or customization, contact support or see extended documentation.
Upgrade
Data (postgres_data, influxdb-data, prefect-data, redis-data) lives under ./volumes/ inside each bundle's own folder — it is not a Docker-managed volume shared across versions. Extracting the new bundle into a fresh directory starts that directory's ./volumes/ empty. Skipping step 2 below will bring the new version up with a blank database.
- Download the latest self-hosted bundle from your organization page and extract it alongside the old one, then
cdinto it. Do not rundocker compose upyet. - Copy your data across:
cp -R ../<old-bundle-dir>/volumes ./volumes. - Load the new images:
./load-images.sh docker(orpodman). - Reconcile your config, don't blind-copy it. Diff your old
.env.self-hostedagainst the new bundle's and carry your values into the new file, keeping any keys the release added. A release can introduce new required variables; compose reads them as${VAR:?}, so a missing key failsdocker compose upimmediately rather than starting on a stale value. - Carry over the secrets your data was created with —
POSTGRES_PASSWORD,PREFECT_DB_PASSWORD,INFLUXDB_INIT_PASSWORD,INFLUXDB_TOKEN— not just user-facing settings likeFRONTEND_URL. If you run./setup-self-hosted.shon the new bundle, it regenerates these randomly; overwrite them with the originals afterward, or the new containers can't authenticate against the copied data. - Apply:
docker compose --env-file .env.self-hosted up -d. Compose recreates the changed containers against the copied data.
The bundle already pins every image version, so there is nothing to look up manually.
DBtune agent
The DBtune agent can be set up as it is normally done with the DBtune SaaS platform, where the agent runs outside of the Docker network, communicating via the open 8000 port.
If you wish to host the DBtune agent inside the Docker network via docker compose alongside the platform stack, you will need to update the server_url to point to the web container inside the Docker Compose network.
The agent is the same as the agent in the SaaS solution — more information can be found in the DBtune documentation. The agent is open-source and written in Go.
Programmatic access
The DBtune REST API enables you to programmatically retrieve database information and recommendations. The API uses resource-oriented URLs, returns request responses in JSON format, and uses standard HTTP status codes.
To get started, please refer to the DBtune API documentation.
Security
The self-hosted deployment of DBtune works in an air-gapped environment, requiring no internet access. This makes it ideal for enterprise offline deployments.