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.


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

  1. Clone the repository:

Clone and cd into the Formbricks directory

git clone && cd formbricks
  1. 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)

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

NEXT_PUBLIC_WEBAPP_URLBase URL injected into static files.requiredhttp://localhost:3000
NEXT_PUBLIC_EMAIL_VERIFICATION_DISABLEDDisables email verification if set to 1.optional
NEXT_PUBLIC_PASSWORD_RESET_DISABLEDDisables password reset functionality if set to 1.optional
NEXT_PUBLIC_SIGNUP_DISABLEDDisables the ability for new users to create an account if set to 1.optional
NEXT_PUBLIC_INVITE_DISABLEDDisables the ability for invited users to create an account if set to 1.optional
NEXT_PUBLIC_PRIVACY_URLURL for privacy policy.optional
NEXT_PUBLIC_TERMS_URLURL for terms of service.optional
NEXT_PUBLIC_IMPRINT_URLURL for imprint.optional
NEXT_PUBLIC_GITHUB_AUTH_ENABLEDEnables GitHub login if set to 1.optional
NEXT_PUBLIC_GOOGLE_AUTH_ENABLEDEnables Google login if set to 1.optional
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_IS_FORMBRICKS_CLOUDUses Formbricks Cloud if set to 1optional
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
NEXT_PUBLIC_VERCEL_URLVercel URL (used instead of WEBAPP_URL).optional


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!

Was this page helpful?