From b34202254050fc9d72acbaff749c5c8790626fd3 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Wed, 6 Sep 2023 08:26:56 +0000 Subject: [PATCH 01/18] chore: Updated Setup Script for Splitting Env File --- setup.sh | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index 235e1a977f7..e34ba3d55ad 100755 --- a/setup.sh +++ b/setup.sh @@ -23,7 +23,46 @@ echo -e "\e[1;38m 2. Copy the token given to you under the first paragraph, afte read -p $'\e[1;32m Please Enter Your TipTap Pro Extensions Authentication Token: \e[0m \e[1;36m' authToken +#!/bin/bash + +# Create .env files in the respective directories +touch ./web/.env +touch ./apiserver/.env +touch ./space/.env + +# Initialize empty strings for each .env file +webEnv="" +apiEnv="" +spaceEnv="" + +# Read the .env file line by line +while IFS= read -r line +do + # Check if the line is a comment + if [[ $line == \#* ]]; then + # Check which section we are in + if [[ $line == *Frontend* ]]; then + section="web" + elif [[ $line == *Backend* ]]; then + section="api" + elif [[ $line == *Space* ]]; then + section="space" + fi + else + # Add the line to the correct string + if [[ $section == "web" ]]; then + webEnv+="$line\n" + elif [[ $section == "api" ]]; then + apiEnv+="$line\n" + elif [[ $section == "space" ]]; then + spaceEnv+="$line\n" + fi + fi +done < .env + +# Write the strings to the respective .env files +echo -e $webEnv > ./web/.env +echo -e $apiEnv > ./apiserver/.env +echo -e $spaceEnv > ./space/.env -echo "@tiptap-pro:registry=https://registry.tiptap.dev/ -//registry.tiptap.dev/:_authToken=${authToken}" > .npmrc From 9c33e6401b5aad62ba62f8c8be7ede2714ea266d Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Wed, 6 Sep 2023 09:24:07 +0000 Subject: [PATCH 02/18] chore: updated dockerfile for using inproject env varaibles --- setup.sh | 5 +++-- space/Dockerfile.space | 13 +++---------- web/Dockerfile.web | 21 +-------------------- 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/setup.sh b/setup.sh index e34ba3d55ad..697df08b0c8 100755 --- a/setup.sh +++ b/setup.sh @@ -21,9 +21,10 @@ echo -e "\n\e[1;38m Instructions for generating TipTap Pro Extensions Auth Token echo -e "\e[1;38m 1. Head over to TipTap cloud's Pro Extensions Page, https://collab.tiptap.dev/pro-extensions \e[0m" echo -e "\e[1;38m 2. Copy the token given to you under the first paragraph, after 'Here it is' \e[0m \n" -read -p $'\e[1;32m Please Enter Your TipTap Pro Extensions Authentication Token: \e[0m \e[1;36m' authToken +read -p $'\e[1;32m Please Enter Your TipTap Pro Extensions Authentication Token: \e[0m \e[1;36m' authToken -#!/bin/bash +echo "@tiptap-pro:registry=https://registry.tiptap.dev/ +//registry.tiptap.dev/:_authToken=${authToken}" > .npmrc # Create .env files in the respective directories touch ./web/.env diff --git a/space/Dockerfile.space b/space/Dockerfile.space index 963dad136e4..d9e3df09c85 100644 --- a/space/Dockerfile.space +++ b/space/Dockerfile.space @@ -1,7 +1,6 @@ FROM node:18-alpine AS builder RUN apk add --no-cache libc6-compat WORKDIR /app -ENV NEXT_PUBLIC_API_BASE_URL=http://NEXT_PUBLIC_API_BASE_URL_PLACEHOLDER RUN yarn global add turbo COPY . . @@ -20,19 +19,16 @@ RUN yarn install --network-timeout 500000 COPY --from=builder /app/out/full/ . COPY turbo.json turbo.json +COPY ./space/.env .env COPY replace-env-vars.sh /usr/local/bin/ USER root RUN chmod +x /usr/local/bin/replace-env-vars.sh -ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 ARG NEXT_PUBLIC_DEPLOY_WITH_NGINX=1 - -ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL BUILT_NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL NEXT_PUBLIC_DEPLOY_WITH_NGINX=$NEXT_PUBLIC_DEPLOY_WITH_NGINX +ENV NEXT_PUBLIC_DEPLOY_WITH_NGINX=$NEXT_PUBLIC_DEPLOY_WITH_NGINX RUN yarn turbo run build --filter=space -RUN /usr/local/bin/replace-env-vars.sh http://NEXT_PUBLIC_WEBAPP_URL_PLACEHOLDER ${NEXT_PUBLIC_API_BASE_URL} space - FROM node:18-alpine AS runner WORKDIR /app @@ -48,14 +44,11 @@ COPY --from=installer --chown=captain:plane /app/space/.next/standalone ./ COPY --from=installer --chown=captain:plane /app/space/.next ./space/.next COPY --from=installer --chown=captain:plane /app/space/public ./space/public -ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 ARG NEXT_PUBLIC_DEPLOY_WITH_NGINX=1 -ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL BUILT_NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL NEXT_PUBLIC_DEPLOY_WITH_NGINX=$NEXT_PUBLIC_DEPLOY_WITH_NGINX +ENV NEXT_PUBLIC_DEPLOY_WITH_NGINX=$NEXT_PUBLIC_DEPLOY_WITH_NGINX USER root -COPY replace-env-vars.sh /usr/local/bin/ COPY start.sh /usr/local/bin/ -RUN chmod +x /usr/local/bin/replace-env-vars.sh RUN chmod +x /usr/local/bin/start.sh USER captain diff --git a/web/Dockerfile.web b/web/Dockerfile.web index 40946fa2dbd..994c2a603a4 100644 --- a/web/Dockerfile.web +++ b/web/Dockerfile.web @@ -2,7 +2,6 @@ FROM node:18-alpine AS builder RUN apk add --no-cache libc6-compat # Set working directory WORKDIR /app -ENV NEXT_PUBLIC_API_BASE_URL=http://NEXT_PUBLIC_API_BASE_URL_PLACEHOLDER RUN yarn global add turbo COPY . . @@ -14,30 +13,21 @@ FROM node:18-alpine AS installer RUN apk add --no-cache libc6-compat WORKDIR /app -ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 -ARG NEXT_PUBLIC_DEPLOY_URL=http://localhost/spaces # First install the dependencies (as they change less often) COPY .gitignore .gitignore COPY --from=builder /app/out/json/ . +COPY ./web/.env .env COPY --from=builder /app/out/yarn.lock ./yarn.lock RUN yarn install --network-timeout 500000 # Build the project COPY --from=builder /app/out/full/ . COPY turbo.json turbo.json -COPY replace-env-vars.sh /usr/local/bin/ USER root -RUN chmod +x /usr/local/bin/replace-env-vars.sh - -ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \ - BUILT_NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \ - NEXT_PUBLIC_DEPLOY_URL=$NEXT_PUBLIC_DEPLOY_URL RUN yarn turbo run build --filter=web -RUN /usr/local/bin/replace-env-vars.sh http://NEXT_PUBLIC_WEBAPP_URL_PLACEHOLDER ${NEXT_PUBLIC_API_BASE_URL} web - FROM node:18-alpine AS runner WORKDIR /app @@ -52,20 +42,11 @@ COPY --from=installer /app/web/package.json . # Automatically leverage output traces to reduce image size # https://nextjs.org/docs/advanced-features/output-file-tracing COPY --from=installer --chown=captain:plane /app/web/.next/standalone ./ - COPY --from=installer --chown=captain:plane /app/web/.next ./web/.next -ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 -ARG NEXT_PUBLIC_DEPLOY_URL=http://localhost/spaces - -ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \ - BUILT_NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \ - NEXT_PUBLIC_DEPLOY_URL=$NEXT_PUBLIC_DEPLOY_URL - USER root COPY replace-env-vars.sh /usr/local/bin/ COPY start.sh /usr/local/bin/ -RUN chmod +x /usr/local/bin/replace-env-vars.sh RUN chmod +x /usr/local/bin/start.sh USER captain From e4779c88e8db6bdbf0f9778151a9eb284b506707 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Wed, 6 Sep 2023 09:25:13 +0000 Subject: [PATCH 03/18] chore: removed husky replacement script --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index eb6a23994b1..793a1922f29 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "packages/*" ], "scripts": { - "prepare": "husky install", "build": "turbo run build", "dev": "turbo run dev", "start": "turbo run start", From 4b164eff390ad96fff89afa6328c6292b7c66a1f Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Wed, 6 Sep 2023 13:25:25 +0000 Subject: [PATCH 04/18] chore: updated shell script using sed --- setup.sh | 51 +++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/setup.sh b/setup.sh index 697df08b0c8..ea3dac57422 100755 --- a/setup.sh +++ b/setup.sh @@ -27,43 +27,38 @@ echo "@tiptap-pro:registry=https://registry.tiptap.dev/ //registry.tiptap.dev/:_authToken=${authToken}" > .npmrc # Create .env files in the respective directories -touch ./web/.env -touch ./apiserver/.env -touch ./space/.env +cp ./web/.env.example ./web/.env +cp ./space/.env.example ./space/.env +cp ./apiserver/.env.example ./apiserver/.env -# Initialize empty strings for each .env file -webEnv="" -apiEnv="" -spaceEnv="" +web_env=$(<./web/.env) +api_env=$(<./apiserver/.env) +space_env=$(<./space/.env) -# Read the .env file line by line while IFS= read -r line do - # Check if the line is a comment - if [[ $line == \#* ]]; then - # Check which section we are in - if [[ $line == *Frontend* ]]; then - section="web" - elif [[ $line == *Backend* ]]; then - section="api" - elif [[ $line == *Space* ]]; then - section="space" + if [[ $line == *=* ]]; then + key=$(echo "$line" | cut -d'=' -f1) + value=$(echo "$line" | cut -d'=' -f2-) + + if [[ $web_env == *"$key"* && $web_env != *"$value"* ]]; then + web_env=$(echo "$web_env" | sed "s#$key=.*#$line#") fi - else - # Add the line to the correct string - if [[ $section == "web" ]]; then - webEnv+="$line\n" - elif [[ $section == "api" ]]; then - apiEnv+="$line\n" - elif [[ $section == "space" ]]; then - spaceEnv+="$line\n" + + if [[ $api_env == *"$key"* && $api_env != *"$value"* ]]; then + api_env=$(echo "$api_env" | sed "s#$key=.*#$line#") + fi + + if [[ $space_env == *"$key"* && $space_env != *"$value"* ]]; then + space_env=$(echo "$space_env" | sed "s#$key=.*#$line#") fi fi done < .env # Write the strings to the respective .env files -echo -e $webEnv > ./web/.env -echo -e $apiEnv > ./apiserver/.env -echo -e $spaceEnv > ./space/.env +echo "$web_env" > ./web/.env +echo "$api_env" > ./apiserver/.env +echo "$space_env" > ./space/.env + From 0736b41f01371921526d98469c704178cddf9179 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Wed, 6 Sep 2023 13:25:49 +0000 Subject: [PATCH 05/18] chore: updated dockerfiles with removed cp statement --- space/Dockerfile.space | 8 ++------ web/Dockerfile.web | 1 - 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/space/Dockerfile.space b/space/Dockerfile.space index d9e3df09c85..f0683776be6 100644 --- a/space/Dockerfile.space +++ b/space/Dockerfile.space @@ -19,13 +19,10 @@ RUN yarn install --network-timeout 500000 COPY --from=builder /app/out/full/ . COPY turbo.json turbo.json -COPY ./space/.env .env -COPY replace-env-vars.sh /usr/local/bin/ USER root RUN chmod +x /usr/local/bin/replace-env-vars.sh -ARG NEXT_PUBLIC_DEPLOY_WITH_NGINX=1 -ENV NEXT_PUBLIC_DEPLOY_WITH_NGINX=$NEXT_PUBLIC_DEPLOY_WITH_NGINX +ENV NEXT_PUBLIC_DEPLOY_WITH_NGINX=1 RUN yarn turbo run build --filter=space @@ -44,8 +41,7 @@ COPY --from=installer --chown=captain:plane /app/space/.next/standalone ./ COPY --from=installer --chown=captain:plane /app/space/.next ./space/.next COPY --from=installer --chown=captain:plane /app/space/public ./space/public -ARG NEXT_PUBLIC_DEPLOY_WITH_NGINX=1 -ENV NEXT_PUBLIC_DEPLOY_WITH_NGINX=$NEXT_PUBLIC_DEPLOY_WITH_NGINX +ENV NEXT_PUBLIC_DEPLOY_WITH_NGINX=1 USER root COPY start.sh /usr/local/bin/ diff --git a/web/Dockerfile.web b/web/Dockerfile.web index 994c2a603a4..00d6981f3bf 100644 --- a/web/Dockerfile.web +++ b/web/Dockerfile.web @@ -17,7 +17,6 @@ WORKDIR /app # First install the dependencies (as they change less often) COPY .gitignore .gitignore COPY --from=builder /app/out/json/ . -COPY ./web/.env .env COPY --from=builder /app/out/yarn.lock ./yarn.lock RUN yarn install --network-timeout 500000 From b3767c581802cbc5063dd6d701797f12167fbc43 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Wed, 6 Sep 2023 13:27:10 +0000 Subject: [PATCH 06/18] chore: added example env for apiserver --- apiserver/.env.example | 60 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 apiserver/.env.example diff --git a/apiserver/.env.example b/apiserver/.env.example new file mode 100644 index 00000000000..d7e6fc779cc --- /dev/null +++ b/apiserver/.env.example @@ -0,0 +1,60 @@ +# Backend +# Debug value for api server use it as 0 for production use +DEBUG=0 + +# Error logs +SENTRY_DSN="" + +# Database Settings +PGUSER="plane" +PGPASSWORD="plane" +PGHOST="plane-db" +PGDATABASE="plane" +DATABASE_URL=postgresql://${PGUSER}:${PGPASSWORD}@${PGHOST}/${PGDATABASE} + +# Redis Settings +REDIS_HOST="plane-redis" +REDIS_PORT="6379" +REDIS_URL="redis://${REDIS_HOST}:6379/" + +# Email Settings +EMAIL_HOST="" +EMAIL_HOST_USER="" +EMAIL_HOST_PASSWORD="" +EMAIL_PORT=587 +EMAIL_FROM="Team Plane " +EMAIL_USE_TLS="1" +EMAIL_USE_SSL="0" + +# AWS Settings +AWS_REGION="" +AWS_ACCESS_KEY_ID="access-key" +AWS_SECRET_ACCESS_KEY="secret-key" +AWS_S3_ENDPOINT_URL="http://plane-minio:9000" +# Changing this requires change in the nginx.conf for uploads if using minio setup +AWS_S3_BUCKET_NAME="uploads" +# Maximum file upload limit +FILE_SIZE_LIMIT=5242880 + +# GPT settings +OPENAI_API_BASE="https://api.openai.com/v1" # change if using a custom endpoint +OPENAI_API_KEY="sk-" # add your openai key here +GPT_ENGINE="gpt-3.5-turbo" # use "gpt-4" if you have access + +# Github +GITHUB_CLIENT_SECRET="" # For fetching release notes + +# Settings related to Docker +DOCKERIZED=1 +# set to 1 If using the pre-configured minio setup +USE_MINIO=1 + +# Nginx Configuration +NGINX_PORT=80 + +# Default Creds +DEFAULT_EMAIL="captain@plane.so" +DEFAULT_PASSWORD="password123" + +# SignUps +ENABLE_SIGNUP="1" \ No newline at end of file From 9ec406b17daa1e65649853f6f8e229d99858a100 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Wed, 6 Sep 2023 15:47:53 +0000 Subject: [PATCH 07/18] chore: refactored secret generation for backend --- apiserver/.env.example | 4 +++- setup.sh | 43 +++++++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/apiserver/.env.example b/apiserver/.env.example index d7e6fc779cc..f538d193e41 100644 --- a/apiserver/.env.example +++ b/apiserver/.env.example @@ -57,4 +57,6 @@ DEFAULT_EMAIL="captain@plane.so" DEFAULT_PASSWORD="password123" # SignUps -ENABLE_SIGNUP="1" \ No newline at end of file +ENABLE_SIGNUP="1" + +SECRET_KEY="" \ No newline at end of file diff --git a/setup.sh b/setup.sh index ea3dac57422..cba8e1b7eb4 100755 --- a/setup.sh +++ b/setup.sh @@ -1,32 +1,15 @@ #!/bin/bash cp ./.env.example ./.env +echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1" >> ./.env +echo -e "WEB_URL=$1" >> ./.env # Export for tr error in mac export LC_ALL=C export LC_CTYPE=C - -# Generate the NEXT_PUBLIC_API_BASE_URL with given IP -echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1" >> ./.env - # Generate the SECRET_KEY that will be used by django echo -e "SECRET_KEY=\"$(tr -dc 'a-z0-9' < /dev/urandom | head -c50)\"" >> ./.env -# WEB_URL for email redirection and image saving -echo -e "WEB_URL=$1" >> ./.env - -# Generate Prompt for taking tiptap auth key -echo -e "\n\e[1;38m Instructions for generating TipTap Pro Extensions Auth Token \e[0m \n" - -echo -e "\e[1;38m 1. Head over to TipTap cloud's Pro Extensions Page, https://collab.tiptap.dev/pro-extensions \e[0m" -echo -e "\e[1;38m 2. Copy the token given to you under the first paragraph, after 'Here it is' \e[0m \n" - -read -p $'\e[1;32m Please Enter Your TipTap Pro Extensions Authentication Token: \e[0m \e[1;36m' authToken - -echo "@tiptap-pro:registry=https://registry.tiptap.dev/ -//registry.tiptap.dev/:_authToken=${authToken}" > .npmrc - -# Create .env files in the respective directories cp ./web/.env.example ./web/.env cp ./space/.env.example ./space/.env cp ./apiserver/.env.example ./apiserver/.env @@ -56,9 +39,31 @@ do done < .env # Write the strings to the respective .env files + echo "$web_env" > ./web/.env echo "$api_env" > ./apiserver/.env echo "$space_env" > ./space/.env +# Generate the NEXT_PUBLIC_API_BASE_URL with given IP + + +# WEB_URL for email redirection and image saving + + +# Generate Prompt for taking tiptap auth key +echo -e "\n\e[1;38m Instructions for generating TipTap Pro Extensions Auth Token \e[0m \n" + +echo -e "\e[1;38m 1. Head over to TipTap cloud's Pro Extensions Page, https://collab.tiptap.dev/pro-extensions \e[0m" +echo -e "\e[1;38m 2. Copy the token given to you under the first paragraph, after 'Here it is' \e[0m \n" + +read -p $'\e[1;32m Please Enter Your TipTap Pro Extensions Authentication Token: \e[0m \e[1;36m' authToken + +echo "@tiptap-pro:registry=https://registry.tiptap.dev/ +//registry.tiptap.dev/:_authToken=${authToken}" > .npmrc + + + + + From e5997fccf5ff65fce3b9b3828d27d7143b7ec4ed Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Wed, 6 Sep 2023 15:48:15 +0000 Subject: [PATCH 08/18] chore: removed replacement script --- replace-env-vars.sh | 15 --------------- space/Dockerfile.space | 1 - start.sh | 4 ---- web/Dockerfile.web | 1 - 4 files changed, 21 deletions(-) delete mode 100644 replace-env-vars.sh diff --git a/replace-env-vars.sh b/replace-env-vars.sh deleted file mode 100644 index afdc1492e41..00000000000 --- a/replace-env-vars.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -FROM=$1 -TO=$2 -DIRECTORY=$3 - -if [ "${FROM}" = "${TO}" ]; then - echo "Nothing to replace, the value is already set to ${TO}." - - exit 0 -fi - -# Only perform action if $FROM and $TO are different. -echo "Replacing all statically built instances of $FROM with this string $TO ." - -grep -R -la "${FROM}" apps/$DIRECTORY/.next | xargs -I{} sed -i "s|$FROM|$TO|g" "{}" diff --git a/space/Dockerfile.space b/space/Dockerfile.space index f0683776be6..3e1b95bd7b7 100644 --- a/space/Dockerfile.space +++ b/space/Dockerfile.space @@ -20,7 +20,6 @@ RUN yarn install --network-timeout 500000 COPY --from=builder /app/out/full/ . COPY turbo.json turbo.json USER root -RUN chmod +x /usr/local/bin/replace-env-vars.sh ENV NEXT_PUBLIC_DEPLOY_WITH_NGINX=1 diff --git a/start.sh b/start.sh index dcb97db6d3a..2685c38265b 100644 --- a/start.sh +++ b/start.sh @@ -1,9 +1,5 @@ #!/bin/sh set -x -# Replace the statically built BUILT_NEXT_PUBLIC_API_BASE_URL with run-time NEXT_PUBLIC_API_BASE_URL -# NOTE: if these values are the same, this will be skipped. -/usr/local/bin/replace-env-vars.sh "$BUILT_NEXT_PUBLIC_API_BASE_URL" "$NEXT_PUBLIC_API_BASE_URL" $2 - echo "Starting Plane Frontend.." node $1 diff --git a/web/Dockerfile.web b/web/Dockerfile.web index 00d6981f3bf..ba70f821f09 100644 --- a/web/Dockerfile.web +++ b/web/Dockerfile.web @@ -44,7 +44,6 @@ COPY --from=installer --chown=captain:plane /app/web/.next/standalone ./ COPY --from=installer --chown=captain:plane /app/web/.next ./web/.next USER root -COPY replace-env-vars.sh /usr/local/bin/ COPY start.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/start.sh From de3db659326e8552bc558202b2b47c026c228778 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Wed, 6 Sep 2023 15:49:22 +0000 Subject: [PATCH 09/18] chore: updated docker-compose with removed env variables --- docker-compose.yml | 65 +++------------------------------------------- 1 file changed, 3 insertions(+), 62 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e51f88c5568..db2564e6425 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,37 +1,5 @@ version: "3.8" -x-api-and-worker-env: &api-and-worker-env - DEBUG: ${DEBUG} - SENTRY_DSN: ${SENTRY_DSN} - DJANGO_SETTINGS_MODULE: plane.settings.production - DATABASE_URL: postgres://${PGUSER}:${PGPASSWORD}@${PGHOST}:5432/${PGDATABASE} - REDIS_URL: redis://plane-redis:6379/ - EMAIL_HOST: ${EMAIL_HOST} - EMAIL_HOST_USER: ${EMAIL_HOST_USER} - EMAIL_HOST_PASSWORD: ${EMAIL_HOST_PASSWORD} - EMAIL_PORT: ${EMAIL_PORT} - EMAIL_FROM: ${EMAIL_FROM} - EMAIL_USE_TLS: ${EMAIL_USE_TLS} - EMAIL_USE_SSL: ${EMAIL_USE_SSL} - AWS_REGION: ${AWS_REGION} - AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID} - AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY} - AWS_S3_BUCKET_NAME: ${AWS_S3_BUCKET_NAME} - AWS_S3_ENDPOINT_URL: ${AWS_S3_ENDPOINT_URL} - FILE_SIZE_LIMIT: ${FILE_SIZE_LIMIT} - WEB_URL: ${WEB_URL} - GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET} - DISABLE_COLLECTSTATIC: 1 - DOCKERIZED: 1 - OPENAI_API_BASE: ${OPENAI_API_BASE} - OPENAI_API_KEY: ${OPENAI_API_KEY} - GPT_ENGINE: ${GPT_ENGINE} - SECRET_KEY: ${SECRET_KEY} - DEFAULT_EMAIL: ${DEFAULT_EMAIL} - DEFAULT_PASSWORD: ${DEFAULT_PASSWORD} - USE_MINIO: ${USE_MINIO} - ENABLE_SIGNUP: ${ENABLE_SIGNUP} - services: plane-web: container_name: planefrontend @@ -40,23 +8,8 @@ services: dockerfile: ./web/Dockerfile.web args: DOCKER_BUILDKIT: 1 - NEXT_PUBLIC_API_BASE_URL: http://localhost:8000 - NEXT_PUBLIC_DEPLOY_URL: http://localhost/spaces restart: always command: /usr/local/bin/start.sh web/server.js web - env_file: - - .env - environment: - NEXT_PUBLIC_API_BASE_URL: ${NEXT_PUBLIC_API_BASE_URL} - NEXT_PUBLIC_DEPLOY_URL: ${NEXT_PUBLIC_DEPLOY_URL} - NEXT_PUBLIC_GOOGLE_CLIENTID: "0" - NEXT_PUBLIC_GITHUB_APP_NAME: "0" - NEXT_PUBLIC_GITHUB_ID: "0" - NEXT_PUBLIC_SENTRY_DSN: "0" - NEXT_PUBLIC_ENABLE_OAUTH: "0" - NEXT_PUBLIC_ENABLE_SENTRY: "0" - NEXT_PUBLIC_ENABLE_SESSION_RECORDER: "0" - NEXT_PUBLIC_TRACK_EVENTS: "0" depends_on: - plane-api - plane-worker @@ -68,14 +21,8 @@ services: dockerfile: ./space/Dockerfile.space args: DOCKER_BUILDKIT: 1 - NEXT_PUBLIC_DEPLOY_WITH_NGINX: 1 - NEXT_PUBLIC_API_BASE_URL: http://localhost:8000 restart: always command: /usr/local/bin/start.sh space/server.js space - env_file: - - .env - environment: - - NEXT_PUBLIC_API_BASE_URL=${NEXT_PUBLIC_API_BASE_URL} depends_on: - plane-api - plane-worker @@ -93,9 +40,7 @@ services: ports: - 8000:8000 env_file: - - .env - environment: - <<: *api-and-worker-env + - ./apiserver/.env depends_on: - plane-db - plane-redis @@ -110,9 +55,7 @@ services: restart: always command: ./bin/worker env_file: - - .env - environment: - <<: *api-and-worker-env + - ./apiserver/.env depends_on: - plane-api - plane-db @@ -128,9 +71,7 @@ services: restart: always command: ./bin/beat env_file: - - .env - environment: - <<: *api-and-worker-env + - ./apiserver/.env depends_on: - plane-api - plane-db From 01a4dbdd9d6b27276a97f6b94c0f9ef6389b1356 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Thu, 7 Sep 2023 07:31:08 +0000 Subject: [PATCH 10/18] chore: resolved comments in setup.sh and docker-compose --- docker-compose.yml | 2 -- setup.sh | 23 +++++++---------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index db2564e6425..b4dd523c059 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,8 +37,6 @@ services: DOCKER_BUILDKIT: 1 restart: always command: ./bin/takeoff - ports: - - 8000:8000 env_file: - ./apiserver/.env depends_on: diff --git a/setup.sh b/setup.sh index cba8e1b7eb4..28c30a994b9 100755 --- a/setup.sh +++ b/setup.sh @@ -1,15 +1,10 @@ #!/bin/bash cp ./.env.example ./.env -echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1" >> ./.env -echo -e "WEB_URL=$1" >> ./.env # Export for tr error in mac export LC_ALL=C export LC_CTYPE=C -# Generate the SECRET_KEY that will be used by django -echo -e "SECRET_KEY=\"$(tr -dc 'a-z0-9' < /dev/urandom | head -c50)\"" >> ./.env - cp ./web/.env.example ./web/.env cp ./space/.env.example ./space/.env cp ./apiserver/.env.example ./apiserver/.env @@ -44,12 +39,11 @@ echo "$web_env" > ./web/.env echo "$api_env" > ./apiserver/.env echo "$space_env" > ./space/.env +# Generate the SECRET_KEY that will be used by django +echo -e "SECRET_KEY=\"$(tr -dc 'a-z0-9' < /dev/urandom | head -c50)\"" >> ./apiserver/.env -# Generate the NEXT_PUBLIC_API_BASE_URL with given IP - - -# WEB_URL for email redirection and image saving - +echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./web/.env +echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./space/.env # Generate Prompt for taking tiptap auth key echo -e "\n\e[1;38m Instructions for generating TipTap Pro Extensions Auth Token \e[0m \n" @@ -60,10 +54,7 @@ echo -e "\e[1;38m 2. Copy the token given to you under the first paragraph, afte read -p $'\e[1;32m Please Enter Your TipTap Pro Extensions Authentication Token: \e[0m \e[1;36m' authToken echo "@tiptap-pro:registry=https://registry.tiptap.dev/ -//registry.tiptap.dev/:_authToken=${authToken}" > .npmrc - - - - - +//registry.tiptap.dev/:_authToken=${authToken}" > ./web/.npmrc +echo "@tiptap-pro:registry=https://registry.tiptap.dev/ +//registry.tiptap.dev/:_authToken=${authToken}" > ./space/.npmrc \ No newline at end of file From 011118f2147d0960546a9f11ae96db06c281f4ab Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Thu, 7 Sep 2023 07:33:32 +0000 Subject: [PATCH 11/18] chore: removed secret key placeholder in apiserver example env --- apiserver/.env.example | 2 -- 1 file changed, 2 deletions(-) diff --git a/apiserver/.env.example b/apiserver/.env.example index f538d193e41..a2a214fe628 100644 --- a/apiserver/.env.example +++ b/apiserver/.env.example @@ -58,5 +58,3 @@ DEFAULT_PASSWORD="password123" # SignUps ENABLE_SIGNUP="1" - -SECRET_KEY="" \ No newline at end of file From cfc9536c15ff7a936faa5b7e87687c81f2d97f1c Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Thu, 7 Sep 2023 10:04:15 +0000 Subject: [PATCH 12/18] chore: updated root env for project less env variables --- .env.example | 52 ---------------------------------------------- docker-compose.yml | 7 ------- 2 files changed, 59 deletions(-) diff --git a/.env.example b/.env.example index 1d95c56a067..082aa753b80 100644 --- a/.env.example +++ b/.env.example @@ -1,36 +1,3 @@ -# Frontend -# Extra image domains that need to be added for Next Image -NEXT_PUBLIC_EXTRA_IMAGE_DOMAINS= -# Google Client ID for Google OAuth -NEXT_PUBLIC_GOOGLE_CLIENTID="" -# Github ID for Github OAuth -NEXT_PUBLIC_GITHUB_ID="" -# Github App Name for GitHub Integration -NEXT_PUBLIC_GITHUB_APP_NAME="" -# Sentry DSN for error monitoring -NEXT_PUBLIC_SENTRY_DSN="" -# Enable/Disable OAUTH - default 0 for selfhosted instance -NEXT_PUBLIC_ENABLE_OAUTH=0 -# Enable/Disable sentry -NEXT_PUBLIC_ENABLE_SENTRY=0 -# Enable/Disable session recording -NEXT_PUBLIC_ENABLE_SESSION_RECORDER=0 -# Enable/Disable event tracking -NEXT_PUBLIC_TRACK_EVENTS=0 -# Slack for Slack Integration -NEXT_PUBLIC_SLACK_CLIENT_ID="" -# For Telemetry, set it to "app.plane.so" -NEXT_PUBLIC_PLAUSIBLE_DOMAIN="" -# public boards deploy url -NEXT_PUBLIC_DEPLOY_URL="" - -# Backend -# Debug value for api server use it as 0 for production use -DEBUG=0 - -# Error logs -SENTRY_DSN="" - # Database Settings PGUSER="plane" PGPASSWORD="plane" @@ -43,15 +10,6 @@ REDIS_HOST="plane-redis" REDIS_PORT="6379" REDIS_URL="redis://${REDIS_HOST}:6379/" -# Email Settings -EMAIL_HOST="" -EMAIL_HOST_USER="" -EMAIL_HOST_PASSWORD="" -EMAIL_PORT=587 -EMAIL_FROM="Team Plane " -EMAIL_USE_TLS="1" -EMAIL_USE_SSL="0" - # AWS Settings AWS_REGION="" AWS_ACCESS_KEY_ID="access-key" @@ -67,9 +25,6 @@ OPENAI_API_BASE="https://api.openai.com/v1" # change if using a custom endpoint OPENAI_API_KEY="sk-" # add your openai key here GPT_ENGINE="gpt-3.5-turbo" # use "gpt-4" if you have access -# Github -GITHUB_CLIENT_SECRET="" # For fetching release notes - # Settings related to Docker DOCKERIZED=1 # set to 1 If using the pre-configured minio setup @@ -78,10 +33,3 @@ USE_MINIO=1 # Nginx Configuration NGINX_PORT=80 -# Default Creds -DEFAULT_EMAIL="captain@plane.so" -DEFAULT_PASSWORD="password123" - -# SignUps -ENABLE_SIGNUP="1" -# Auto generated and Required that will be generated from setup.sh diff --git a/docker-compose.yml b/docker-compose.yml index b4dd523c059..5bb240d40b1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -85,9 +85,6 @@ services: env_file: - .env environment: - POSTGRES_USER: ${PGUSER} - POSTGRES_DB: ${PGDATABASE} - POSTGRES_PASSWORD: ${PGPASSWORD} PGDATA: /var/lib/postgresql/data plane-redis: @@ -104,8 +101,6 @@ services: command: server /export --console-address ":9090" volumes: - uploads:/export - env_file: - - .env environment: MINIO_ROOT_USER: ${AWS_ACCESS_KEY_ID} MINIO_ROOT_PASSWORD: ${AWS_SECRET_ACCESS_KEY} @@ -128,8 +123,6 @@ services: restart: always ports: - ${NGINX_PORT}:80 - env_file: - - .env environment: FILE_SIZE_LIMIT: ${FILE_SIZE_LIMIT:-5242880} BUCKET_NAME: ${AWS_S3_BUCKET_NAME:-uploads} From dd7d614b8da20f52edaa442f8e13a09c14ed0159 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Thu, 7 Sep 2023 10:04:48 +0000 Subject: [PATCH 13/18] chore: removed project level env update from root env logic --- setup.sh | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/setup.sh b/setup.sh index 28c30a994b9..d1e4aac3e18 100755 --- a/setup.sh +++ b/setup.sh @@ -9,36 +9,6 @@ cp ./web/.env.example ./web/.env cp ./space/.env.example ./space/.env cp ./apiserver/.env.example ./apiserver/.env -web_env=$(<./web/.env) -api_env=$(<./apiserver/.env) -space_env=$(<./space/.env) - -while IFS= read -r line -do - if [[ $line == *=* ]]; then - key=$(echo "$line" | cut -d'=' -f1) - value=$(echo "$line" | cut -d'=' -f2-) - - if [[ $web_env == *"$key"* && $web_env != *"$value"* ]]; then - web_env=$(echo "$web_env" | sed "s#$key=.*#$line#") - fi - - if [[ $api_env == *"$key"* && $api_env != *"$value"* ]]; then - api_env=$(echo "$api_env" | sed "s#$key=.*#$line#") - fi - - if [[ $space_env == *"$key"* && $space_env != *"$value"* ]]; then - space_env=$(echo "$space_env" | sed "s#$key=.*#$line#") - fi - fi -done < .env - -# Write the strings to the respective .env files - -echo "$web_env" > ./web/.env -echo "$api_env" > ./apiserver/.env -echo "$space_env" > ./space/.env - # Generate the SECRET_KEY that will be used by django echo -e "SECRET_KEY=\"$(tr -dc 'a-z0-9' < /dev/urandom | head -c50)\"" >> ./apiserver/.env @@ -54,7 +24,4 @@ echo -e "\e[1;38m 2. Copy the token given to you under the first paragraph, afte read -p $'\e[1;32m Please Enter Your TipTap Pro Extensions Authentication Token: \e[0m \e[1;36m' authToken echo "@tiptap-pro:registry=https://registry.tiptap.dev/ -//registry.tiptap.dev/:_authToken=${authToken}" > ./web/.npmrc - -echo "@tiptap-pro:registry=https://registry.tiptap.dev/ -//registry.tiptap.dev/:_authToken=${authToken}" > ./space/.npmrc \ No newline at end of file +//registry.tiptap.dev/:_authToken=${authToken}" > .npmrc \ No newline at end of file From fdb389b2e9ff1c9db543b0ff4bf78a0510cf63fb Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Sun, 10 Sep 2023 15:38:47 +0000 Subject: [PATCH 14/18] chore: updated API_BASE_URL in .env.example --- space/.env.example | 2 +- web/.env.example | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/space/.env.example b/space/.env.example index 238f70854ef..bd0318df4eb 100644 --- a/space/.env.example +++ b/space/.env.example @@ -1,5 +1,5 @@ # Base url for the API requests -NEXT_PUBLIC_API_BASE_URL="" +NEXT_PUBLIC_API_BASE_URL="http://localhost:8000" # Public boards deploy URL NEXT_PUBLIC_DEPLOY_URL="" # Google Client ID for Google OAuth diff --git a/web/.env.example b/web/.env.example index 50a6209b2a2..bae67ab08df 100644 --- a/web/.env.example +++ b/web/.env.example @@ -1,5 +1,5 @@ # Base url for the API requests -NEXT_PUBLIC_API_BASE_URL="" +NEXT_PUBLIC_API_BASE_URL="http://localhost:8000" # Extra image domains that need to be added for Next Image NEXT_PUBLIC_EXTRA_IMAGE_DOMAINS= # Google Client ID for Google OAuth From e92812ae44188c0d9454403e5aa823fe43e5863e Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Sun, 10 Sep 2023 15:44:08 +0000 Subject: [PATCH 15/18] chore: restored docker argument as env NEXT_PUBLIC_API_BASE_URL --- docker-compose.yml | 2 ++ space/Dockerfile.space | 12 ++++++++++-- web/Dockerfile.web | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5bb240d40b1..448346239eb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,7 @@ services: dockerfile: ./web/Dockerfile.web args: DOCKER_BUILDKIT: 1 + NEXT_PUBLIC_API_BASE_URL: "http://localhost:8000" restart: always command: /usr/local/bin/start.sh web/server.js web depends_on: @@ -21,6 +22,7 @@ services: dockerfile: ./space/Dockerfile.space args: DOCKER_BUILDKIT: 1 + NEXT_PUBLIC_API_BASE_URL: http://localhost:8000 restart: always command: /usr/local/bin/start.sh space/server.js space depends_on: diff --git a/space/Dockerfile.space b/space/Dockerfile.space index 3e1b95bd7b7..453d3b66302 100644 --- a/space/Dockerfile.space +++ b/space/Dockerfile.space @@ -21,7 +21,11 @@ COPY --from=builder /app/out/full/ . COPY turbo.json turbo.json USER root -ENV NEXT_PUBLIC_DEPLOY_WITH_NGINX=1 +ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 +ARG NEXT_PUBLIC_DEPLOY_WITH_NGINX=1 + +ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL +ENV NEXT_PUBLIC_DEPLOY_WITH_NGINX=$NEXT_PUBLIC_DEPLOY_WITH_NGINX RUN yarn turbo run build --filter=space @@ -40,7 +44,11 @@ COPY --from=installer --chown=captain:plane /app/space/.next/standalone ./ COPY --from=installer --chown=captain:plane /app/space/.next ./space/.next COPY --from=installer --chown=captain:plane /app/space/public ./space/public -ENV NEXT_PUBLIC_DEPLOY_WITH_NGINX=1 +ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 +ARG NEXT_PUBLIC_DEPLOY_WITH_NGINX=1 + +ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL +ENV NEXT_PUBLIC_DEPLOY_WITH_NGINX=$NEXT_PUBLIC_DEPLOY_WITH_NGINX USER root COPY start.sh /usr/local/bin/ diff --git a/web/Dockerfile.web b/web/Dockerfile.web index ba70f821f09..a0250e0baf7 100644 --- a/web/Dockerfile.web +++ b/web/Dockerfile.web @@ -13,6 +13,7 @@ FROM node:18-alpine AS installer RUN apk add --no-cache libc6-compat WORKDIR /app +ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 # First install the dependencies (as they change less often) COPY .gitignore .gitignore @@ -24,6 +25,7 @@ RUN yarn install --network-timeout 500000 COPY --from=builder /app/out/full/ . COPY turbo.json turbo.json USER root +ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL RUN yarn turbo run build --filter=web @@ -43,6 +45,9 @@ COPY --from=installer /app/web/package.json . COPY --from=installer --chown=captain:plane /app/web/.next/standalone ./ COPY --from=installer --chown=captain:plane /app/web/.next ./web/.next +ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 +ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL + USER root COPY start.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/start.sh From c0b83d83128d59f9255abb3fdfd5ff689bf096b5 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Sun, 10 Sep 2023 16:53:05 +0000 Subject: [PATCH 16/18] chore: added pg missing env variables --- docker-compose.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 448346239eb..f1db7eda86a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -87,6 +87,9 @@ services: env_file: - .env environment: + POSTGRES_USER: ${PGUSER} + POSTGRES_DB: ${PGDATABASE} + POSTGRES_PASSWORD: ${PGPASSWORD} PGDATA: /var/lib/postgresql/data plane-redis: From 30101076a24dad51a3f02ce1b296a8d1b63b21aa Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Tue, 12 Sep 2023 18:12:44 +0530 Subject: [PATCH 17/18] [chore] Updated web and deploy backend configuration for reverse proxy & decoupled Plane Deploy URL generation for web (#2135) * chore: removed api url build arg from compose * chore: set public api default argument to black string for self hosted * chore: updated web services to accept blank string as API URL * chore: added env variables for pg compose service * chore: modified space app services to use accept empty string as api base * chore: conditionally trigger web url value based on argument * fix: made web to use identical host with spaces suffix on absense of Deploy URL for deploy * chore: added example env for PUBLIC_DEPLOY Env * chore: updated web dockerfile with addition as PLANE_DEPLOY Argument * API BASE URL global update * API BASE URL replace with api server * api base url fixes * typo fixes --------- Co-authored-by: sriram veeraghanta --- docker-compose.yml | 2 -- setup.sh | 8 +++-- space/Dockerfile.space | 4 +-- space/helpers/common.helper.ts | 2 ++ space/services/authentication.service.ts | 3 +- space/services/file.service.ts | 6 ++-- space/services/issue.service.ts | 3 +- space/services/project.service.ts | 3 +- space/services/user.service.ts | 3 +- web/.env.example | 2 +- web/Dockerfile.web | 8 +++-- .../project/publish-project/modal.tsx | 6 +++- web/helpers/common.helper.ts | 5 +++ web/layouts/app-layout/app-header.tsx | 6 +++- web/lib/auth.ts | 33 +++++++++---------- web/services/ai.service.ts | 8 ++--- web/services/analytics.service.ts | 5 ++- web/services/app-installations.service.ts | 5 ++- web/services/authentication.service.ts | 5 ++- web/services/cycles.service.ts | 6 ++-- web/services/estimates.service.ts | 5 ++- web/services/file.service.ts | 5 ++- web/services/inbox.service.ts | 5 ++- web/services/integration/csv.services.ts | 6 ++-- web/services/integration/github.service.ts | 3 +- web/services/integration/index.ts | 5 ++- web/services/integration/jira.service.ts | 4 +-- web/services/issues.service.ts | 5 ++- web/services/modules.service.ts | 4 +-- web/services/notifications.service.ts | 7 ++-- web/services/pages.service.ts | 6 ++-- web/services/project-publish.service.ts | 5 ++- web/services/project.service.ts | 6 ++-- web/services/reaction.service.ts | 6 ++-- web/services/state.service.ts | 6 ++-- web/services/user.service.ts | 4 +-- web/services/views.service.ts | 4 ++- web/services/workspace.service.ts | 7 ++-- 38 files changed, 108 insertions(+), 108 deletions(-) create mode 100644 space/helpers/common.helper.ts diff --git a/docker-compose.yml b/docker-compose.yml index f1db7eda86a..e3c1b37be27 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,6 @@ services: dockerfile: ./web/Dockerfile.web args: DOCKER_BUILDKIT: 1 - NEXT_PUBLIC_API_BASE_URL: "http://localhost:8000" restart: always command: /usr/local/bin/start.sh web/server.js web depends_on: @@ -22,7 +21,6 @@ services: dockerfile: ./space/Dockerfile.space args: DOCKER_BUILDKIT: 1 - NEXT_PUBLIC_API_BASE_URL: http://localhost:8000 restart: always command: /usr/local/bin/start.sh space/server.js space depends_on: diff --git a/setup.sh b/setup.sh index d1e4aac3e18..940fb8b4d22 100755 --- a/setup.sh +++ b/setup.sh @@ -12,8 +12,12 @@ cp ./apiserver/.env.example ./apiserver/.env # Generate the SECRET_KEY that will be used by django echo -e "SECRET_KEY=\"$(tr -dc 'a-z0-9' < /dev/urandom | head -c50)\"" >> ./apiserver/.env -echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./web/.env -echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./space/.env +if [ -n "$1" ] +then + echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./web/.env + echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./space/.env +fi + # Generate Prompt for taking tiptap auth key echo -e "\n\e[1;38m Instructions for generating TipTap Pro Extensions Auth Token \e[0m \n" diff --git a/space/Dockerfile.space b/space/Dockerfile.space index 453d3b66302..12c3091349e 100644 --- a/space/Dockerfile.space +++ b/space/Dockerfile.space @@ -21,7 +21,7 @@ COPY --from=builder /app/out/full/ . COPY turbo.json turbo.json USER root -ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 +ARG NEXT_PUBLIC_API_BASE_URL="" ARG NEXT_PUBLIC_DEPLOY_WITH_NGINX=1 ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL @@ -44,7 +44,7 @@ COPY --from=installer --chown=captain:plane /app/space/.next/standalone ./ COPY --from=installer --chown=captain:plane /app/space/.next ./space/.next COPY --from=installer --chown=captain:plane /app/space/public ./space/public -ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 +ARG NEXT_PUBLIC_API_BASE_URL="" ARG NEXT_PUBLIC_DEPLOY_WITH_NGINX=1 ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL diff --git a/space/helpers/common.helper.ts b/space/helpers/common.helper.ts new file mode 100644 index 00000000000..d96c342b582 --- /dev/null +++ b/space/helpers/common.helper.ts @@ -0,0 +1,2 @@ +export const API_BASE_URL = + process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"; diff --git a/space/services/authentication.service.ts b/space/services/authentication.service.ts index a6f1ec90fb1..4d861994f0f 100644 --- a/space/services/authentication.service.ts +++ b/space/services/authentication.service.ts @@ -1,9 +1,10 @@ // services import APIService from "services/api.service"; +import { API_BASE_URL } from "helpers/common.helper"; class AuthService extends APIService { constructor() { - super(process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async emailLogin(data: any) { diff --git a/space/services/file.service.ts b/space/services/file.service.ts index 5ef34fc760c..d9783d29c8f 100644 --- a/space/services/file.service.ts +++ b/space/services/file.service.ts @@ -1,7 +1,5 @@ -// services import APIService from "services/api.service"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; interface UnSplashImage { id: string; @@ -29,7 +27,7 @@ interface UnSplashImageUrls { class FileServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async uploadFile(workspaceSlug: string, file: FormData): Promise { diff --git a/space/services/issue.service.ts b/space/services/issue.service.ts index 03a94654ba2..591db25ca04 100644 --- a/space/services/issue.service.ts +++ b/space/services/issue.service.ts @@ -1,9 +1,10 @@ // services import APIService from "services/api.service"; +import { API_BASE_URL } from "helpers/common.helper"; class IssueService extends APIService { constructor() { - super(process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async getPublicIssues(workspace_slug: string, project_slug: string, params: any): Promise { diff --git a/space/services/project.service.ts b/space/services/project.service.ts index 291a5f3230f..0d6eca951b4 100644 --- a/space/services/project.service.ts +++ b/space/services/project.service.ts @@ -1,9 +1,10 @@ // services import APIService from "services/api.service"; +import { API_BASE_URL } from "helpers/common.helper"; class ProjectService extends APIService { constructor() { - super(process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async getProjectSettings(workspace_slug: string, project_slug: string): Promise { diff --git a/space/services/user.service.ts b/space/services/user.service.ts index 9a324bb9577..21e9f941e59 100644 --- a/space/services/user.service.ts +++ b/space/services/user.service.ts @@ -1,9 +1,10 @@ // services import APIService from "services/api.service"; +import { API_BASE_URL } from "helpers/common.helper"; class UserService extends APIService { constructor() { - super(process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async currentUser(): Promise { diff --git a/web/.env.example b/web/.env.example index bae67ab08df..224a80bbfc7 100644 --- a/web/.env.example +++ b/web/.env.example @@ -23,4 +23,4 @@ NEXT_PUBLIC_SLACK_CLIENT_ID="" # For Telemetry, set it to "app.plane.so" NEXT_PUBLIC_PLAUSIBLE_DOMAIN="" # Public boards deploy URL -NEXT_PUBLIC_DEPLOY_URL="" \ No newline at end of file +NEXT_PUBLIC_DEPLOY_URL="http://localhost:3000/spaces" \ No newline at end of file diff --git a/web/Dockerfile.web b/web/Dockerfile.web index a0250e0baf7..d9260e61d8b 100644 --- a/web/Dockerfile.web +++ b/web/Dockerfile.web @@ -13,7 +13,8 @@ FROM node:18-alpine AS installer RUN apk add --no-cache libc6-compat WORKDIR /app -ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 +ARG NEXT_PUBLIC_API_BASE_URL="" +ARG NEXT_PUBLIC_DEPLOY_URL="" # First install the dependencies (as they change less often) COPY .gitignore .gitignore @@ -26,6 +27,7 @@ COPY --from=builder /app/out/full/ . COPY turbo.json turbo.json USER root ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL +ENV NEXT_PUBLIC_DEPLOY_URL=$NEXT_PUBLIC_DEPLOY_URL RUN yarn turbo run build --filter=web @@ -45,8 +47,10 @@ COPY --from=installer /app/web/package.json . COPY --from=installer --chown=captain:plane /app/web/.next/standalone ./ COPY --from=installer --chown=captain:plane /app/web/.next ./web/.next -ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 +ARG NEXT_PUBLIC_API_BASE_URL="" +ARG NEXT_PUBLIC_DEPLOY_URL="" ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL +ENV NEXT_PUBLIC_DEPLOY_URL=$NEXT_PUBLIC_DEPLOY_URL USER root COPY start.sh /usr/local/bin/ diff --git a/web/components/project/publish-project/modal.tsx b/web/components/project/publish-project/modal.tsx index 173a5242c32..56ed10ee001 100644 --- a/web/components/project/publish-project/modal.tsx +++ b/web/components/project/publish-project/modal.tsx @@ -63,7 +63,11 @@ export const PublishProjectModal: React.FC = observer(() => { const [isUnpublishing, setIsUnpublishing] = useState(false); const [isUpdateRequired, setIsUpdateRequired] = useState(false); - const plane_deploy_url = process.env.NEXT_PUBLIC_DEPLOY_URL ?? "http://localhost:4000"; + let plane_deploy_url = process.env.NEXT_PUBLIC_DEPLOY_URL; + + if (typeof window !== 'undefined' && !plane_deploy_url) { + plane_deploy_url= window.location.protocol + "//" + window.location.host + "/spaces"; + } const router = useRouter(); const { workspaceSlug } = router.query; diff --git a/web/helpers/common.helper.ts b/web/helpers/common.helper.ts index 4220a7174ce..0829863c9fe 100644 --- a/web/helpers/common.helper.ts +++ b/web/helpers/common.helper.ts @@ -16,3 +16,8 @@ export const debounce = (func: any, wait: number, immediate: boolean = false) => if (callNow) func(...args); }; }; + +export const API_BASE_URL = + process.env.NEXT_PUBLIC_API_BASE_URL !== undefined + ? process.env.NEXT_PUBLIC_API_BASE_URL + : "http://localhost:8000"; diff --git a/web/layouts/app-layout/app-header.tsx b/web/layouts/app-layout/app-header.tsx index f2fbdc78c3b..27c52f654f7 100644 --- a/web/layouts/app-layout/app-header.tsx +++ b/web/layouts/app-layout/app-header.tsx @@ -17,7 +17,11 @@ type Props = { }; const { NEXT_PUBLIC_DEPLOY_URL } = process.env; -const plane_deploy_url = NEXT_PUBLIC_DEPLOY_URL ? NEXT_PUBLIC_DEPLOY_URL : "http://localhost:3001"; +let plane_deploy_url = NEXT_PUBLIC_DEPLOY_URL + +if (typeof window !== 'undefined' && !plane_deploy_url) { + plane_deploy_url= window.location.protocol + "//" + window.location.host + "/spaces"; +} const Header: React.FC = ({ breadcrumbs, left, right, setToggleSidebar, noHeader }) => { const { projectDetails } = useProjectDetails(); diff --git a/web/lib/auth.ts b/web/lib/auth.ts index 47a52663d1d..56cfab9ae78 100644 --- a/web/lib/auth.ts +++ b/web/lib/auth.ts @@ -2,6 +2,8 @@ import { convertCookieStringToObject } from "./cookie"; // types import type { IProjectMember, IUser, IWorkspace, IWorkspaceMember } from "types"; +// helper +import { API_BASE_URL } from "helpers/common.helper"; export const requiredAuth = async (cookie?: string) => { const cookies = convertCookieStringToObject(cookie); @@ -9,12 +11,10 @@ export const requiredAuth = async (cookie?: string) => { if (!token) return null; - const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.plane.so"; - let user: IUser | null = null; try { - const data = await fetch(`${baseUrl}/api/users/me/`, { + const data = await fetch(`${API_BASE_URL}/api/users/me/`, { method: "GET", headers: { "Content-Type": "application/json", @@ -41,13 +41,11 @@ export const requiredAdmin = async (workspaceSlug: string, projectId: string, co const cookies = convertCookieStringToObject(cookie); const token = cookies?.accessToken; - const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.plane.so"; - let memberDetail: IProjectMember | null = null; try { const data = await fetch( - `${baseUrl}/api/workspaces/${workspaceSlug}/projects/${projectId}/project-members/me/`, + `${API_BASE_URL}/api/workspaces/${workspaceSlug}/projects/${projectId}/project-members/me/`, { method: "GET", headers: { @@ -75,17 +73,18 @@ export const requiredWorkspaceAdmin = async (workspaceSlug: string, cookie?: str const cookies = convertCookieStringToObject(cookie); const token = cookies?.accessToken; - const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.plane.so"; - let memberDetail: IWorkspaceMember | null = null; try { - const data = await fetch(`${baseUrl}/api/workspaces/${workspaceSlug}/workspace-members/me/`, { - method: "GET", - headers: { - Authorization: `Bearer ${token}`, - }, - }) + const data = await fetch( + `${API_BASE_URL}/api/workspaces/${workspaceSlug}/workspace-members/me/`, + { + method: "GET", + headers: { + Authorization: `Bearer ${token}`, + }, + } + ) .then((res) => res.json()) .then((data) => data); @@ -119,13 +118,11 @@ export const homePageRedirect = async (cookie?: string) => { let workspaces: IWorkspace[] = []; - const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.plane.so"; - const cookies = convertCookieStringToObject(cookie); const token = cookies?.accessToken; try { - const data = await fetch(`${baseUrl}/api/users/me/workspaces/`, { + const data = await fetch(`${API_BASE_URL}/api/users/me/workspaces/`, { method: "GET", headers: { "Content-Type": "application/json", @@ -166,7 +163,7 @@ export const homePageRedirect = async (cookie?: string) => { }; } - const invitations = await fetch(`${baseUrl}/api/users/me/invitations/workspaces/`, { + const invitations = await fetch(`${API_BASE_URL}/api/users/me/invitations/workspaces/`, { method: "GET", headers: { "Content-Type": "application/json", diff --git a/web/services/ai.service.ts b/web/services/ai.service.ts index ecb1ada52d1..33b59f3df24 100644 --- a/web/services/ai.service.ts +++ b/web/services/ai.service.ts @@ -1,18 +1,16 @@ -// services import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - // types import { ICurrentUserResponse, IGptResponse } from "types"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +// helpers +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class AiServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async createGptTask( diff --git a/web/services/analytics.service.ts b/web/services/analytics.service.ts index 0b38f8c570d..66b6569e807 100644 --- a/web/services/analytics.service.ts +++ b/web/services/analytics.service.ts @@ -8,12 +8,11 @@ import { IExportAnalyticsFormData, ISaveAnalyticsFormData, } from "types"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; class AnalyticsServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async getAnalytics(workspaceSlug: string, params: IAnalyticsParams): Promise { diff --git a/web/services/app-installations.service.ts b/web/services/app-installations.service.ts index dea6fa421cf..8b18cddfcae 100644 --- a/web/services/app-installations.service.ts +++ b/web/services/app-installations.service.ts @@ -1,12 +1,11 @@ // services import axios from "axios"; import APIService from "services/api.service"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; class AppInstallationsService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async addInstallationApp(workspaceSlug: string, provider: string, data: any): Promise { diff --git a/web/services/authentication.service.ts b/web/services/authentication.service.ts index e4a33bff8a0..58eaa2aff8f 100644 --- a/web/services/authentication.service.ts +++ b/web/services/authentication.service.ts @@ -1,12 +1,11 @@ // services import APIService from "services/api.service"; import { ICurrentUserResponse } from "types"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; class AuthService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async emailLogin(data: any) { diff --git a/web/services/cycles.service.ts b/web/services/cycles.service.ts index 89cd50a2fcc..e0e42c68741 100644 --- a/web/services/cycles.service.ts +++ b/web/services/cycles.service.ts @@ -1,18 +1,16 @@ // services import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - // types import type { CycleDateCheckData, ICurrentUserResponse, ICycle, IIssue } from "types"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class ProjectCycleServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async createCycle( diff --git a/web/services/estimates.service.ts b/web/services/estimates.service.ts index 8b0fe25f4ec..eaa49e57ccb 100644 --- a/web/services/estimates.service.ts +++ b/web/services/estimates.service.ts @@ -3,15 +3,14 @@ import APIService from "services/api.service"; // types import type { ICurrentUserResponse, IEstimate, IEstimateFormData } from "types"; import trackEventServices from "services/track-event.service"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class ProjectEstimateServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async createEstimate( diff --git a/web/services/file.service.ts b/web/services/file.service.ts index d2f01428da4..cbed73fc897 100644 --- a/web/services/file.service.ts +++ b/web/services/file.service.ts @@ -1,7 +1,6 @@ // services import APIService from "services/api.service"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; interface UnSplashImage { id: string; @@ -29,7 +28,7 @@ interface UnSplashImageUrls { class FileServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async uploadFile(workspaceSlug: string, file: FormData): Promise { diff --git a/web/services/inbox.service.ts b/web/services/inbox.service.ts index 61949c87749..16eed288ec2 100644 --- a/web/services/inbox.service.ts +++ b/web/services/inbox.service.ts @@ -1,7 +1,6 @@ import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; @@ -19,7 +18,7 @@ import type { class InboxServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async getInboxes(workspaceSlug: string, projectId: string): Promise { diff --git a/web/services/integration/csv.services.ts b/web/services/integration/csv.services.ts index f19cc4a74a9..0b53f7778a4 100644 --- a/web/services/integration/csv.services.ts +++ b/web/services/integration/csv.services.ts @@ -1,16 +1,14 @@ import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - import { ICurrentUserResponse } from "types"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class CSVIntegrationService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async exportCSVService( diff --git a/web/services/integration/github.service.ts b/web/services/integration/github.service.ts index 494785f04b7..58aa12318a7 100644 --- a/web/services/integration/github.service.ts +++ b/web/services/integration/github.service.ts @@ -1,5 +1,6 @@ import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; +import { API_BASE_URL } from "helpers/common.helper"; import { ICurrentUserResponse, IGithubRepoInfo, IGithubServiceImportFormData } from "types"; @@ -11,7 +12,7 @@ const trackEvent = const integrationServiceType: string = "github"; class GithubIntegrationService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async listAllRepositories(workspaceSlug: string, integrationSlug: string): Promise { diff --git a/web/services/integration/index.ts b/web/services/integration/index.ts index 2b32a5bd02c..b1bbefda836 100644 --- a/web/services/integration/index.ts +++ b/web/services/integration/index.ts @@ -9,15 +9,14 @@ import { IWorkspaceIntegration, IExportServiceResponse, } from "types"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class IntegrationService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async getAppIntegrationsList(): Promise { diff --git a/web/services/integration/jira.service.ts b/web/services/integration/jira.service.ts index 8f6a9fec9c0..d4620f3ff0c 100644 --- a/web/services/integration/jira.service.ts +++ b/web/services/integration/jira.service.ts @@ -1,6 +1,6 @@ import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - +import { API_BASE_URL } from "helpers/common.helper"; // types import { IJiraMetadata, IJiraResponse, IJiraImporterForm, ICurrentUserResponse } from "types"; @@ -11,7 +11,7 @@ const trackEvent = class JiraImportedService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async getJiraProjectInfo(workspaceSlug: string, params: IJiraMetadata): Promise { diff --git a/web/services/issues.service.ts b/web/services/issues.service.ts index b8875e6c5e0..6a642506744 100644 --- a/web/services/issues.service.ts +++ b/web/services/issues.service.ts @@ -11,15 +11,14 @@ import type { IIssueViewOptions, ISubIssueResponse, } from "types"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class ProjectIssuesServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async createIssues( diff --git a/web/services/modules.service.ts b/web/services/modules.service.ts index 0e3b5cfe29e..dcac98d501f 100644 --- a/web/services/modules.service.ts +++ b/web/services/modules.service.ts @@ -1,9 +1,9 @@ // services import APIService from "services/api.service"; import trackEventServices from "./track-event.service"; - // types import type { IIssueViewOptions, IModule, IIssue, ICurrentUserResponse } from "types"; +import { API_BASE_URL } from "helpers/common.helper"; const { NEXT_PUBLIC_API_BASE_URL } = process.env; @@ -12,7 +12,7 @@ const trackEvent = class ProjectIssuesServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async getModules(workspaceSlug: string, projectId: string): Promise { diff --git a/web/services/notifications.service.ts b/web/services/notifications.service.ts index 01c139b5154..8ff64e91567 100644 --- a/web/services/notifications.service.ts +++ b/web/services/notifications.service.ts @@ -1,8 +1,5 @@ // services import APIService from "services/api.service"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; - // types import type { IUserNotification, @@ -11,10 +8,12 @@ import type { PaginatedUserNotification, IMarkAllAsReadPayload, } from "types"; +// helpers +import { API_BASE_URL } from "helpers/common.helper"; class UserNotificationsServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async getUserNotifications( diff --git a/web/services/pages.service.ts b/web/services/pages.service.ts index 72b12012e31..b9dc580f318 100644 --- a/web/services/pages.service.ts +++ b/web/services/pages.service.ts @@ -1,18 +1,16 @@ +import { API_BASE_URL } from "helpers/common.helper"; // services import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - // types import { IPage, IPageBlock, RecentPagesResponse, IIssue, ICurrentUserResponse } from "types"; -const { NEXT_PUBLIC_API_BASE_URL } = process.env; - const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class PageServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async createPage( diff --git a/web/services/project-publish.service.ts b/web/services/project-publish.service.ts index 4ee01a94b2d..05555bd2913 100644 --- a/web/services/project-publish.service.ts +++ b/web/services/project-publish.service.ts @@ -1,3 +1,4 @@ +import { API_BASE_URL } from "helpers/common.helper"; // services import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; @@ -5,14 +6,12 @@ import trackEventServices from "services/track-event.service"; import { ICurrentUserResponse } from "types"; import { IProjectPublishSettings } from "store/project-publish"; -const { NEXT_PUBLIC_API_BASE_URL } = process.env; - const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class ProjectServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async getProjectSettingsAsync( diff --git a/web/services/project.service.ts b/web/services/project.service.ts index 0c2712c5622..54826c90055 100644 --- a/web/services/project.service.ts +++ b/web/services/project.service.ts @@ -1,7 +1,7 @@ +import { API_BASE_URL } from "helpers/common.helper"; // services import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - // types import type { GithubRepositoriesResponse, @@ -16,14 +16,12 @@ import type { TProjectIssuesSearchParams, } from "types"; -const { NEXT_PUBLIC_API_BASE_URL } = process.env; - const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; export class ProjectServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async createProject( diff --git a/web/services/reaction.service.ts b/web/services/reaction.service.ts index 3ba8a83e453..35dc915a177 100644 --- a/web/services/reaction.service.ts +++ b/web/services/reaction.service.ts @@ -1,7 +1,7 @@ +import { API_BASE_URL } from "helpers/common.helper"; // services import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - // types import type { ICurrentUserResponse, @@ -11,14 +11,12 @@ import type { IssueCommentReactionForm, } from "types"; -const { NEXT_PUBLIC_API_BASE_URL } = process.env; - const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class ReactionService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async createIssueReaction( diff --git a/web/services/state.service.ts b/web/services/state.service.ts index 52481f8bb31..a97753d6d6e 100644 --- a/web/services/state.service.ts +++ b/web/services/state.service.ts @@ -1,8 +1,8 @@ // services import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +// helpers +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; @@ -12,7 +12,7 @@ import type { ICurrentUserResponse, IState, IStateResponse } from "types"; class ProjectStateServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async createState( diff --git a/web/services/user.service.ts b/web/services/user.service.ts index 0e5def647bd..6a852334872 100644 --- a/web/services/user.service.ts +++ b/web/services/user.service.ts @@ -12,14 +12,14 @@ import type { IUserWorkspaceDashboard, } from "types"; -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class UserService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } currentUserConfig() { diff --git a/web/services/views.service.ts b/web/services/views.service.ts index e1d25925ed7..a684e41ff18 100644 --- a/web/services/views.service.ts +++ b/web/services/views.service.ts @@ -6,6 +6,8 @@ import { ICurrentUserResponse } from "types"; // types import { IView } from "types/views"; +import { API_BASE_URL } from "helpers/common.helper"; + const { NEXT_PUBLIC_API_BASE_URL } = process.env; const trackEvent = @@ -13,7 +15,7 @@ const trackEvent = class ViewServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async createView( diff --git a/web/services/workspace.service.ts b/web/services/workspace.service.ts index 8097253e634..0539cdf8c2e 100644 --- a/web/services/workspace.service.ts +++ b/web/services/workspace.service.ts @@ -1,9 +1,8 @@ // services import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; - +// helpers +import { API_BASE_URL } from "helpers/common.helper"; // types import { IWorkspace, @@ -22,7 +21,7 @@ const trackEvent = class WorkspaceService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(API_BASE_URL); } async userWorkspaces(): Promise { From 5628b038a249d5d13db9ef1f83b7f1b0d5e40be3 Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Wed, 13 Sep 2023 20:12:37 +0530 Subject: [PATCH 18/18] dev: remove API_BASE_URL from environment variable --- setup.sh | 7 ------- space/.env.example | 2 -- web/.env.example | 2 -- 3 files changed, 11 deletions(-) diff --git a/setup.sh b/setup.sh index 940fb8b4d22..87c0f445b2d 100755 --- a/setup.sh +++ b/setup.sh @@ -12,13 +12,6 @@ cp ./apiserver/.env.example ./apiserver/.env # Generate the SECRET_KEY that will be used by django echo -e "SECRET_KEY=\"$(tr -dc 'a-z0-9' < /dev/urandom | head -c50)\"" >> ./apiserver/.env -if [ -n "$1" ] -then - echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./web/.env - echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./space/.env -fi - - # Generate Prompt for taking tiptap auth key echo -e "\n\e[1;38m Instructions for generating TipTap Pro Extensions Auth Token \e[0m \n" diff --git a/space/.env.example b/space/.env.example index bd0318df4eb..c7063c15582 100644 --- a/space/.env.example +++ b/space/.env.example @@ -1,5 +1,3 @@ -# Base url for the API requests -NEXT_PUBLIC_API_BASE_URL="http://localhost:8000" # Public boards deploy URL NEXT_PUBLIC_DEPLOY_URL="" # Google Client ID for Google OAuth diff --git a/web/.env.example b/web/.env.example index 224a80bbfc7..88a2064c53e 100644 --- a/web/.env.example +++ b/web/.env.example @@ -1,5 +1,3 @@ -# Base url for the API requests -NEXT_PUBLIC_API_BASE_URL="http://localhost:8000" # Extra image domains that need to be added for Next Image NEXT_PUBLIC_EXTRA_IMAGE_DOMAINS= # Google Client ID for Google OAuth