From 09f885d3652089e39f91cb38dfd8874c259ef71e Mon Sep 17 00:00:00 2001 From: Shubham Palriwala Date: Thu, 5 Oct 2023 19:44:23 +0530 Subject: [PATCH] feat: auto generate formbricks encryption key in one click setup (#953) * fix: docker env parsing & response bug when built w docker * chore: bring back env example * fix: docker compose envs are now single place defined * add: renaming of .env in docs * remove: existence of prisma_generate_data_proxy * fix: use newer env vars and a smarter way to handle existing .env file * fix: remove text to remove existing .enb * fix: remove comments, local testing, and mention of more updating via echo in prod script * fix: env ending * fix: finalllyyy the docker compose works * wip * fix: update self host docker compose * fix: echo log rename --- docker/docker-compose.yml | 13 +++++++++++++ docker/production.sh | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index ffd26180b4..2a138d228e 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -16,6 +16,10 @@ x-environment: &environment # 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: + # PostgreSQL password POSTGRES_PASSWORD: postgres @@ -27,6 +31,12 @@ x-environment: &environment SMTP_USER: SMTP_PASSWORD: + # 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: @@ -58,6 +68,9 @@ x-environment: &environment # 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 diff --git a/docker/production.sh b/docker/production.sh index 9387b34f22..4a4126b3b9 100644 --- a/docker/production.sh +++ b/docker/production.sh @@ -170,6 +170,10 @@ x-environment: &environment # 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 @@ -261,6 +265,11 @@ 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 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!" + + newgrp docker <