Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] Updated web and deploy backend configuration for reverse proxy & decoupled Plane Deploy URL generation for web #2135

Merged
merged 13 commits into from
Sep 12, 2023

Conversation

henit-chobisa
Copy link
Collaborator

@henit-chobisa henit-chobisa commented Sep 10, 2023

Tasks accomplished:

  • Changed the request URL for web and deploy containers from "localhost:8000" and arbitrary URLs to the same URL the application is running on.
  • Updated the docker-compose configuration to use reverse proxy for backend requests.
  • Decoupled the URL for Plane Deploy in the web environment variable.
  • Generated the Plane Deploy link using the host URL of the web project with a suffix, If the URL is explicitly specified, the web project will use that URL for Plane Deploy.

Previous state:

  • Containers in the docker-compose configuration did not use reverse proxy for backend requests.
  • The web and deploy containers made requests to "localhost:8000" and arbitrary URLs.
  • The URL for Plane Deploy had to be manually specified in the web environment variable.

Current state:

  • The web and plane deploy projects has been updated to use reverse proxy for backend requests, making request to /api on the same host .
  • The web and deploy containers now make request on the same host.
  • The URL for Plane Deploy is decoupled from the web project and is generated using the host URL of the web project with a suffix spaces in case if the URL is explicitly specified, the web project will use that URL for Plane Deploy.

How I tested the changes

✅ Ran Individual Builds for all three projects
✅ Ran Individual Containers and tested them with environment variables provided and without giving any environment variables for self hosted deployments
✅ Built Individual Docker Compose Services for testing individually with the given environment variables
✅ Built complete docker compose with the given set of environment variables.

Keep this in mind

  • When working with self hosted part, the NEXT_PUBLIC_API_BASE_URL and NEXT_PUBLIC_DEPLOY_URL are given as empty strings at the time of the build, which means that the request for both API and DEPLOY should be made on the same host as web.
  • In case of changes in the above two variables, or defining explicit endpoint for NEXT_PUBLIC_API_BASE_URL & NEXT_PUBLIC_DEPLOY_URL, these envs can be passed as build args in docker-compose file.

@vercel
Copy link

vercel bot commented Sep 10, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

6 Ignored Deployments
Name Status Preview Comments Updated (UTC)
plane ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2023 0:36am
plane-dev ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2023 0:36am
plane-sh ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2023 0:36am
plane-sh-dev ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2023 0:36am
plane-sh-stage ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2023 0:36am
plane-staging ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2023 0:36am

@henit-chobisa henit-chobisa changed the title [chore] Updated web and deploy backend configuration for reverse proxy & decoupled Plane Deploy URL generation [chore] Updated web and deploy backend configuration for reverse proxy & decoupled Plane Deploy URL generation for web Sep 10, 2023
setup.sh Outdated
echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./space/.env
if [ -n "$1" ]
then
echo "hello"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove hello

@sriramveeraghanta sriramveeraghanta merged commit 3010107 into chore/update-setup-script Sep 12, 2023
8 of 9 checks passed
@sriramveeraghanta sriramveeraghanta deleted the chore/api-url-docker branch September 12, 2023 12:42
sriramveeraghanta added a commit that referenced this pull request Sep 13, 2023
…oject-level ENVs (#2115)

* chore: Updated Setup Script for Splitting Env File

* chore: updated dockerfile for using inproject env varaibles

* chore: removed husky replacement script

* chore: updated shell script using sed

* chore: updated dockerfiles with removed cp statement

* chore: added example env for apiserver

* chore: refactored secret generation for backend

* chore: removed replacement script

* chore: updated docker-compose with removed env variables

* chore: resolved comments in setup.sh and docker-compose

* chore: removed secret key placeholder in apiserver example env

* chore: updated root env for project less env variables

* chore: removed project level env update from root env logic

* chore: updated API_BASE_URL in .env.example

* chore: restored docker argument as env NEXT_PUBLIC_API_BASE_URL

* chore: added pg missing env variables

* [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 <veeraghanta.sriram@gmail.com>

* dev: remove API_BASE_URL from environment variable

---------

Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
Co-authored-by: pablohashescobar <nikhilschacko@gmail.com>
@leikoilja
Copy link

@henit-chobisa, what is the reason/benefit to set NEXT_PUBLIC_API_BASE_URL as empty strings during the build process? is that some sort of a hack?
i m experiencing the same issue as #2434 describes, but looking at the PR changes, i can't quite understand how setting those build args in dockerfile would make container omit env variable.
I ssh'ed into my running web container on the latest v0.13.2-dev and can see that he container itself sees env variable just fine
image

however the API calls the frontend does goes to the same host as web is hosted on
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants