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.

  1. 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
  1. 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
  1. 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
  1. 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
  1. 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.

  1. 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

  1. Stop the Formbricks stack

Stop the docker instance

docker compose down
  1. Pull the latest changes

Pull the changes into docker

docker compose pull
  1. Update env vars as necessary in the docker-compose file.
  2. 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.

Important Run-time Variables

These variables can be provided at the runtime i.e. in your docker-compose file.

VariableDescriptionRequiredDefault
WEBAPP_URLBase URL of the site.requiredhttp://localhost:3000
DATABASE_URLDatabase URL with credentials.requiredpostgresql://postgres:postgres@postgres:5432/formbricks?schema=public
NEXTAUTH_SECRETSecret for NextAuth, used for session signing and encryption.required(Generated by the user)
NEXTAUTH_URLLocation of the auth server. By default, this is the Formbricks docker instance itself.requiredhttp://localhost:3000
PRIVACY_URLURL for privacy policy.optional
TERMS_URLURL for terms of service.optional
IMPRINT_URLURL for imprint.optional
SIGNUP_DISABLEDDisables the ability for new users to create an account if set to 1.optional
PASSWORD_RESET_DISABLEDDisables password reset functionality if set to 1.optional
EMAIL_VERIFICATION_DISABLEDDisables email verification if set to 1.optional
INVITE_DISABLEDDisables the ability for invited users to create an account if set to 1.optional
MAIL_FROMEmail address to send emails from.optional (required if email services are to be enabled)
SMTP_HOSTHost URL of your SMTP server.optional (required if email services are to be enabled)
SMTP_PORTHost Port of your SMTP server.optional (required if email services are to be enabled)
SMTP_USERUsername for your SMTP Server.optional (required if email services are to be enabled)
SMTP_PASSWORDPassword for your SMTP Server.optional (required if email services are to be enabled)
SMTP_SECURE_ENABLEDSMTP secure connection. For using TLS, set to 1 else to 0.optional (required if email services are to be enabled)
GITHUB_AUTH_ENABLEDEnables GitHub login if set to 1.optional
GOOGLE_AUTH_ENABLEDEnables Google login if set to 1.optional
GITHUB_IDClient ID for GitHub.optional (required if GitHub auth is enabled)
GITHUB_SECRETSecret for GitHub.optional (required if GitHub auth is enabled)
GOOGLE_CLIENT_IDClient ID for Google.optional (required if Google auth is enabled)
GOOGLE_CLIENT_SECRETSecret for Google.optional (required if Google auth is enabled)
CRON_SECRETAPI Secret for running cron jobs.optional
STRIPE_SECRET_KEYSecret key for Stripe integration.optional
STRIPE_WEBHOOK_SECRETWebhook secret for Stripe integration.optional
TELEMETRY_DISABLEDDisables telemetry if set to 1.optional
INSTANCE_IDInstance ID for Formbricks Cloud to be sent to Telemetry.optional
INTERNAL_SECRETInternal Secret (Currently we overwrite the value with a random value).optional
DEFAULT_BRAND_COLORDefault brand color for your app (Can be overwritten from the UI as well).optional#64748b
DEFAULT_TEAM_IDAutomatically assign new users to a specific team when joiningoptional
DEFAULT_TEAM_ROLERole of the user in the default team.optionaladmin
ONBOARDING_DISABLEDDisables onboarding for new users if set to 1optional

Build-time Variables

These variables must be provided at the time of the docker build and would require rebuilding the image.

VariableDescriptionRequiredDefault
NEXT_PUBLIC_FORMBRICKS_API_HOSTHost for the Formbricks API.optional
NEXT_PUBLIC_FORMBRICKS_ENVIRONMENT_IDIf you already have a preset environment ID of the environment.optional
NEXT_PUBLIC_FORMBRICKS_ONBOARDING_SURVEY_IDIf you already have an onboarding survey ID to show new users.optional
NEXT_PUBLIC_POSTHOG_API_KEYAPI key for PostHog analytics.optional
NEXT_PUBLIC_POSTHOG_API_HOSTHost for PostHog analytics.optional
NEXT_PUBLIC_SENTRY_DSNDSN for Sentry error tracking.optional
NEXT_PUBLIC_DOCSEARCH_APP_IDID of the DocSearch application.optional
NEXT_PUBLIC_DOCSEARCH_API_KEYAPI key of the DocSearch application.optional
NEXT_PUBLIC_DOCSEARCH_INDEX_NAMEName of the DocSearch index.optional
NEXT_PUBLIC_FORMBRICKS_COM_ENVIRONMENT_IDEnvironment ID for Formbricks (if you already have one)optional
NEXT_PUBLIC_FORMBRICKS_COM_DOCS_FEEDBACK_SURVEY_IDSurvey ID for the feedback survey on the docs site.optional
NEXT_PUBLIC_FORMBRICKS_COM_API_HOSTHost for the Formbricks API.optional

Still facing issues? Join our Discord! and we'd be glad to assist you!

Was this page helpful?