chore: remove *_auth_enabled env variables (#1997)

This commit is contained in:
Matti Nannt
2024-02-07 12:35:13 +01:00
committed by GitHub
parent fd6322652b
commit 548251a2ba
9 changed files with 54 additions and 66 deletions

View File

@@ -84,17 +84,14 @@ TERMS_URL=
IMPRINT_URL=
# Configure Github Login
GITHUB_AUTH_ENABLED=0
GITHUB_ID=
GITHUB_SECRET=
# Configure Google Login
GOOGLE_AUTH_ENABLED=0
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
# Configure Azure Active Directory Login
AZUREAD_AUTH_ENABLED=0
AZUREAD_CLIENT_ID=
AZUREAD_CLIENT_SECRET=
AZUREAD_TENANT_ID=

View File

@@ -212,7 +212,7 @@ 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` |
| 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) |
@@ -229,9 +229,7 @@ These variables can be provided at the runtime i.e. in your docker-compose file.
| 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 | |
| SMTP_SECURE_ENABLED | SMTP secure connection. For using TLS, set to `1` else to `0`. | optional (required if email services are to be enabled) | | | 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) | |

View File

@@ -40,12 +40,11 @@ Integrating Google OAuth with your Formbricks instance allows users to log in us
- Ensure to specify authorized JavaScript origins and authorized redirect URIs.
<Col>
<CodeGroup title="Configuration URLs">
``` {{ title: 'Redirect & Origin URLs' }}
Authorized JavaScript origins: {WEBAPP_URL}
Authorized redirect URIs: {WEBAPP_URL}/api/auth/callback/google
```
</CodeGroup>
<CodeGroup title="Configuration URLs">
``` {{ title: "Redirect & Origin URLs" }}
Authorized JavaScript origins: {WEBAPP_URL}
Authorized redirect URIs: {WEBAPP_URL}/api/auth/callback/google ```
</CodeGroup>
</Col>
5. **Update Environment Variables in Docker**:
@@ -58,14 +57,12 @@ Authorized redirect URIs: {WEBAPP_URL}/api/auth/callback/google
```sh {{ title: 'Shell commands' }}
docker exec -it container_id /bin/bash
export GOOGLE_AUTH_ENABLED=1
export GOOGLE_CLIENT_ID=your-client-id-here
export GOOGLE_CLIENT_SECRET=your-client-secret-here
exit
```
```sh {{ title: 'env file' }}
GOOGLE_AUTH_ENABLED=1
GOOGLE_CLIENT_ID=your-client-id-here
GOOGLE_CLIENT_SECRET=your-client-secret-here
```

View File

@@ -1,6 +1,7 @@
import AuthorBox from "@/components/shared/AuthorBox";
import LayoutMdx from "@/components/shared/LayoutMdx";
import Image from "next/image";
import Container from "./container.webp";
import DockerCompose from "./docker-compose.webp";
import Docker from "./docker.webp";
@@ -9,9 +10,11 @@ import Header from "./header.webp";
import SelfHostGif from "./self-host.gif";
import SmartestPersonGif from "./smartest-person.gif";
import SuperSonicGif from "./supersonic.gif";
export const meta = {
title: "Understand Formbricks Self-Hosting",
description:"We explain how we internally built Formbricks self hosting architecture with Docker, Docker Compose, and Bash Script. It's easy and to-the-point!",
title: "Understand Formbricks Self Hosting",
description:
"We explain how we internally built Formbricks self hosting architecture with Docker, Docker Compose, and Bash Script. It's easy and to-the-point!",
date: "2024-01-23",
publishedTime: "2024-01-23T12:00:00",
authors: ["Shubham Palriwala"],
@@ -52,7 +55,6 @@ Deciding to self-host is particularly advantageous in certain scenarios:
In these situations, self-hosting offers an unmatched level of control and customization.
### What to expect from this guide?
Embark on an insightful journey into the world of Formbricks self-hosting. We'll dive deep into two key methods: the [Advanced Docker Setup](https://formbricks.com/docs/self-hosting/docker) and the [Single Script Setup](https://formbricks.com/docs/self-hosting/production). Along the way, we'll demystify several core concepts:
@@ -93,12 +95,14 @@ Docker is a container runtime that enables you to abstract your projects into re
Building on the earlier analogy, Docker can be seen as the fleet of trucks that transport these secure boxes (containers). Each truck (Docker) is equipped to carry a container, ensuring it reaches its destination intact and operates smoothly. Docker takes care of the driving, navigating through different environments (operating systems), and making sure each container is running as it should, regardless of where it's deployed.
<Note>
It's important to note that Docker is a **runtime environment** — it's responsible for running the containers, rather than being a technology that creates them. While Docker is widely used, there are other alternatives in the field, such as Podman and Containerd, which also offer container runtime capabilities.
It's important to note that Docker is a **runtime environment** — it's responsible for running the
containers, rather than being a technology that creates them. While Docker is widely used, there are other
alternatives in the field, such as Podman and Containerd, which also offer container runtime capabilities.
</Note>
### Understanding Formbricks Dockerfile
The Dockerfile for our Formbricks application is structured into two key stages - the Builder and Runner stages. Its currently hosted [here](https://github.com/formbricks/formbricks/blob/main/apps/web/Dockerfile).
The Dockerfile for our Formbricks application is structured into two key stages - the Builder and Runner stages. Its currently hosted [here](https://github.com/formbricks/formbricks/blob/main/apps/web/Dockerfile).
<CodeGroup title="Dockerfile">
@@ -204,7 +208,6 @@ CMD supercronic -quiet /app/docker/cronjobs & \
4. **Port and Volume:** Exposes port 3000 and sets up a persistent volume mapping for uploads.
5. **Application Launch:** Uses a command sequence to run
### 3. What is Docker Compose
Docker Compose is a tool designed to manage multiple containers, streamlining the process of running multi-container Docker applications. It allows for the configuration of how these containers interact, including mapping ports, creating, and sharing data volumes. This orchestration is crucial when your application comprises several interconnected containers, each with its specific role.
@@ -283,13 +286,11 @@ x-environment: &environment
# 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:
# Uncomment the below if you want to enable GitHub OAuth
# GITHUB_ID:
# GITHUB_SECRET:
# Uncomment the below and set to 1 if you want to enable Google OAuth
# GOOGLE_AUTH_ENABLED:
# Uncomment the below if you want to enable Google OAuth
# GOOGLE_CLIENT_ID:
# GOOGLE_CLIENT_SECRET:
@@ -330,28 +331,28 @@ volumes:
</CodeGroup>
- Version Specification:
- **`version: "3.3"`**: Specifies the Docker Compose file version, which determines the syntax and functionalities available.
- **`version: "3.3"`**: Specifies the Docker Compose file version, which determines the syntax and functionalities available.
- Environment Variables Setup (x-environment):
- **`x-environment: &environment`**: A reusable anchor for environment variables, detailing settings for the Formbricks instance, database connections, authentication, and optional configurations like email, OAuth, and URLs for terms/privacy.
- **`x-environment: &environment`**: A reusable anchor for environment variables, detailing settings for the Formbricks instance, database connections, authentication, and optional configurations like email, OAuth, and URLs for terms/privacy.
- Services Configuration:
1. **Postgres Service**:
- **`postgres:`**: Defines the PostgreSQL service.
- **`restart: always`**: Ensures the container restarts automatically if it stops.
- **`image: postgres:15-alpine`**: Uses the Postgres 15 image on Alpine Linux, a lightweight version.
- **`volumes: - postgres:/var/lib/postgresql/data`**: Maps a named volume **`postgres`** to persist database data.
- **`<<: *environment`**: Inherits the environment settings defined earlier.
2. **Formbricks Service**:
- **`formbricks:`**: Defines the Formbricks application service.
- **`restart: always`**: Similar to Postgres, configures the container to restart automatically.
- **`image: ghcr.io/formbricks/formbricks:latest`**: Pulls the latest Formbricks image from GitHub Container Registry.
- **`depends_on: - postgres`**: Specifies that Formbricks depends on the PostgreSQL service.
- **`ports: - 3000:3000`**: Maps port 3000 from the container to the host, allowing web access to the application.
- **`volumes: - uploads:/home/nextjs/apps/web/uploads/`**: Sets a volume for uploads.
- **`<<: *environment`**: Inherits environment settings.
1. **Postgres Service**:
- **`postgres:`**: Defines the PostgreSQL service.
- **`restart: always`**: Ensures the container restarts automatically if it stops.
- **`image: postgres:15-alpine`**: Uses the Postgres 15 image on Alpine Linux, a lightweight version.
- **`volumes: - postgres:/var/lib/postgresql/data`**: Maps a named volume **`postgres`** to persist database data.
- **`<<: *environment`**: Inherits the environment settings defined earlier.
2. **Formbricks Service**:
- **`formbricks:`**: Defines the Formbricks application service.
- **`restart: always`**: Similar to Postgres, configures the container to restart automatically.
- **`image: ghcr.io/formbricks/formbricks:latest`**: Pulls the latest Formbricks image from GitHub Container Registry.
- **`depends_on: - postgres`**: Specifies that Formbricks depends on the PostgreSQL service.
- **`ports: - 3000:3000`**: Maps port 3000 from the container to the host, allowing web access to the application.
- **`volumes: - uploads:/home/nextjs/apps/web/uploads/`**: Sets a volume for uploads.
- **`<<: *environment`**: Inherits environment settings.
- Volumes Definition:
- **`volumes:`**
- **`postgres: { driver: local }`**: Defines a local volume for PostgreSQL data, ensuring data persistence.
- **`uploads:`**: Sets up a volume for storing uploads in the Formbricks application.
- **`volumes:`**
- **`postgres: { driver: local }`**: Defines a local volume for PostgreSQL data, ensuring data persistence.
- **`uploads:`**: Sets up a volume for storing uploads in the Formbricks application.
This Docker Compose file orchestrates the Formbricks application and its database, providing a harmonized and efficient deployment setup. It highlights the ease of configuring and running a multi-container application, where each service is finely tuned and interconnected.
@@ -361,20 +362,24 @@ This Docker Compose file orchestrates the Formbricks application and its databas
className="w-full rounded-lg"
/>
<<<<<<< HEAD
Thats it! **Youve understood our Advanced Docker Setup** in the Self Hosting Stack! Congratulations! Now lets go a step further and understand our cool Single Script Setup too!
=======
Thats it! **Youve understood our Advanced Docker Setup** in the Self-Hosting Stack! Congratulations! Now lets go a step further and understand our cool Single Script Setup too!
> > > > > > > 8b1718c9b34beece65c90eb89910640648716c7e
### Quick Server Concepts before we understand our Single Script Setup
1. **Proxy**:
A proxy server acts as an intermediary between a user's computer and the internet. It's used to request resources from other servers, offering benefits like improved security and performance, and controlled access.
A proxy server acts as an intermediary between a user's computer and the internet. It's used to request resources from other servers, offering benefits like improved security and performance, and controlled access.
2. **Reverse Proxy**:
A reverse proxy sits in front of web servers and forwards client requests to those web servers. It's key for load balancing, providing SSL termination, and ensuring secure and anonymous browsing.
A reverse proxy sits in front of web servers and forwards client requests to those web servers. It's key for load balancing, providing SSL termination, and ensuring secure and anonymous browsing.
3. **SSL (Secure Sockets Layer)**:
SSL is a standard security technology for establishing an encrypted link between a web server and a browser. It ensures that all data passed between the web server and browsers remain private and integral, a must-have for securing online transactions.
SSL is a standard security technology for establishing an encrypted link between a web server and a browser. It ensures that all data passed between the web server and browsers remain private and integral, a must-have for securing online transactions.
4. **Cronjobs**:
Cronjobs are scheduled tasks that automate scripts at specified times. They're crucial for routine tasks like backups and system updates. However, managing cronjobs in Docker can be challenging due to its isolated environment.
Cronjobs are scheduled tasks that automate scripts at specified times. They're crucial for routine tasks like backups and system updates. However, managing cronjobs in Docker can be challenging due to its isolated environment.
### Struggles with running Cronjobs in Docker env

View File

@@ -48,11 +48,9 @@ x-privacy-url: &privacy_url
x-terms-url: &terms_url
x-imprint-url: &imprint_url
x-github-auth-enabled: &github_auth_enabled 0 # Configure Github Login
x-github-id: &github_id
x-github-secret: &github_secret
x-google-auth-enabled: &google_auth_enabled 0 # Configure Google Login
x-google-client-id: &google_client_id
x-google-client-secret: &google_client_secret
@@ -110,10 +108,8 @@ services:
INVITE_DISABLED: *invite_disabled
SENTRY_IGNORE_API_RESOLUTION_ERROR: *sentry_ignore_api_resolution_error
NEXT_PUBLIC_SENTRY_DSN: *next_public_sentry_dsn
GITHUB_AUTH_ENABLED: *github_auth_enabled
GITHUB_ID: *github_id
GITHUB_SECRET: *github_secret
GOOGLE_AUTH_ENABLED: *google_auth_enabled
GOOGLE_CLIENT_ID: *google_client_id
GOOGLE_CLIENT_SECRET: *google_client_secret
CRON_SECRET: *cron_secret

View File

@@ -60,12 +60,10 @@ x-environment: &environment
# 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:

View File

@@ -28,15 +28,21 @@ export const IMPRINT_URL = env.IMPRINT_URL;
export const PASSWORD_RESET_DISABLED = env.PASSWORD_RESET_DISABLED === "1";
export const EMAIL_VERIFICATION_DISABLED = env.EMAIL_VERIFICATION_DISABLED === "1";
export const GOOGLE_OAUTH_ENABLED = env.GOOGLE_AUTH_ENABLED === "1";
export const GITHUB_OAUTH_ENABLED = env.GITHUB_AUTH_ENABLED === "1";
export const AZURE_OAUTH_ENABLED = env.AZUREAD_AUTH_ENABLED === "1";
export const GOOGLE_OAUTH_ENABLED = env.GOOGLE_CLIENT_ID && env.GITHUB_SECRET ? true : false;
export const GITHUB_OAUTH_ENABLED = env.GITHUB_ID && env.GITHUB_SECRET ? true : false;
export const AZURE_OAUTH_ENABLED =
env.AZUREAD_CLIENT_ID && env.AZUREAD_CLIENT_SECRET && env.AZUREAD_TENANT_ID ? true : false;
export const GITHUB_ID = env.GITHUB_ID;
export const GITHUB_SECRET = env.GITHUB_SECRET;
export const GOOGLE_CLIENT_ID = env.GOOGLE_CLIENT_ID;
export const GOOGLE_CLIENT_SECRET = env.GOOGLE_CLIENT_SECRET;
export const AZUREAD_CLIENT_ID = env.AZUREAD_CLIENT_ID;
export const AZUREAD_CLIENT_SECRET = env.AZUREAD_CLIENT_SECRET;
export const AZUREAD_TENANT_ID = env.AZUREAD_TENANT_ID;
export const SIGNUP_ENABLED = env.SIGNUP_DISABLED !== "1";
export const INVITE_DISABLED = env.INVITE_DISABLED === "1";

View File

@@ -47,9 +47,6 @@ export const env = createEnv({
.url()
.optional()
.or(z.string().refine((str) => str === "")),
GITHUB_AUTH_ENABLED: z.enum(["1", "0"]).optional(),
GOOGLE_AUTH_ENABLED: z.enum(["1", "0"]).optional(),
AZUREAD_AUTH_ENABLED: z.enum(["1", "0"]).optional(),
INVITE_DISABLED: z.enum(["1", "0"]).optional(),
IS_FORMBRICKS_CLOUD: z.enum(["1", "0"]).optional(),
VERCEL_URL: z.string().optional(),
@@ -126,8 +123,6 @@ export const env = createEnv({
PRIVACY_URL: process.env.PRIVACY_URL,
TERMS_URL: process.env.TERMS_URL,
IMPRINT_URL: process.env.IMPRINT_URL,
GITHUB_AUTH_ENABLED: process.env.GITHUB_AUTH_ENABLED,
GOOGLE_AUTH_ENABLED: process.env.GOOGLE_AUTH_ENABLED,
GOOGLE_SHEETS_CLIENT_ID: process.env.GOOGLE_SHEETS_CLIENT_ID,
GOOGLE_SHEETS_CLIENT_SECRET: process.env.GOOGLE_SHEETS_CLIENT_SECRET,
GOOGLE_SHEETS_REDIRECT_URL: process.env.GOOGLE_SHEETS_REDIRECT_URL,
@@ -147,7 +142,6 @@ export const env = createEnv({
VERCEL_URL: process.env.VERCEL_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,
AZUREAD_CLIENT_SECRET: process.env.AZUREAD_CLIENT_SECRET,
AZUREAD_TENANT_ID: process.env.AZUREAD_TENANT_ID,

View File

@@ -58,7 +58,6 @@
"ASSET_PREFIX_URL",
"AWS_ACCESS_KEY",
"AWS_SECRET_KEY",
"AZUREAD_AUTH_ENABLED",
"AZUREAD_CLIENT_ID",
"AZUREAD_CLIENT_SECRET",
"AZUREAD_TENANT_ID",
@@ -88,8 +87,6 @@
"INTERNAL_SECRET",
"INVITE_DISABLED",
"IS_FORMBRICKS_CLOUD",
"GOOGLE_AUTH_ENABLED",
"GITHUB_AUTH_ENABLED",
"MAIL_FROM",
"NEXT_PUBLIC_DOCSEARCH_APP_ID",
"NEXT_PUBLIC_DOCSEARCH_API_KEY",