feat: let's v1.2 (#1332)

Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
This commit is contained in:
Shubham Palriwala
2023-10-26 00:52:16 +05:30
committed by GitHub
parent 21fe7080ef
commit e9f4edadbd
35 changed files with 355 additions and 378 deletions

View File

@@ -10,18 +10,13 @@
WEBAPP_URL=http://localhost:3000
SURVEY_BASE_URL=http://localhost:3000/s
# Set this if you want to have a shorter link for surveys
SHORT_SURVEY_BASE_URL=
SHORT_URL_BASE=
# Encryption keys
# Please set both for now, we will change this in the future
# You can use: `openssl rand -base64 16` to generate one
FORMBRICKS_ENCRYPTION_KEY=
# You can use: `openssl rand -base64 24` to generate one
# You can use: `openssl rand -hex 32` to generate one
ENCRYPTION_KEY=
##############
@@ -35,7 +30,7 @@ DATABASE_URL='postgresql://postgres:postgres@localhost:5432/formbricks?schema=pu
###############
# @see: https://next-auth.js.org/configuration/options#nextauth_secret
# You can use: `openssl rand -base64 32` to generate one
# You can use: `openssl rand -hex 32` to generate one
NEXTAUTH_SECRET=RANDOM_STRING
# Set this to your public-facing URL, e.g., https://example.com

View File

@@ -27,7 +27,7 @@ jobs:
- name: Generate Random NEXTAUTH_SECRET
run: |
SECRET=$(openssl rand -base64 24)
SECRET=$(openssl rand -hex 32)
echo "ENCRYPTION_KEY=$SECRET" >> $GITHUB_ENV
- name: Build Formbricks-web

View File

@@ -27,7 +27,7 @@ jobs:
- name: Generate Random NEXTAUTH_SECRET
run: |
SECRET=$(openssl rand -base64 24)
SECRET=$(openssl rand -hex 32)
echo "ENCRYPTION_KEY=$SECRET" >> $GITHUB_ENV
- name: Lint

View File

@@ -16,12 +16,12 @@ jobs:
steps:
- name: Generate Random NEXTAUTH_SECRET
run: |
SECRET=$(openssl rand -hex 16)
SECRET=$(openssl rand -hex 32)
echo "NEXTAUTH_SECRET=$SECRET" >> $GITHUB_ENV
- name: Generate Random NEXTAUTH_SECRET
run: |
SECRET=$(openssl rand -base64 24)
SECRET=$(openssl rand -hex 32)
echo "ENCRYPTION_KEY=$SECRET" >> $GITHUB_ENV
- name: Checkout Repo

View File

@@ -10,7 +10,7 @@ tasks:
gp sync-await init &&
turbo --filter "@formbricks/demo" go
- name : website
- name: website
command: gp sync-await init && turbo --filter "@formbricks/formbricks-com" dev
- name: Init Formbricks
@@ -34,12 +34,10 @@ tasks:
cp .env.example .env &&
sed -i -r "s#^(WEBAPP_URL=).*#\1 $(gp url 3000)#" .env &&
sed -i -r "s#^(NEXTAUTH_URL=).*#\1 $(gp url 3000)#" .env &&
RANDOM_FORMBRICKS_ENCRYPTION_KEY=$(openssl rand -base64 16)
sed -i 's/^FORMBRICKS_ENCRYPTION_KEY=.*/FORMBRICKS_ENCRYPTION_KEY='"$RANDOM_FORMBRICKS_ENCRYPTION_KEY"'/' .env
RANDOM_ENCRYPTION_KEY=$(openssl rand -base64 24)
RANDOM_ENCRYPTION_KEY=$(openssl rand -hex 32)
sed -i 's/^ENCRYPTION_KEY=.*/ENCRYPTION_KEY='"$RANDOM_ENCRYPTION_KEY"'/' .env
turbo --filter "@formbricks/web" go
image:
file: .gitpod.Dockerfile
@@ -62,7 +60,7 @@ ports:
- port: 8025
visibility: public
onOpen: open-browser
github:
prebuilds:
master: true
@@ -77,4 +75,4 @@ vscode:
- "dbaeumer.vscode-eslint"
- "esbenp.prettier-vscode"
- "Prisma.prisma"
- "yzhang.markdown-all-in-one"
- "yzhang.markdown-all-in-one"

View File

