Self-Hosting
Building and Running Formbricks from Source
This approach provides the flexibility to configure every aspect of your Formbricks instance, including environment variables that need to be set at build time. While we don't recommend changing the source code of Formbricks, this method allows you to set your own configuration that might be necessary for specific deployment needs. Keep in mind that this method requires a more in-depth understanding of Docker and the build process. However, the trade-off is the additional control and flexibility you gain, making it worth considering if you're a more advanced user or have very specific configuration needs.
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.
- Clone the repository:
Clone and cd into the Formbricks directory
git clone https://github.com/formbricks/formbricks.git && cd formbricks
-
Modify the
.env.docker
file as required by your setup.
This file comes with a basic setup and Formbricks works without making any changes to the file. To enable email sending functionality you need to configure the SMTP settings. If you configured your email credentials, you can also comment the following lines to enable email verification (# NEXT_PUBLIC_EMAIL_VERIFICATION_DISABLED=1
) and password reset (# NEXT_PUBLIC_PASSWORD_RESET_DISABLED=1
)Editing a NEXT_PUBLIC_* variable?
Note: All environment variables starting with
NEXT_PUBLIC_
are used at build time. When you change environment variables later, you need to rebuild the image withdocker compose build
for the changes to take effect. -
Start the docker compose process.
Finally start the docker compose process to build and spin up the Formbricks container as well as the PostgreSQL database.
Use docker-compose if you are on an older docker version
Launch docker instances
docker compose up -d
You can now access the app on http://localhost:3000. You will be automatically redirected to the login. To use your local installation of Formbricks, create a new account.
Important Run-time Variables
These variables must also be provided at runtime.
| 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
|
| PRISMA_GENERATE_DATAPROXY | Enables a dedicated connection pool for Prisma using Prisma Data Proxy. Uncomment to enable. | optional | |
| 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
|
| 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_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 do not use this anywhere). | optional | |
| RENDER_EXTERNAL_URL | External URL for rendering (used instead of WEBAPP_URL). | optional | |
| HEROKU_APP_NAME | Heroku app name (used instead of WEBAPP_URL). | optional | |
| RAILWAY_STATIC_URL | Railway static URL (used instead of WEBAPP_URL). | optional | | |
Build-time Variables
These variables must be provided at the time of the docker build and can be provided by updating the .env
file.
Variable | Description | Required | Default |
---|---|---|---|
NEXT_PUBLIC_WEBAPP_URL | Base URL injected into static files. | required | http://localhost:3000 |
NEXT_PUBLIC_EMAIL_VERIFICATION_DISABLED | Disables email verification if set to 1 . | optional | |
NEXT_PUBLIC_PASSWORD_RESET_DISABLED | Disables password reset functionality if set to 1 . | optional | |
NEXT_PUBLIC_SIGNUP_DISABLED | Disables the ability for new users to create an account if set to 1 . | optional | |
NEXT_PUBLIC_INVITE_DISABLED | Disables the ability for invited users to create an account if set to 1 . | optional | |
NEXT_PUBLIC_PRIVACY_URL | URL for privacy policy. | optional | |
NEXT_PUBLIC_TERMS_URL | URL for terms of service. | optional | |
NEXT_PUBLIC_IMPRINT_URL | URL for imprint. | optional | |
NEXT_PUBLIC_GITHUB_AUTH_ENABLED | Enables GitHub login if set to 1 . | optional | |
NEXT_PUBLIC_GOOGLE_AUTH_ENABLED | Enables Google login if set to 1 . | optional | |
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_IS_FORMBRICKS_CLOUD | Uses Formbricks Cloud if set to 1 | 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 | |
NEXT_PUBLIC_VERCEL_URL | Vercel URL (used instead of WEBAPP_URL). | optional |
Debugging
If you encounter any issues, you can check the logs of the container with:
Docker container logs
docker compose logs -f
You can close the logs again with CTRL + C
.
Still facing issues? Join our Discord! and we'd be glad to assist you!