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.

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

Was this page helpful?