Self Host Formbricks Production Instance
Follow this guide to get your Formbricks instance up and running with a Postgres DB and SSL certificate using a single script:
Requirements
Before you proceed, make sure you have the following:
-
A Linux Ubuntu Virtual Machine deployed with SSH access.
-
An A record set up to connect a custom domain to your instance. Formbricks will automatically create an SSL certificate for your domain using Let's Encrypt.
Single Command Setup
Copy and paste the following command into your terminal:
/bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/formbricks/formbricks/stable/docker/formbricks.sh)"
The script will prompt you for the following information:
-
Overwriting Docker GPG Keys: If Docker GPG keys already exist, the script will ask if you want to overwrite them.
-
Email Address: Provide your email address for SSL certificate registration with Let's Encrypt.
-
Domain Name: Enter the domain name that Traefik will use to create the SSL certificate and forward requests to Formbricks.
That's it! After running the command and providing the required information, visit the domain name you entered, and you should see the Formbricks home wizard!
Formbricks Hub and Cube
The stack includes the Formbricks Hub API (ghcr.io/formbricks/hub) and can also run a bundled Cube.js service for XM Suite v5 analytics. Hub and Cube share the same database as Formbricks by default, and Cube is enabled through the optional Docker Compose xm profile.
- Migrations: A
hub-migrateservice runs Hub's database migrations (goose + river) before the Hub API starts. It runs on everydocker compose upand is idempotent. - Production (
docker/docker-compose.yml): SetHUB_API_KEY(required).HUB_API_URLdefaults tohttp://hub:8080so the Formbricks app can reach Hub inside the compose network. To enable XM Suite v5 analytics, setCOMPOSE_PROFILES=xmandCUBEJS_API_SECRET;CUBEJS_API_URLdefaults tohttp://cube:4000. Cube JWT issuer/audience default toformbricks-webandformbricks-cube, and the bundled Cube service exposes onlymeta,dataAPI scopes. OverrideHUB_DATABASE_URLandCUBEJS_DB_*only if Hub or Cube should use a separate database. The Hub image tracks:latestby default soformbricks.sh updateadvances Hub in lockstep with the app.hubandhub-migratealways resolve to the same image. To pin to an immutable reference, setHUB_IMAGE_REFindocker/.envto either a tag (e.g.:0.2.0) or a digest (e.g.@sha256:14db7b3d...). - Development (
docker-compose.dev.yml): Hub uses the same local Postgres database andHUB_API_KEYdefaults todev-api-key. Cube is behind thexmprofile,CUBEJS_API_URLdefaults tohttp://localhost:4000, andpnpm dev:setupgeneratesCUBEJS_API_SECRETin the repo root.env. The Hub image is pinned to a semver tag (hubandhub-migrateshare the same value); overrideHUB_IMAGE_TAGin the repo root.envto test a specific Hub release.
In development, Hub is exposed locally on port 8080. When the xm profile is enabled, Cube is exposed on 4000 (with the Cube playground on 4001). In production Docker Compose, Hub stays internal to the compose network at http://hub:8080; Cube also stays internal at http://cube:4000 when enabled.