@@ -1,6 +1,7 @@
export const meta = {
title: "Formbricks Development Setup: Complete Guide to Local Environment Configuration for Dev",
description: "Step-by-step guide to setting up your local development environment for Formbricks. Includes installing essential tools like Node.JS, pnpm, and Docker, and accessing the entire Formbricks stack including the Demo app and the main website",
description:
"Step-by-step guide to setting up your local development environment for Formbricks. Includes installing essential tools like Node.JS, pnpm, and Docker, and accessing the entire Formbricks stack including the Demo app and the main website",
};
#### Contributing
@@ -14,14 +15,15 @@ To get the project running locally on your machine you need to have the followin
- [Docker](https://www.docker.com/) (to run PostgreSQL / MailHog)
1. Clone the project:
<Col>
<Col>
<CodeGroup title="Git clone Formbricks monorepo">
```bash
git clone https://github.com/formbricks/formbricks
```
</CodeGroup>
</CodeGroup>
</Col>
and move into the directory
<Col>
@@ -31,48 +33,55 @@ To get the project running locally on your machine you need to have the followin
cd formbricks
```
</CodeGroup>
</CodeGroup>
</Col>
1. Install Node.JS packages via pnpm. Don't have pnpm? Get it [here](https://pnpm.io/installation)
<Col>
<Col>
<CodeGroup title="Install dependencies via pnpm">
```bash
pnpm install
```
</CodeGroup>
</CodeGroup>
</Col>
1. Create a `.env` file based on `.env.example`. It's already preset to work with the docker-compose setup but you can also change values if needed.
<Col>
<Col>
<CodeGroup title="Define environment variables">
```bash
cp .env.example .env
```
</CodeGroup>
</CodeGroup>
</Col>
1. Generate a secret value mandatory to be set for the key ENCRYPTION_KEY in the .env file. You can use the following command to generate the random string of required length:
<Col>
<Col>
<CodeGroup title="Set value of ENCRYPTION_KEY">
```bash
openssl rand -base64 24
openssl rand -hex 32
```
</CodeGroup>
</CodeGroup>
</Col>
1. Make sure you have [`Docker`](https://docs.docker.com/compose/) & [`docker-compose`](https://docs.docker.com/compose/) installed and running on your machine. Then run the following command to start the formbricks dev setup:
<Col>
<Col>
<CodeGroup title="Start Formbricks Dev Setup">
```bash
pnpm go
```
</CodeGroup>
</CodeGroup>
</Col>
This starts the Formbricks main app (plus all its dependencies) as well as the following services using Docker:
@@ -86,6 +95,7 @@ To get the project running locally on your machine you need to have the followin
### Build
To build all apps and packages and check for build errors, run the following command:
<Col>
<CodeGroup title="Build Formbricks stack">
@@ -98,6 +108,7 @@ pnpm build
### Access Demo app
To run the [Demo app](/docs/contributing/demo), run the following command in a separate terminal window:
<Col>
<CodeGroup title="Start Formbricks Demo App">
@@ -112,6 +123,7 @@ You can now access the Demo app on [http://localhost:3002](http://localhost:3002
### Access Formbricks website
If you want to make changes to the Formbricks website, e.g. to update the documentation, run the following command in a separate terminal window:
<Col>
<CodeGroup title="Start Formbricks Website">

View File

@@ -8,7 +8,7 @@ export const meta = {
# Self Hosting Formbricks
At Formbricks, we understand that different users have different needs, and we strive to cater to a wide variety of situations. This is why we currently provide three ways of running our application:
At Formbricks, we understand that different users have different needs, and we strive to cater to a wide variety of situations. This is why we currently provide two ways of running our application:
1. **Production Instance Setup with Shell Script on Ubuntu**: If you want to quickly set up a production instance of Formbricks on a server running Ubuntu, we've got you covered! This method utilizes a convenient shell script that takes care of everything, including Docker, Postgres DB, and SSL certificate configuration. The shell script will automatically install all the required dependencies and configure your server, making the process a breeze. Visit the [Production Instance Setup with a Bash Script Documentation](/docs/self-hosting/production).

View File

@@ -21,98 +21,131 @@ Ensure `docker` & `docker compose` are installed on your server/system. Both are
Docker documentation.
</Note>
1. **Create a New Directory for Formbricks**
1. **Create a New Directory for Formbricks**
Open a terminal and create a new directory for Formbricks, then navigate into this new directory:
<Col>
Open a terminal and create a new directory for Formbricks, then navigate into this new directory:
<Col>
<CodeGroup title="Create and cd into the new directory">
```bash
mkdir formbricks-quickstart && cd formbricks-quickstart
```
```bash
mkdir formbricks-quickstart && cd formbricks-quickstart
```
</CodeGroup>
</Col>
2. **Download the Docker-Compose File**
</CodeGroup>
Download the docker-compose file directly from the Formbricks repository:
<Col>
</Col>
2. **Download the Docker-Compose File**
Download the docker-compose file directly from the Formbricks repository:
<Col>
<CodeGroup title="Download docker compose file">
```bash
curl -o docker-compose.yml https://raw.githubusercontent.com/formbricks/formbricks/main/docker/docker-compose.yml
```
```bash
curl -o docker-compose.yml https://raw.githubusercontent.com/formbricks/formbricks/main/docker/docker-compose.yml
```
</CodeGroup>
</Col>
3. **Generate NextAuth Secret**
</CodeGroup>
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:
<Col>
</Col>
3. **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:
<Col>
<CodeGroup title="Generate NextAuth Secret">
```bash
sed -i "/NEXTAUTH_SECRET:$/s/NEXTAUTH_SECRET:.*/NEXTAUTH_SECRET: $(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | head -c 32)/" docker-compose.yml
```
```bash
sed -i "/NEXTAUTH_SECRET:$/s/NEXTAUTH_SECRET:.*/NEXTAUTH_SECRET: $(openssl rand -hex 32)/" docker-compose.yml
```
</CodeGroup>
</Col>
4. **Start the Docker Setup**
</CodeGroup>
You're now ready to start the Formbricks Docker setup. The following command will start Formbricks together with a postgreSQL database using Docker Compose:
</Col>
4. **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:
<Col>
<CodeGroup title="Generate Encryption Key">
```bash
sed -i "/ENCRYPTION_KEY:$/s/ENCRYPTION_KEY:.*/ENCRYPTION_KEY: $(openssl rand -hex 32)/" docker-compose.yml
```
</CodeGroup>
</Col>
5. **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:
We pass the `--env-file /dev/null` flag to docker-compose to prevent it from reading the .env file. This is because we're using environment variables directly in the docker-compose.yml file as the env file is currently in a format not well recognised by docker systems.
<Col>
<CodeGroup title="Launch Docker Instance">
```bash
docker compose --env-file /dev/null up -d
```
```bash
docker compose up -d
```
</CodeGroup>
</Col>
The `-d` flag will run the containers in detached mode, meaning they'll run in the background.
5. **Visit Formbricks in Your Browser**
6. **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
<Col>
1. Stop the Formbricks stack
<Col>
<CodeGroup title="Stop the docker instance">
```bash
docker compose down
```
```bash
docker compose down
```
</CodeGroup>
</Col>
2. Pull the latest changes
<Col>
</CodeGroup>
</Col>
2. Pull the latest changes
<Col>
<CodeGroup title="Pull the changes into docker">
```bash
docker compose pull
```
```bash
docker compose pull
```
</CodeGroup>
</Col>
3. Update env vars as necessary in the docker-compose file.
4. Re-start the Formbricks stack
<Col>
</CodeGroup>
</Col>
3. Update env vars as necessary in the docker-compose file.
4. Re-start the Formbricks stack
<Col>
<CodeGroup title="Relaunch the Docker Instance">
```bash
docker compose --env-file /dev/null up -d
```
```bash
docker compose up -d
```
</CodeGroup>
</Col>
</CodeGroup>
</Col>
## Debugging
If you encounter any issues, you can check the logs of the container with:
<Col>
<CodeGroup title="Look into docker logs">
@@ -178,40 +211,39 @@ To edit any of the variables that start with `NEXT_PUBLIC_`, you need to rebuild
These variables can be provided at the runtime i.e. in your docker-compose file.
| Variable | Description | Required | Default |
| --------------------------- | -------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ----------------------------------------------------------------------- |
| WEBAPP_URL | Base URL of the site. | required | `http://localhost:3000` |
| SURVEY_BASE_URL | Base URL of the link surveys. | required | `http://localhost:3000/s/` |
| DATABASE_URL | Database URL with credentials. | required | `postgresql://postgres:postgres@postgres:5432/formbricks?schema=public` |
| 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` |
| PRIVACY_URL | URL for privacy policy. | optional | |
| TERMS_URL | URL for terms of service. | optional | |
| IMPRINT_URL | URL for imprint. | optional | |
| SIGNUP_DISABLED | Disables the ability for new users to create an account if set to `1`. | optional | |
| PASSWORD_RESET_DISABLED | Disables password reset functionality if set to `1`. | optional | |
| EMAIL_VERIFICATION_DISABLED | Disables email verification if set to `1`. | optional | |
| INVITE_DISABLED | Disables the ability for invited users to create an account if set to `1`. | optional | |
| 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_AUTH_ENABLED | Enables GitHub login if set to `1`. | optional | |
| GOOGLE_AUTH_ENABLED | Enables Google login if set to `1`. | optional | |
| 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 overwrite the value with a random value). | optional | |
| IS_FORMBRICKS_CLOUD | Uses Formbricks Cloud if set to `1` | optional | |
| DEFAULT_BRAND_COLOR | Default brand color for your app (Can be overwritten from the UI as well). | optional | `#64748b` |
| 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` |
| 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` |
| PRIVACY_URL | URL for privacy policy. | optional | |
| TERMS_URL | URL for terms of service. | optional | |
| IMPRINT_URL | URL for imprint. | optional | |
| SIGNUP_DISABLED | Disables the ability for new users to create an account if set to `1`. | optional | |
| PASSWORD_RESET_DISABLED | Disables password reset functionality if set to `1`. | optional | |
| EMAIL_VERIFICATION_DISABLED | Disables email verification if set to `1`. | optional | |
| INVITE_DISABLED | Disables the ability for invited users to create an account if set to `1`. | optional | |
| 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_AUTH_ENABLED | Enables GitHub login if set to `1`. | optional | |
| GOOGLE_AUTH_ENABLED | Enables Google login if set to `1`. | optional | |
| 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 overwrite the value with a random value). | optional | |
| IS_FORMBRICKS_CLOUD | Uses Formbricks Cloud if set to `1` | optional | |
| DEFAULT_BRAND_COLOR | Default brand color for your app (Can be overwritten from the UI as well). | optional | `#64748b` |
## Build-time Variables
@@ -232,5 +264,4 @@ These variables must be provided at the time of the docker build and would requi
| 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 | |
Still facing issues? [Join our Discord!](https://formbricks.com/discord) and we'd be glad to assist you!

View File

@@ -6,33 +6,53 @@ export const meta = {
#### Self-Hosting
# Migrating to v1.1
# Migration Guide
## v1.1 -> v1.2
Formbricks v1.2 ships a lot of features targeting our Link Surveys. We have also improved our security posture to be as robust as ever. However, it also comes with a few breaking changes specifically with the environment variables. This guide will help you migrate your existing Formbricks instance to v1.2 without any hassles or build errors.
### New Environment Variables
| Environment Variable | Required | Recommended Generation | Comments |
| -------------------- | -------- | ------------------------------ | ----------------------------------------------------------- |
| ENCRYPTION_KEY | true | `openssl rand -hex 32` | Needed for 2 Factor Authentication |
| SHORT_URL_BASE | false | `<your-short-base-url>` | Needed if you want to enable shorter links for Link Surveys |
| ASSET_PREFIX_URL | false | `<your-asset-hosted-base-url>` | Needed if you have a separate URL for hosted assets |
### Deprecated / Removed Environment Variables
| Environment Variable | Comments |
| -------------------- | ------------------------------------------------------------------------- |
| SURVEY_BASE_URL | The WEBAPP_URL is now used to determine the survey base url in all places |
## v1.0 -> v1.1
Formbricks v1.1 includes a lot of new features and improvements. However, it also comes with a few breaking changes specifically with the environment variables. This guide will help you migrate your existing Formbricks instance to v1.1 without losing any data.
## Changes in .env
### Renamed Environment Variables
This was introduced because we got a lot of requests from our users for the ability to define some common environment variables at runtime itself i.e. without having to rebuild the image for the changes to take effect.
This is now possible with v1.1. However, due to Next.JS best practices, we had to deprecate the prefix **NEXT_PUBLIC_** in the following environment variables:
This is now possible with v1.1. However, due to Next.JS best practices, we had to deprecate the prefix **NEXT*PUBLIC*** in the following environment variables:
| till v1.0 | v1.1 |
| ------------------------------------------- | --------------------------- |
| **NEXT_PUBLIC_**EMAIL_VERIFICATION_DISABLED | EMAIL_VERIFICATION_DISABLED |
| **NEXT_PUBLIC_**PASSWORD_RESET_DISABLED | PASSWORD_RESET_DISABLED |
| **NEXT_PUBLIC_**SIGNUP_DISABLED | SIGNUP_DISABLED |
| **NEXT_PUBLIC_**INVITE_DISABLED | INVITE_DISABLED |
| **NEXT_PUBLIC_**PRIVACY_URL | PRIVACY_URL |
| **NEXT_PUBLIC_**TERMS_URL | TERMS_URL |
| **NEXT_PUBLIC_**IMPRINT_URL | IMPRINT_URL |
| **NEXT_PUBLIC_**GITHUB_AUTH_ENABLED | GITHUB_AUTH_ENABLED |
| **NEXT_PUBLIC_**GOOGLE_AUTH_ENABLED | GOOGLE_AUTH_ENABLED |
| **NEXT_PUBLIC_**WEBAPP_URL | WEBAPP_URL |
| **NEXT_PUBLIC_**IS_FORMBRICKS_CLOUD | IS_FORMBRICKS_CLOUD |
| **NEXT_PUBLIC_**SURVEY_BASE_URL | SURVEY_BASE_URL |
| **NEXT*PUBLIC***EMAIL_VERIFICATION_DISABLED | EMAIL_VERIFICATION_DISABLED |
| **NEXT*PUBLIC***PASSWORD_RESET_DISABLED | PASSWORD_RESET_DISABLED |
| **NEXT*PUBLIC***SIGNUP_DISABLED | SIGNUP_DISABLED |
| **NEXT*PUBLIC***INVITE_DISABLED | INVITE_DISABLED |
| **NEXT*PUBLIC***PRIVACY_URL | PRIVACY_URL |
| **NEXT*PUBLIC***TERMS_URL | TERMS_URL |
| **NEXT*PUBLIC***IMPRINT_URL | IMPRINT_URL |
| **NEXT*PUBLIC***GITHUB_AUTH_ENABLED | GITHUB_AUTH_ENABLED |
| **NEXT*PUBLIC***GOOGLE_AUTH_ENABLED | GOOGLE_AUTH_ENABLED |
| **NEXT*PUBLIC***WEBAPP_URL | WEBAPP_URL |
| **NEXT*PUBLIC***IS_FORMBRICKS_CLOUD | IS_FORMBRICKS_CLOUD |
| **NEXT*PUBLIC***SURVEY_BASE_URL | SURVEY_BASE_URL |
<Note>
Please note that their values and the logic remains exactly the same. Only the prefix has been deprecated. The other environment variables remain the same as well.
Please note that their values and the logic remains exactly the same. Only the prefix has been deprecated.
The other environment variables remain the same as well.
</Note>
### Deprecated Environment Variables
@@ -44,13 +64,15 @@ Please note that their values and the logic remains exactly the same. Only the p
- **NEXT_PUBLIC_WEBAPP_URL**: Was used for the same purpose as WEBAPP_URL, but from v1.1, you can just set the WEBAPP_URL environment variable.
- **PRISMA_GENERATE_DATAPROXY**: Was used to tell Prisma that it should generate the runtime for Dataproxy usage. But its officially deprecated now.
## Helper Shell Script
### Helper Shell Script
For a seamless migration, below is a shell script for your self-hosted instance that will automatically update your environment variables to be compliant with the new naming conventions.
### Docker & Single Script Setup
Now that these variables can be defined at runtime, you can append them inside your `x-environment` in the `docker-compose.yml` itself.
For a more detailed guide on these environment variables, please refer to the [Important Runtime Variables](/docs/self-hosting/docker#important-run-time-variables) section.
<Col>
<CodeGroup title="docker-compose.yml">
```yaml {{ title: 'docker-compose.yml' }}
@@ -65,7 +87,7 @@ x-environment: &environment
# NextJS Auth
# @see: https://next-auth.js.org/configuration/options#nextauth_secret
# You can use: `openssl rand -base64 32` to generate one
# You can use: `openssl rand -hex 32` to generate one
NEXTAUTH_SECRET:
# Set this to your public-facing URL, e.g., https://example.com
@@ -106,7 +128,7 @@ x-environment: &environment
# Uncomment the below and set to 1 if you want to enable GitHub OAuth
# GITHUB_AUTH_ENABLED:
# GITHUB_ID:
# GITHUB_ID:
# GITHUB_SECRET:
# Uncomment the below and set to 1 if you want to enable Google OAuth
@@ -117,4 +139,5 @@ x-environment: &environment
```
</CodeGroup>
</Col>
Did we miss something? Are you still facing issues migrating your app? [Join our Discord!](https://formbricks.com/discord) We'd be happy to help!
Did we miss something? Are you still facing issues migrating your app? [Join our Discord!](https://formbricks.com/discord) We'd be happy to help!
```

View File

@@ -246,7 +246,8 @@ export const navigation: Array<NavGroup> = [
{ title: "Deployment", href: "/docs/self-hosting/deployment" },
{ title: "Production", href: "/docs/self-hosting/production" },
{ title: "Docker", href: "/docs/self-hosting/docker" },
{ title: "Migration to v1.1", href: "/docs/self-hosting/migrating-to-1.1" },
{ title: "From Source", href: "/docs/self-hosting/from-source" },
{ title: "Migration Guide", href: "/docs/self-hosting/migration-guide" },
],
},
{

View File

@@ -145,12 +145,16 @@ const nextConfig = {
destination: "https://app.formbricks.com/s/clhys1p9r001cpr0hu65rwh17",
permanent: true,
},
{
source: "/docs/self-hosting/migrating-to-1.1",
destination: "/docs/self-hosting/migration-guide",
permanent: true,
},
{
source: "/cla",
destination: "https://formbricks.com/clmyhzfrymr4ko00hycsg1tvx",
permanent: true,
},
];
},
async rewrites() {

View File

@@ -2,7 +2,7 @@
import { prisma } from "@formbricks/database";
import { authOptions } from "@formbricks/lib/authOptions";
import { SHORT_SURVEY_BASE_URL, SURVEY_BASE_URL } from "@formbricks/lib/constants";
import { SHORT_URL_BASE, WEBAPP_URL } from "@formbricks/lib/constants";
import { hasUserEnvironmentAccess } from "@formbricks/lib/environment/auth";
import { createMembership } from "@formbricks/lib/membership/service";
import { createProduct } from "@formbricks/lib/product/service";
@@ -19,13 +19,13 @@ export const createShortUrlAction = async (url: string) => {
const session = await getServerSession(authOptions);
if (!session) throw new AuthenticationError("Not authenticated");
const regexPattern = new RegExp("^" + SURVEY_BASE_URL);
const regexPattern = new RegExp("^" + WEBAPP_URL);
const isValidUrl = regexPattern.test(url);
if (!isValidUrl) throw new Error("Only Formbricks survey URLs are allowed");
const shortUrl = await createShortUrl(url);
const fullShortUrl = SHORT_SURVEY_BASE_URL + shortUrl.id;
const fullShortUrl = SHORT_URL_BASE + "/" + shortUrl.id;
return fullShortUrl;
};

View File

@@ -1,7 +1,7 @@
export const revalidate = REVALIDATION_INTERVAL;
import Navigation from "@/app/(app)/environments/[environmentId]/components/Navigation";
import { IS_FORMBRICKS_CLOUD, REVALIDATION_INTERVAL, SURVEY_BASE_URL } from "@formbricks/lib/constants";
import { IS_FORMBRICKS_CLOUD, REVALIDATION_INTERVAL, WEBAPP_URL } from "@formbricks/lib/constants";
import { getEnvironment, getEnvironments } from "@formbricks/lib/environment/service";
import { getProducts } from "@formbricks/lib/product/service";
import { getTeamByEnvironmentId, getTeamsByUserId } from "@formbricks/lib/team/service";
@@ -43,7 +43,7 @@ export default async function EnvironmentsNavbar({ environmentId, session }: Env
environments={environments}
session={session}
isFormbricksCloud={IS_FORMBRICKS_CLOUD}
surveyBaseUrl={SURVEY_BASE_URL}
webAppUrl={WEBAPP_URL}
/>
);
}

View File

@@ -62,7 +62,7 @@ interface NavigationProps {
products: TProduct[];
environments: TEnvironment[];
isFormbricksCloud: boolean;
surveyBaseUrl: string;
webAppUrl: string;
}
export default function Navigation({
@@ -73,7 +73,7 @@ export default function Navigation({
products,
environments,
isFormbricksCloud,
surveyBaseUrl,
webAppUrl,
}: NavigationProps) {
const router = useRouter();
const pathname = usePathname();
@@ -495,7 +495,7 @@ export default function Navigation({
<UrlShortenerModal
open={showLinkShortenerModal}
setOpen={(val) => setShowLinkShortenerModal(val)}
surveyBaseUrl={surveyBaseUrl}
webAppUrl={webAppUrl}
/>
</nav>
)}

View File

@@ -12,14 +12,14 @@ import { createShortUrlAction } from "../actions";
type UrlShortenerModalProps = {
open: boolean;
setOpen: (v: boolean) => void;
surveyBaseUrl: string;
webAppUrl: string;
};
type UrlShortenerFormDataProps = {
url: string;
};
type UrlValidationState = "default" | "valid" | "invalid";
export default function UrlShortenerModal({ open, setOpen, surveyBaseUrl }: UrlShortenerModalProps) {
export default function UrlShortenerModal({ open, setOpen, webAppUrl }: UrlShortenerModalProps) {
const [urlValidationState, setUrlValidationState] = useState<UrlValidationState>("default");
const [shortUrl, setShortUrl] = useState("");
const {
@@ -41,7 +41,7 @@ export default function UrlShortenerModal({ open, setOpen, surveyBaseUrl }: UrlS
return;
}
const regexPattern = new RegExp("^" + surveyBaseUrl);
const regexPattern = new RegExp("^" + webAppUrl);
const isValid = regexPattern.test(value);
if (!isValid) {
setUrlValidationState("invalid");
@@ -99,7 +99,7 @@ export default function UrlShortenerModal({ open, setOpen, surveyBaseUrl }: UrlS
<div className="grid grid-cols-6 gap-3">
<Input
autoFocus
placeholder={`${surveyBaseUrl}...`}
placeholder={`${webAppUrl}...`}
className={clsx(
"col-span-5",
urlValidationState === "valid"

View File

@@ -20,7 +20,7 @@ interface ResponsePageProps {
survey: TSurvey;
surveyId: string;
responses: TResponse[];
surveyBaseUrl: string;
webAppUrl: string;
product: TProduct;
profile: TProfile;
environmentTags: TTag[];
@@ -32,7 +32,7 @@ const ResponsePage = ({
survey,
surveyId,
responses,
surveyBaseUrl,
webAppUrl,
product,
profile,
environmentTags,
@@ -58,7 +58,7 @@ const ResponsePage = ({
environment={environment}
survey={survey}
surveyId={surveyId}
surveyBaseUrl={surveyBaseUrl}
webAppUrl={webAppUrl}
product={product}
profile={profile}
/>

View File

@@ -3,7 +3,7 @@ export const revalidate = REVALIDATION_INTERVAL;
import { getAnalysisData } from "@/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/data";
import ResponsePage from "@/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/responses/components/ResponsePage";
import { authOptions } from "@formbricks/lib/authOptions";
import { RESPONSES_PER_PAGE, REVALIDATION_INTERVAL, SURVEY_BASE_URL } from "@formbricks/lib/constants";
import { RESPONSES_PER_PAGE, REVALIDATION_INTERVAL, WEBAPP_URL } from "@formbricks/lib/constants";
import { getEnvironment } from "@formbricks/lib/environment/service";
import { getProductByEnvironmentId } from "@formbricks/lib/product/service";
import { getProfile } from "@formbricks/lib/profile/service";
@@ -40,7 +40,7 @@ export default async function Page({ params }) {
responses={responses}
survey={survey}
surveyId={params.surveyId}
surveyBaseUrl={SURVEY_BASE_URL}
webAppUrl={WEBAPP_URL}
product={product}
environmentTags={tags}
profile={profile}

View File

@@ -12,7 +12,7 @@ import { TProfile } from "@formbricks/types/profile";
interface LinkSurveyShareButtonProps {
survey: TSurvey;
className?: string;
surveyBaseUrl: string;
webAppUrl: string;
product: TProduct;
profile: TProfile;
}
@@ -20,7 +20,7 @@ interface LinkSurveyShareButtonProps {
export default function LinkSurveyShareButton({
survey,
className,
surveyBaseUrl,
webAppUrl,
product,
profile,
}: LinkSurveyShareButtonProps) {
@@ -45,7 +45,7 @@ export default function LinkSurveyShareButton({
open={showLinkModal}
setOpen={setShowLinkModal}
product={product}
surveyBaseUrl={surveyBaseUrl}
webAppUrl={webAppUrl}
profile={profile}
/>
)}

View File

@@ -17,7 +17,7 @@ interface ShareEmbedSurveyProps {
survey: TSurvey;
open: boolean;
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
surveyBaseUrl: string;
webAppUrl: string;
product: TProduct;
profile: TProfile;
}
@@ -25,11 +25,11 @@ export default function ShareEmbedSurvey({
survey,
open,
setOpen,
surveyBaseUrl,
webAppUrl,
product,
profile,
}: ShareEmbedSurveyProps) {
const surveyUrl = useMemo(() => surveyBaseUrl + survey.id, [survey]);
const surveyUrl = useMemo(() => webAppUrl + "/s/" + survey.id, [survey]);
const isSingleUseLinkSurvey = survey.singleUse?.enabled;
const { email } = profile;
const { brandColor } = product;
@@ -45,7 +45,7 @@ export default function ShareEmbedSurvey({
const componentMap = {
link: isSingleUseLinkSurvey ? (
<LinkSingleUseSurveyModal survey={survey} surveyBaseUrl={surveyBaseUrl} />
<LinkSingleUseSurveyModal survey={survey} surveyBaseUrl={webAppUrl} />
) : (
<LinkTab surveyUrl={surveyUrl} survey={survey} brandColor={surveyBrandColor} />
),

View File

@@ -13,7 +13,7 @@ import { TProfile } from "@formbricks/types/profile";
interface SummaryMetadataProps {
environment: TEnvironment;
survey: TSurvey;
surveyBaseUrl: string;
webAppUrl: string;
product: TProduct;
profile: TProfile;
singleUseIds?: string[];
@@ -22,7 +22,7 @@ interface SummaryMetadataProps {
export default function SuccessMessage({
environment,
survey,
surveyBaseUrl,
webAppUrl,
product,
profile,
}: SummaryMetadataProps) {
@@ -60,7 +60,7 @@ export default function SuccessMessage({
survey={survey}
open={showLinkModal}
setOpen={setShowLinkModal}
surveyBaseUrl={surveyBaseUrl}
webAppUrl={webAppUrl}
product={product}
profile={profile}
/>

View File

@@ -23,7 +23,7 @@ interface SummaryPageProps {
survey: TSurvey;
surveyId: string;
responses: TResponse[];
surveyBaseUrl: string;
webAppUrl: string;
product: TProduct;
profile: TProfile;
environmentTags: TTag[];
@@ -36,7 +36,7 @@ const SummaryPage = ({
survey,
surveyId,
responses,
surveyBaseUrl,
webAppUrl,
product,
profile,
environmentTags,
@@ -64,7 +64,7 @@ const SummaryPage = ({
environment={environment}
survey={survey}
surveyId={surveyId}
surveyBaseUrl={surveyBaseUrl}
webAppUrl={webAppUrl}
product={product}
profile={profile}
/>

View File

@@ -3,11 +3,7 @@ export const revalidate = REVALIDATION_INTERVAL;
import { getAnalysisData } from "@/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/data";
import SummaryPage from "@/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/summary/components/SummaryPage";
import { authOptions } from "@formbricks/lib/authOptions";
import {
OPEN_TEXT_RESPONSES_PER_PAGE,
REVALIDATION_INTERVAL,
SURVEY_BASE_URL,
} from "@formbricks/lib/constants";
import { OPEN_TEXT_RESPONSES_PER_PAGE, REVALIDATION_INTERVAL, WEBAPP_URL } from "@formbricks/lib/constants";
import { getEnvironment } from "@formbricks/lib/environment/service";
import { getProductByEnvironmentId } from "@formbricks/lib/product/service";
import { getProfile } from "@formbricks/lib/profile/service";
@@ -47,7 +43,7 @@ export default async function Page({ params }) {
responses={responses}
survey={survey}
surveyId={params.surveyId}
surveyBaseUrl={SURVEY_BASE_URL}
webAppUrl={WEBAPP_URL}
product={product}
profile={profile}
environmentTags={tags}

View File

@@ -30,7 +30,7 @@ interface SummaryHeaderProps {
surveyId: string;
environment: TEnvironment;
survey: TSurvey;
surveyBaseUrl: string;
webAppUrl: string;
product: TProduct;
profile: TProfile;
}
@@ -38,7 +38,7 @@ const SummaryHeader = ({
surveyId,
environment,
survey,
surveyBaseUrl,
webAppUrl,
product,
profile,
}: SummaryHeaderProps) => {
@@ -56,12 +56,7 @@ const SummaryHeader = ({
</div>
<div className="hidden justify-end gap-x-1.5 sm:flex">
{survey.type === "link" && (
<LinkSurveyShareButton
survey={survey}
surveyBaseUrl={surveyBaseUrl}
product={product}
profile={profile}
/>
<LinkSurveyShareButton survey={survey} webAppUrl={webAppUrl} product={product} profile={profile} />
)}
{(environment?.widgetSetupCompleted || survey.type === "link") && survey?.status !== "draft" ? (
<SurveyStatusDropdown environment={environment} survey={survey} />
@@ -87,7 +82,7 @@ const SummaryHeader = ({
<LinkSurveyShareButton
className="flex w-full justify-center p-1"
survey={survey}
surveyBaseUrl={surveyBaseUrl}
webAppUrl={webAppUrl}
product={product}
profile={profile}
/>
@@ -172,7 +167,7 @@ const SummaryHeader = ({
<SuccessMessage
environment={environment}
survey={survey}
surveyBaseUrl={surveyBaseUrl}
webAppUrl={webAppUrl}
product={product}
profile={profile}
/>

View File

@@ -35,7 +35,7 @@ interface SurveyDropDownMenuProps {
survey: TSurvey;
environment: TEnvironment;
otherEnvironment: TEnvironment;
surveyBaseUrl: string;
webAppUrl: string;
singleUseId?: string;
}
@@ -44,14 +44,14 @@ export default function SurveyDropDownMenu({
survey,
environment,
otherEnvironment,
surveyBaseUrl,
webAppUrl,
singleUseId,
}: SurveyDropDownMenuProps) {
const [isDeleteDialogOpen, setDeleteDialogOpen] = useState(false);
const [loading, setLoading] = useState(false);
const router = useRouter();
const surveyUrl = useMemo(() => surveyBaseUrl + survey.id, [survey.id, surveyBaseUrl]);
const surveyUrl = useMemo(() => webAppUrl + "/s/" + survey.id, [survey.id, webAppUrl]);
const handleDeleteSurvey = async (survey) => {
setLoading(true);

View File

@@ -2,7 +2,7 @@ import { UsageAttributesUpdater } from "@/app/(app)/components/FormbricksClient"
import SurveyDropDownMenu from "@/app/(app)/environments/[environmentId]/surveys/components/SurveyDropDownMenu";
import SurveyStarter from "@/app/(app)/environments/[environmentId]/surveys/components/SurveyStarter";
import { SurveyStatusIndicator } from "@formbricks/ui/SurveyStatusIndicator";
import { SURVEY_BASE_URL } from "@formbricks/lib/constants";
import { WEBAPP_URL } from "@formbricks/lib/constants";
import { getEnvironment, getEnvironments } from "@formbricks/lib/environment/service";
import { getProductByEnvironmentId } from "@formbricks/lib/product/service";
import { getSurveys } from "@formbricks/lib/survey/service";
@@ -111,7 +111,7 @@ export default async function SurveysList({ environmentId }: { environmentId: st
environmentId={environmentId}
environment={environment}
otherEnvironment={otherEnvironment!}
surveyBaseUrl={SURVEY_BASE_URL}
webAppUrl={WEBAPP_URL}
singleUseId={singleUseId}
/>
</div>

View File

@@ -2,7 +2,7 @@ export const revalidate = REVALIDATION_INTERVAL;
import LinkSurvey from "@/app/s/[surveyId]/components/LinkSurvey";
import SurveyInactive from "@/app/s/[surveyId]/components/SurveyInactive";
import { REVALIDATION_INTERVAL, WEBAPP_URL, SURVEY_BASE_URL } from "@formbricks/lib/constants";
import { REVALIDATION_INTERVAL, WEBAPP_URL } from "@formbricks/lib/constants";
import { getOrCreatePersonByUserId } from "@formbricks/lib/person/service";
import { getProductByEnvironmentId } from "@formbricks/lib/product/service";
import { getSurvey } from "@formbricks/lib/survey/service";
@@ -56,7 +56,7 @@ export async function generateMetadata({ params }: LinkSurveyPageProps): Promise
openGraph: {
title: survey.name,
description: "Create your own survey like this with Formbricks' open source survey suite.",
url: `${SURVEY_BASE_URL}/${survey.id}`,
url: `${WEBAPP_URL}/${survey.id}`,
siteName: "",
images: [ogImgURL],
locale: "en_US",

View File

@@ -9,8 +9,8 @@ export const env = createEnv({
server: {
WEBAPP_URL: z.string().url().optional(),
DATABASE_URL: z.string().url(),
ENCRYPTION_KEY: z.string().length(32),
FORMBRICKS_ENCRYPTION_KEY: z.string().length(24).or(z.string().length(0)),
ENCRYPTION_KEY: z.string().length(64).or(z.string().length(32)),
FORMBRICKS_ENCRYPTION_KEY: z.string().length(24).or(z.string().length(0)).optional(),
NEXTAUTH_SECRET: z.string().min(1),
NEXTAUTH_URL: z.string().url().optional(),
MAIL_FROM: z.string().email().optional(),
@@ -50,8 +50,7 @@ export const env = createEnv({
INVITE_DISABLED: z.enum(["1", "0"]).optional(),
IS_FORMBRICKS_CLOUD: z.enum(["1", "0"]).optional(),
VERCEL_URL: z.string().optional(),
SURVEY_BASE_URL: z.string().url().optional(),
SHORT_SURVEY_BASE_URL: z.string().url().optional().or(z.string().length(0)),
SHORT_URL_BASE: z.string().url().optional().or(z.string().length(0)),
GOOGLE_SHEETS_CLIENT_ID: z.string().optional(),
GOOGLE_SHEETS_CLIENT_SECRET: z.string().optional(),
GOOGLE_SHEETS_REDIRECT_URL: z.string().optional(),
@@ -94,7 +93,6 @@ export const env = createEnv({
WEBAPP_URL: process.env.WEBAPP_URL,
DATABASE_URL: process.env.DATABASE_URL,
ENCRYPTION_KEY: process.env.ENCRYPTION_KEY,
FORMBRICKS_ENCRYPTION_KEY: process.env.FORMBRICKS_ENCRYPTION_KEY,
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
MAIL_FROM: process.env.MAIL_FROM,
@@ -134,8 +132,7 @@ export const env = createEnv({
NEXT_PUBLIC_POSTHOG_API_HOST: process.env.NEXT_PUBLIC_POSTHOG_API_HOST,
FORMBRICKS_ENCRYPTION_KEY: process.env.FORMBRICKS_ENCRYPTION_KEY,
VERCEL_URL: process.env.VERCEL_URL,
SURVEY_BASE_URL: process.env.SURVEY_BASE_URL,
SHORT_SURVEY_BASE_URL: process.env.SHORT_SURVEY_BASE_URL,
SHORT_URL_BASE: process.env.SHORT_URL_BASE,
NEXT_PUBLIC_SENTRY_DSN: process.env.NEXT_PUBLIC_SENTRY_DSN,
AZUREAD_AUTH_ENABLED: process.env.AZUREAD_AUTH_ENABLED,
AZUREAD_CLIENT_ID: process.env.AZUREAD_CLIENT_ID,

View File

@@ -34,9 +34,9 @@ const nextConfig = {
async redirects() {
return [
{
source: "/api/v1/responses",
destination: "/api/v1/management/responses",
permanent: true,
source: "/i/:path*",
destination: "/:path*",
permanent: false,
},
{
source: "/api/v1/surveys",
@@ -48,6 +48,11 @@ const nextConfig = {
destination: "/api/v1/management/me",
permanent: true,
},
{
source: "/api/v1/me",
destination: "/api/v1/management/me",
permanent: true,
},
];
},
async headers() {

View File

@@ -11,32 +11,32 @@ x-database-url: &database_url postgresql://postgres:postgres@postgres:5432/formb
# NextJS Auth
# @see: https://next-auth.js.org/configuration/options#nextauth_secret
# You can use: `openssl rand -base64 32` to generate one
x-nextauth-secret: &nextauth_secret luJthrnoDpVgGakjVYlccsZ1FdlwxIWogWIsrxzoQ6E=
# You can use: `openssl rand -hex 32` to generate one
x-nextauth-secret: &nextauth_secret 10ee8bc17d40a457544cf373affbab16
# Set this to your public-facing URL, e.g., https://example.com
# You do not need the NEXTAUTH_URL environment variable in Vercel.
x-nextauth-url: &nextauth_url http://localhost:3000
# Encryption key
# You can use: `openssl rand -base64 16` to generate one
x-formbricks-encryption-key: &formbricks_encryption_key
# Necessary if email verification and password reset are enabled.
# See further below if you want to disable these features.
# You can use: `openssl rand -hex 32` to generate one
x-encryption-key: &encryption_key 1b3d888592454d23b520040950654669
x-mail-from: &mail_from
x-smtp-host: &smtp_host
x-smtp-port: &smtp_port # Enable SMTP_SECURE_ENABLED for TLS (port 465)
x-smtp-secure-enabled: &smtp_secure_enabled
x-smtp-user: &smtp_user
x-smtp-password: &smtp_password # Set the below value to your public-facing URL, e.g., https://example.com
x-smtp-password: &smtp_password
# Set the below value to your public-facing URL, e.g., https://example.com
x-survey-base-url: &survey_base_url http://localhost:3000/s
# Set the below value if you have and want to share a shorter base URL than the x-survey-base-url
x-short-url-base:
&short_url_base # Email Verification. If you enable Email Verification you have to setup SMTP-Settings, too.
# Set the below value if you have and want to share a shorter base URL than the x-survey-base-url
x-short-survey-base-url:
&short_survey_base_url # Email Verification. If you enable Email Verification you have to setup SMTP-Settings, too.
x-email-verification-disabled: &email_verification_disabled 1
@@ -54,21 +54,27 @@ x-privacy-url: &privacy_url
x-terms-url: &terms_url
x-imprint-url: &imprint_url # Configure Github Login
x-github-auth-enabled: &github_auth_enabled 0
x-github-id: &github_id
x-github-secret: &github_secret # Configure Google Login
x-google-auth-enabled: &google_auth_enabled 0
x-google-client-id: &google_client_id
x-google-client-secret: &google_client_secret # Disable Sentry warning
x-sentry-ignore-api-resolution-error: &sentry_ignore_api_resolution_error # Enable Sentry Error Tracking
x-next-public-sentry-dsn: &next_public_sentry_dsn # Cron Secret
x-cron-secret:
&cron_secret # Configure ASSET_PREFIX_URL when you want to ship JS & CSS files from a complete URL instead of the current domain
x-asset-prefix-url: &asset_prefix_url
services:
@@ -105,9 +111,8 @@ services:
SMTP_SECURE_ENABLED: *smtp_secure_enabled
SMTP_USER: *smtp_user
SMTP_PASSWORD: *smtp_password
FORMBRICKS_ENCRYPTION_KEY: *formbricks_encryption_key
SURVEY_BASE_URL: *survey_base_url
SHORT_SURVEY_BASE_URL: *short_survey_base_url
ENCRYPTION_KEY: *encryption_key
SHORT_URL_BASE: *short_url_base
PRIVACY_URL: *privacy_url
TERMS_URL: *terms_url
IMPRINT_URL: *imprint_url

View File

@@ -9,39 +9,36 @@ x-environment: &environment
# NextJS Auth
# @see: https://next-auth.js.org/configuration/options#nextauth_secret
# You can use: `openssl rand -base64 32` to generate one
# You can use: `openssl rand -hex 32` to generate one
NEXTAUTH_SECRET:
# Set this to your public-facing URL, e.g., https://example.com
# You do not need the NEXTAUTH_URL environment variable in Vercel.
NEXTAUTH_URL: http://localhost:3000
# Formbricks Encryption Key is used to generate encrypted single use URLs for Link Surveys
# You can use: $(openssl rand -base64 16) to generate one
# FORMBRICKS_ENCRYPTION_KEY:
# Encryption Key is used for 2FA & Single use URLs for Link Surveys
# You can use: $(openssl rand -hex 32) to generate one
ENCRYPTION_KEY:
# PostgreSQL password
POSTGRES_PASSWORD: postgres
# Email Configuration
MAIL_FROM:
SMTP_HOST:
SMTP_PORT:
SMTP_SECURE_ENABLED:
SMTP_USER:
SMTP_PASSWORD:
# Set the below value if you want to have another base URL apart from your Domain Name
# SURVEY_BASE_URL:
# MAIL_FROM:
# SMTP_HOST:
# SMTP_PORT:
# SMTP_SECURE_ENABLED:
# SMTP_USER:
# SMTP_PASSWORD:
# Set the below value if you have and want to use a custom URL for the links created by the Link Shortener
# SHORT_SURVEY_BASE_URL:
# SHORT_URL_BASE:
# Uncomment the below and set it to 1 to disable Email Verification for new signups
# EMAIL_VERIFICATION_DISABLED:
# Set the below to 0 to enable Email Verification for new signups (will required Email Configuration)
EMAIL_VERIFICATION_DISABLED: 1
# Uncomment the below and set it to 1 to disable Password Reset
# PASSWORD_RESET_DISABLED:
# Set the below to 0 to enable Password Reset (will required Email Configuration)
PASSWORD_RESET_DISABLED: 1
# Uncomment the below and set it to 1 to disable Signups
# SIGNUP_DISABLED:

View File

@@ -100,7 +100,7 @@ touch acme.json
chmod 600 acme.json
echo "💡 Created acme.json file with correct permissions."
# Ask the user for their email address
# Ask the user for their domain name
echo "🔗 Please enter your domain name for the SSL certificate (🚨 do NOT enter the protocol (http/https/etc)):"
read domain_name
@@ -136,143 +136,68 @@ else
smtp_secure_enabled=0
fi
if [[ -n $mail_from ]]; then
email_config=$(
cat <<EOT
MAIL_FROM: "$mail_from"
SMTP_HOST: "$smtp_host"
SMTP_PORT: "$smtp_port"
SMTP_SECURE_ENABLED: $smtp_secure_enabled
SMTP_USER: "$smtp_user"
SMTP_PASSWORD: "$smtp_password"
EOT
)
else
email_config=""
fi
echo "📥 Downloading docker-compose.yml from Formbricks GitHub repository..."
curl -o docker-compose.yml https://raw.githubusercontent.com/formbricks/formbricks/main/docker/docker-compose.yml
cat <<EOT >docker-compose.yml
version: "3.3"
x-environment: &environment
environment:
# The url of your Formbricks instance used in the admin panel
WEBAPP_URL: "https://$domain_name"
echo "🚙 Updating docker-compose.yml with your custom inputs..."
sed -i "/WEBAPP_URL:/s|WEBAPP_URL:.*|WEBAPP_URL: \"https://$domain_name\"|" docker-compose.yml
sed -i "/NEXTAUTH_URL:/s|NEXTAUTH_URL:.*|NEXTAUTH_URL: \"https://$domain_name\"|" docker-compose.yml
# PostgreSQL DB for Formbricks to connect to
DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/formbricks?schema=public"
# NextJS Auth
# @see: https://next-auth.js.org/configuration/options#nextauth_secret
# You can use: $(openssl rand -base64 32) to generate one
NEXTAUTH_SECRET:
# Set this to your public-facing URL, e.g., https://example.com
# You do not need the NEXTAUTH_URL environment variable in Vercel.
NEXTAUTH_URL: "https://$domain_name"
# Formbricks Encryption Key is used to generate encrypted single use URLs for Link Surveys
# You can use: $(openssl rand -base64 16) to generate one
FORMBRICKS_ENCRYPTION_KEY:
# PostgreSQL password
POSTGRES_PASSWORD: postgres
# Email configuration
$email_config
# Set the below value if you want to have another base URL apart from your Domain Name
# SURVEY_BASE_URL:
# Set the below value if you have and want to use a custom URL for the links created by the Link Shortener
# SHORT_SURVEY_BASE_URL:
# Uncomment the below and set it to 1 to disable Email Verification for new signups
# EMAIL_VERIFICATION_DISABLED:
# Uncomment the below and set it to 1 to disable Password Reset
# PASSWORD_RESET_DISABLED:
# Uncomment the below and set it to 1 to disable Signups
# SIGNUP_DISABLED:
# Uncomment the below and set it to 1 to disable Invites
# INVITE_DISABLED:
# Uncomment the below and set a value to have your own Privacy Page URL on the signup & login page
# PRIVACY_URL:
# Uncomment the below and set a value to have your own Terms Page URL on the auth and the surveys page
# TERMS_URL:
# Uncomment the below and set a value to have your own Imprint Page URL on the auth and the surveys page
# IMPRINT_URL:
# Uncomment the below and set to 1 if you want to enable GitHub OAuth
# GITHUB_AUTH_ENABLED:
# GITHUB_ID:
# GITHUB_SECRET:
# Uncomment the below and set to 1 if you want to enable Google OAuth
# GOOGLE_AUTH_ENABLED:
# GOOGLE_CLIENT_ID:
# GOOGLE_CLIENT_SECRET:
# Configure ASSET_PREFIX_URL when you want to ship JS & CSS files from a complete URL instead of the current domain
# ASSET_PREFIX_URL: *asset_prefix_url
services:
postgres:
restart: always
image: postgres:15-alpine
volumes:
- postgres:/var/lib/postgresql/data
<<: *environment
formbricks:
restart: always
image: formbricks/formbricks:latest
depends_on:
- postgres
labels:
- "traefik.enable=true" # Enable Traefik for this service
- "traefik.http.routers.formbricks.rule=Host(\`$domain_name\`)" # Replace your_domain_name with your actual domain or IP
- "traefik.http.routers.formbricks.entrypoints=websecure" # Use the websecure entrypoint (port 443 with TLS)
- "traefik.http.services.formbricks.loadbalancer.server.port=3000" # Forward traffic to Formbricks on port 3000
<<: *environment
traefik:
image: "traefik:v2.7"
restart: always
container_name: "traefik"
depends_on:
- formbricks
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- ./traefik.yaml:/traefik.yaml
- ./acme.json:/acme.json
- /var/run/docker.sock:/var/run/docker.sock:ro
volumes:
postgres:
driver: local
EOT
echo "🚙 Updating NEXTAUTH_SECRET in the Formbricks container..."
nextauth_secret=$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | head -c 32) && sed -i "/NEXTAUTH_SECRET:$/s/NEXTAUTH_SECRET:.*/NEXTAUTH_SECRET: $nextauth_secret/" docker-compose.yml
nextauth_secret=$(openssl rand -hex 32) && sed -i "/NEXTAUTH_SECRET:$/s/NEXTAUTH_SECRET:.*/NEXTAUTH_SECRET: $nextauth_secret/" docker-compose.yml
echo "🚗 NEXTAUTH_SECRET updated successfully!"
echo "🚙 Updating FORMBRICKS_ENCRYPTION_KEY in the Formbricks container..."
formbricks_encryption_key=$(openssl rand -base64 16 | tr -dc 'a-zA-Z0-9' | head -c 16) && sed -i "/FORMBRICKS_ENCRYPTION_KEY:$/s/FORMBRICKS_ENCRYPTION_KEY:.*/FORMBRICKS_ENCRYPTION_KEY: $formbricks_encryption_key/" docker-compose.yml
echo "🚗 FORMBRICKS_ENCRYPTION_KEY updated successfully!"
encryption_key=$(openssl rand -hex 32) && sed -i "/ENCRYPTION_KEY:$/s/ENCRYPTION_KEY:.*/ENCRYPTION_KEY: $encryption_key/" docker-compose.yml
echo "🚗 ENCRYPTION_KEY updated successfully!"
if [[ -n $mail_from ]]; then
sed -i "s|# MAIL_FROM:|MAIL_FROM: \"$mail_from\"|" docker-compose.yml
sed -i "s|# SMTP_HOST:|SMTP_HOST: \"$smtp_host\"|" docker-compose.yml
sed -i "s|# SMTP_PORT:|SMTP_PORT: \"$smtp_port\"|" docker-compose.yml
sed -i "s|# SMTP_SECURE_ENABLED:|SMTP_SECURE_ENABLED: $smtp_secure_enabled|" docker-compose.yml
sed -i "s|# SMTP_USER:|SMTP_USER: \"$smtp_user\"|" docker-compose.yml
sed -i "s|# SMTP_PASSWORD:|SMTP_PASSWORD: \"$smtp_password\"|" docker-compose.yml
fi
awk -v domain_name="$domain_name" '
/formbricks:/,/^ *$/ {
if ($0 ~ /depends_on:/) {
inserting_labels=1
}
if (inserting_labels && ($0 ~ /ports:/)) {
print " labels:"
print " - \"traefik.enable=true\" # Enable Traefik for this service"
print " - \"traefik.http.routers.formbricks.rule=Host(\`" domain_name "\`)\" # Use your actual domain or IP"
print " - \"traefik.http.routers.formbricks.entrypoints=websecure\" # Use the websecure entrypoint (port 443 with TLS)"
print " - \"traefik.http.services.formbricks.loadbalancer.server.port=3000\" # Forward traffic to Formbricks on port 3000"
inserting_labels=0
}
print
next
}
/^volumes:/ {
print " traefik:"
print " image: \"traefik:v2.7\""
print " restart: always"
print " container_name: \"traefik\""
print " depends_on:"
print " - formbricks"
print " ports:"
print " - \"80:80\""
print " - \"443:443\""
print " - \"8080:8080\""
print " volumes:"
print " - ./traefik.yaml:/traefik.yaml"
print " - ./acme.json:/acme.json"
print " - /var/run/docker.sock:/var/run/docker.sock:ro"
print ""
}
1
' docker-compose.yml >tmp.yml && mv tmp.yml docker-compose.yml
newgrp docker <<END
docker compose --env-file /dev/null up
docker compose up
echo "🔗 To edit more variables and deeper config, go to the formbricks/docker-compose.yml, edit the file, and restart the container!"

View File

@@ -11,11 +11,7 @@ export const MAU_LIMIT = IS_FORMBRICKS_CLOUD ? 9000 : 1000000;
export const WEBAPP_URL =
env.WEBAPP_URL || (env.VERCEL_URL ? `https://${env.VERCEL_URL}` : false) || "http://localhost:3000";
export const SURVEY_BASE_URL = env.SURVEY_BASE_URL ? env.SURVEY_BASE_URL + "/" : `${WEBAPP_URL}/s/`;
export const SHORT_SURVEY_BASE_URL = env.SHORT_SURVEY_BASE_URL
? env.SHORT_SURVEY_BASE_URL + "/"
: `${WEBAPP_URL}/i/`;
export const SHORT_URL_BASE = env.SHORT_URL_BASE ? env.SHORT_URL_BASE : WEBAPP_URL;
// encryption keys
export const FORMBRICKS_ENCRYPTION_KEY = env.FORMBRICKS_ENCRYPTION_KEY || undefined;

View File

@@ -53,7 +53,6 @@
"AZUREAD_TENANT_ID",
"CRON_SECRET",
"ENCRYPTION_KEY",
"FORMBRICKS_ENCRYPTION_KEY",
"DEBUG",
"GITHUB_ID",
"GITHUB_SECRET",
@@ -95,11 +94,9 @@
"NEXT_PUBLIC_FORMBRICKS_ONBOARDING_SURVEY_ID",
"NEXT_PUBLIC_FORMBRICKS_PMF_FORM_ID",
"NEXT_PUBLIC_FORMBRICKS_URL",
"FORMBRICKS_ENCRYPTION_KEY",
"IMPRINT_URL",
"NEXT_PUBLIC_SENTRY_DSN",
"SURVEY_BASE_URL",
"SHORT_SURVEY_BASE_URL",
"SHORT_URL_BASE",
"NODE_ENV",
"NEXT_PUBLIC_POSTHOG_API_HOST",
"NEXT_PUBLIC_POSTHOG_API_KEY",