Self-Hosting

Advanced Setup

Quickly set up and start using Formbricks with our official Docker 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. It's as easy as downloading the Docker image and firing up the container.

Requirements

Ensure docker & docker compose are installed on your server/system. Both are typically included with Docker utilities, like Docker Desktop and Rancher Desktop.

Start

  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. Generate Cron Secret

Next, you need to generate a Cron secret. This will be used as an API Secret for running cron jobs. The sed command below generates a random string using openssl, then replaces the CRON_SECRET: placeholder in the docker-compose.yml file with this generated secret:

Generate Cron Secret

sed -i "/CRON_SECRET:$/s/CRON_SECRET:.*/CRON_SECRET: $(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.

Update

  1. Pull the latest Formbricks image

Pull the changes into docker

docker compose pull
  1. Stop the Formbricks stack

Stop the docker instance

docker compose down
  1. Re-start the Formbricks stack with the updated image

Relaunch the Docker Instance

docker compose up -d

Debug

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.

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

Was this page helpful?