help: Add production config for the new help center.

Fixes #35131.

Most of the nginx config is copied from
https://docs.astro.build/en/recipes/docker/#nginx.

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. We can look into this as an immediate followup while this
commit helps things get ready for a test deploy on CZO.
This commit is contained in:
Shubham Padia
2025-08-13 21:55:04 +00:00
committed by Tim Abbott
parent a766c092fc
commit 246fbf6d29
3 changed files with 32 additions and 1 deletions

View File

@@ -27,6 +27,29 @@ location /static/ {
}
}
# Serve help center generated by astro/starlight.
location /help {
alias /home/zulip/deployments/current/starlight_help/dist/;
gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
include /etc/nginx/zulip-include/headers;
add_header Access-Control-Allow-Origin *;
add_header Timing-Allow-Origin *;
error_page 404 /404.html;
index /index.html;
try_files $uri $uri/index.html =404;
}
# 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#L304
location /help/_astro/ {
alias /home/zulip/deployments/current/starlight_help/dist/_astro/;
add_header Cache-Control "public, max-age=31536000, immutable";
}
# Send longpoll requests to Tornado
location /json/events {
if ($request_method = 'OPTIONS') {

View File

@@ -26,7 +26,8 @@
"sharp": "^0.34.1",
"typescript": "^5.4.5",
"unist-util-visit": "^5.0.0",
"unplugin-icons": "^22.1.0"
"unplugin-icons": "^22.1.0",
"@types/mdast": "^4.0.4"
},
"devDependencies": {
"remark-cli": "^12.0.1",

View File

@@ -46,10 +46,17 @@ 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"])
# Create webpack bundle
run(["./tools/webpack", "--quiet"])
# Collect the files that we're going to serve; this creates prod-static/serve.
run(["./manage.py", "collectstatic", "-v0", "--noinput"])