Self-Hosting
Advanced Setup
Quickly set up and start using Formbricks without getting into the technicalities of the build process. You'll be using an image that we've already built for you. The pre-built image is ready-to-run, and it only requires minimal configuration on your part. This approach is perfect for getting a functional instance of Formbricks up and running with minimal hassle. It's as easy as downloading the Docker image and firing up the container.
This is ideal for those who are testing Formbricks or want to run it with minimal to no modifications. For this we use the public Docker image and a simple docker-compose file.
Requirements
Ensure docker
& docker compose
are installed on your server/system. Both are typically included with Docker utilities, like Docker Desktop and Rancher Desktop.
docker compose
without the hyphen is now the primary method of using docker-compose, according to the
Docker documentation.
- Create a New Directory for Formbricks
Open a terminal and create a new directory for Formbricks, then navigate into this new directory:
Create and cd into the new directory
mkdir formbricks-quickstart && cd formbricks-quickstart
- Download the Docker-Compose File
Download the docker-compose file directly from the Formbricks repository:
Download docker compose file
curl -o docker-compose.yml https://raw.githubusercontent.com/formbricks/formbricks/main/docker/docker-compose.yml
- Generate NextAuth Secret
Next, you need to generate a NextAuth secret. This will be used for session signing and encryption. The sed
command below generates a random string using openssl
, then replaces the NEXTAUTH_SECRET:
placeholder in the docker-compose.yml
file with this generated secret:
Generate NextAuth Secret
sed -i "/NEXTAUTH_SECRET:$/s/NEXTAUTH_SECRET:.*/NEXTAUTH_SECRET: $(openssl rand -hex 32)/" docker-compose.yml
- Generate Encryption Key
Next, you need to generate an Encryption Key. This will be used for authenticating and verifying 2 Factor Authentication. The sed
command below generates a random string using openssl
, then replaces the ENCRYPTION_KEY:
placeholder in the docker-compose.yml
file with this generated secret:
Generate Encryption Key
sed -i "/ENCRYPTION_KEY:$/s/ENCRYPTION_KEY:.*/ENCRYPTION_KEY: $(openssl rand -hex 32)/" docker-compose.yml
- Start the Docker Setup
You're now ready to start the Formbricks Docker setup. The following command will start Formbricks together with a postgreSQL database using Docker Compose:
Launch Docker Instance
docker compose up -d
The -d
flag will run the containers in detached mode, meaning they'll run in the background.
-
Visit Formbricks in Your Browser
After starting the Docker setup, visit http://localhost:3000 in your browser to interact with the Formbricks application. The first time you access this page, you'll be greeted by a setup wizard. Follow the prompts to define your first user and get started.
Updating Formbricks
- Stop the Formbricks stack
Stop the docker instance
docker compose down
- Pull the latest changes
Pull the changes into docker
docker compose pull
- Update env vars as necessary in the docker-compose file.
- Re-start the Formbricks stack
Relaunch the Docker Instance
docker compose up -d
Debugging
If you encounter any issues, you can check the logs of the container with:
Look into docker logs
docker compose logs -f
In an ideal case, you should see something like this:
Docker Build Underway
[+] Running 9/16
⠹ formbricks 15 layers [⣿⣤⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀] 29.78MB/47.76MB Pulling 13.3s
✔ 7264a8db6415 Already exists 0.0s
⠋ 751194035c36 Downloading [===============================> ] 29.78MB/47.76... 8.1s
✔ eff5dce73b38 Download complete 1.7s
✔ c8ce5be43019 Download complete 1.2s
✔ a2f33c630af5 Download complete 5.1s
✔ e3b64e437860 Download complete 3.3s
✔ a6551ac5f976 Download complete 4.9s
✔ 4f4fb700ef54 Download complete 6.0s
✔ 22163889e16b Download complete 6.7s
✔ dc647bb9eb13 Download complete 7.8s
⠋ 49c2ad494720 Waiting 8.1s
⠋ 5c797a842dcb Waiting 8.1s
⠋ 1f231213db04 Waiting 8.1s
⠋ e407294bdcda Waiting 8.1s
⠋ 6fd8358dca47 Pulling fs layer 8.1s
[+] Running 2/2
✔ Container formbricks-quickstart-postgres-1 Created 0.0s
✔ Container formbricks-quickstart-formbricks-1 Created 0.0s
And at the tail of the output, you should see something like this:
Docker Build Completed
formbricks-quickstart-formbricks-1 | All migrations have been successfully applied.
formbricks-quickstart-formbricks-1 |
formbricks-quickstart-formbricks-1 | - info Loaded env from /home/nextjs/apps/web/.env
formbricks-quickstart-formbricks-1 | Listening on port 3000 url: http://<random-string>:3000
You can close the logs again with CTRL + C
.
Customizing the Build Time variables
To edit any of the variables that start with NEXT_PUBLIC_
, you need to rebuild the Formbricks Docker Image!
Important Run-time Variables
These variables can be provided at the runtime i.e. in your docker-compose file.
Variable | Description | Required | Default |
---|---|---|---|
WEBAPP_URL | Base URL of the site. | required | http://localhost:3000 |
DATABASE_URL | Database URL with credentials. | required | postgresql://postgres:postgres@postgres:5432/formbricks?schema=public |
NEXTAUTH_SECRET | Secret for NextAuth, used for session signing and encryption. | required | (Generated by the user) |
NEXTAUTH_URL | Location of the auth server. By default, this is the Formbricks docker instance itself. | required | http://localhost:3000 |
PRIVACY_URL | URL for privacy policy. | optional | |
TERMS_URL | URL for terms of service. | optional | |
IMPRINT_URL | URL for imprint. | optional | |
SIGNUP_DISABLED | Disables the ability for new users to create an account if set to 1 . | optional | |
PASSWORD_RESET_DISABLED | Disables password reset functionality if set to 1 . | optional | |
EMAIL_VERIFICATION_DISABLED | Disables email verification if set to 1 . | optional | |
INVITE_DISABLED | Disables the ability for invited users to create an account if set to 1 . | optional | |
MAIL_FROM | Email address to send emails from. | optional (required if email services are to be enabled) | |
SMTP_HOST | Host URL of your SMTP server. | optional (required if email services are to be enabled) | |
SMTP_PORT | Host Port of your SMTP server. | optional (required if email services are to be enabled) | |
SMTP_USER | Username for your SMTP Server. | optional (required if email services are to be enabled) | |
SMTP_PASSWORD | Password for your SMTP Server. | optional (required if email services are to be enabled) | |
SMTP_SECURE_ENABLED | SMTP secure connection. For using TLS, set to 1 else to 0 . | optional (required if email services are to be enabled) | |
GITHUB_AUTH_ENABLED | Enables GitHub login if set to 1 . | optional | |
GOOGLE_AUTH_ENABLED | Enables Google login if set to 1 . | optional | |
GITHUB_ID | Client ID for GitHub. | optional (required if GitHub auth is enabled) | |
GITHUB_SECRET | Secret for GitHub. | optional (required if GitHub auth is enabled) | |
GOOGLE_CLIENT_ID | Client ID for Google. | optional (required if Google auth is enabled) | |
GOOGLE_CLIENT_SECRET | Secret for Google. | optional (required if Google auth is enabled) | |
CRON_SECRET | API Secret for running cron jobs. | optional | |
STRIPE_SECRET_KEY | Secret key for Stripe integration. | optional | |
STRIPE_WEBHOOK_SECRET | Webhook secret for Stripe integration. | optional | |
TELEMETRY_DISABLED | Disables telemetry if set to 1 . | optional | |
INSTANCE_ID | Instance ID for Formbricks Cloud to be sent to Telemetry. | optional | |
INTERNAL_SECRET | Internal Secret (Currently we overwrite the value with a random value). | optional | |
DEFAULT_BRAND_COLOR | Default brand color for your app (Can be overwritten from the UI as well). | optional | #64748b |
DEFAULT_TEAM_ID | Automatically assign new users to a specific team when joining | optional | |
DEFAULT_TEAM_ROLE | Role of the user in the default team. | optional | admin |
ONBOARDING_DISABLED | Disables onboarding for new users if set to 1 | optional |
Build-time Variables
These variables must be provided at the time of the docker build and would require rebuilding the image.
Variable | Description | Required | Default |
---|---|---|---|
NEXT_PUBLIC_FORMBRICKS_API_HOST | Host for the Formbricks API. | optional | |
NEXT_PUBLIC_FORMBRICKS_ENVIRONMENT_ID | If you already have a preset environment ID of the environment. | optional | |
NEXT_PUBLIC_FORMBRICKS_ONBOARDING_SURVEY_ID | If you already have an onboarding survey ID to show new users. | optional | |
NEXT_PUBLIC_POSTHOG_API_KEY | API key for PostHog analytics. | optional | |
NEXT_PUBLIC_POSTHOG_API_HOST | Host for PostHog analytics. | optional | |
NEXT_PUBLIC_SENTRY_DSN | DSN for Sentry error tracking. | optional | |
NEXT_PUBLIC_DOCSEARCH_APP_ID | ID of the DocSearch application. | optional | |
NEXT_PUBLIC_DOCSEARCH_API_KEY | API key of the DocSearch application. | optional | |
NEXT_PUBLIC_DOCSEARCH_INDEX_NAME | Name of the DocSearch index. | optional | |
NEXT_PUBLIC_FORMBRICKS_COM_ENVIRONMENT_ID | Environment ID for Formbricks (if you already have one) | optional | |
NEXT_PUBLIC_FORMBRICKS_COM_DOCS_FEEDBACK_SURVEY_ID | Survey ID for the feedback survey on the docs site. | optional | |
NEXT_PUBLIC_FORMBRICKS_COM_API_HOST | Host for the Formbricks API. | optional |
Still facing issues? Join our Discord! and we'd be glad to assist you!