Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
help: Serve help center build without relative links for zulip.com.
Shubham Padia7db29f29de4d
diff --git a/puppet/zulip/files/nginx/zulip-include-frontend/app b/puppet/zulip/files/nginx/zulip-include-frontend/appindex 48fb93760b3..2582fbbde73 100644--- a/puppet/zulip/files/nginx/zulip-include-frontend/app+++ b/puppet/zulip/files/nginx/zulip-include-frontend/app@@ -29,7 +29,8 @@ location /static/ {# Serve help center generated by astro/starlight.location /help {- alias /home/zulip/deployments/current/starlight_help/dist/;+ alias $help_alias;+gzip on;gzip_min_length 1000;gzip_proxied expired no-cache no-store private auth;@@ -46,7 +47,8 @@ location /help {# These files are hashed and thus immutable; cache them aggressively.# https://github.com/withastro/docs/blob/53603ad048e8aedbca1aed77bac8eb00dcada79d/src/content/docs/en/guides/integrations-guide/node.mdx?plain=1#L304location /help/_astro/ {- alias /home/zulip/deployments/current/starlight_help/dist/_astro/;+ set $help_cache_alias "${help_alias}_astro/";+ alias $help_cache_alias;add_header Cache-Control "public, max-age=31536000, immutable";}diff --git a/puppet/zulip/templates/nginx.conf.template.erb b/puppet/zulip/templates/nginx.conf.template.erbindex 84e46bbd8f9..2e4c0650f73 100644--- a/puppet/zulip/templates/nginx.conf.template.erb+++ b/puppet/zulip/templates/nginx.conf.template.erb@@ -61,4 +61,9 @@ http {include /etc/nginx/conf.d/*.conf;include /etc/nginx/sites-enabled/*;++ map $host $help_alias {+ zulip.com /home/zulip/deployments/current/starlight_help/dist_no_relative_links/;+ default /home/zulip/deployments/current/starlight_help/dist/;+ }}diff --git a/starlight_help/.gitignore b/starlight_help/.gitignoreindex c2defb434b0..94ce928b198 100644--- a/starlight_help/.gitignore+++ b/starlight_help/.gitignore@@ -1,5 +1,6 @@# build outputdist/+dist_no_relative_links/# generated types.astro/diff --git a/tools/build-help-center b/tools/build-help-centerindex 960e3242c26..8273f4997c8 100755--- a/tools/build-help-center+++ b/tools/build-help-center@@ -26,6 +26,13 @@ parser.add_argument(dest="show_relative_links",help="Disable relative links when using NavigationSteps component. Typically only set to true in case of the help center being hosted on zulip.com.",)++parser.add_argument(+ "--out-dir",+ action="store",+ dest="out_dir",+ help="Output directory for the final build.",+)args = parser.parse_args()@@ -34,8 +41,12 @@ def run() -> None:env["SUPPORT_EMAIL"] = parseaddr(settings.ZULIP_ADMINISTRATOR)[1]env["CORPORATE_ENABLED"] = str(settings.CORPORATE_ENABLED).lower()env["SHOW_RELATIVE_LINKS"] = str(args.show_relative_links).lower()+ build_command = ["/usr/local/bin/corepack", "pnpm", "build"]+ if args.out_dir:+ build_command += ["--outDir", args.out_dir]+subprocess.check_call(- ["/usr/local/bin/corepack", "pnpm", "build"],+ build_command,cwd="starlight_help",env=env,)diff --git a/tools/update-prod-static b/tools/update-prod-staticindex 45047c3f17e..040f91edce3 100755--- a/tools/update-prod-static+++ b/tools/update-prod-static@@ -46,17 +46,20 @@ run(["./tools/setup/build_timezone_values"])# need them.if settings.CORPORATE_ENABLED:run(["./tools/setup/generate_landing_page_images.py"])- # We ideally should be generating two builds for Zulip cloud- # and serve a different one depending on whether the subdomain- # is same as the root domain or not.- run(["./tools/build-help-center", "--no-relative-links"])-else:- run(["./tools/build-help-center"])+ run(+ [+ "./tools/build-help-center",+ "--no-relative-links",+ "--out-dir",+ "./dist_no_relative_links",+ ]+ )++run(["./tools/build-help-center"])# Create webpack bundlerun(["./tools/webpack", "--quiet"])-# Collect the files that we're going to serve; this creates prod-static/serve.run(["./manage.py", "collectstatic", "-v0", "--noinput"])