Background
The self-hosting documentation for Discourse is excellent, and the installation process went smoothly. However, I encountered issues when deploying my server in mainland China, behind the Great Firewall.
Issue
Whenever I run ./launcher rebuild app
, the process fails due to network restrictions. Below are the key error messages:
I, [2025-01-14T10:21:45.402169 #1] INFO -- : Scope: all 17 workspace projects
Lockfile is up to date, resolution step is skipped
Progress: resolved 1, reused 0, downloaded 0, added 0
Packages: +87 -15
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------
Progress: resolved 87, reused 46, downloaded 0, added 33
Progress: resolved 87, reused 46, downloaded 18, added 53
Progress: resolved 87, reused 46, downloaded 25, added 61
Progress: resolved 87, reused 46, downloaded 29, added 66
Progress: resolved 87, reused 46, downloaded 30, added 67
Progress: resolved 87, reused 46, downloaded 30, added 68
WARN GET https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.9.tgz error (ECONNRESET). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz error (ECONNRESET). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/lefthook-linux-x64/-/lefthook-linux-x64-1.10.4.tgz error (ECONNRESET). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/@embroider/compat/-/compat-3.8.0.tgz error (ECONNRESET). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.7.2.tgz error (ECONNRESET). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/ace-builds/-/ace-builds-1.37.4.tgz error (ECONNRESET). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.9.tgz error (ERR_SOCKET_TIMEOUT). Will retry in 1 minute. 1 retries left.
WARN GET https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz error (ERR_SOCKET_TIMEOUT). Will retry in 1 minute. 1 retries left.
WARN GET https://registry.npmjs.org/lefthook-linux-x64/-/lefthook-linux-x64-1.10.4.tgz error (ERR_SOCKET_TIMEOUT). Will retry in 1 minute. 1 retries left.
WARN GET https://registry.npmjs.org/@embroider/compat/-/compat-3.8.0.tgz error (ERR_SOCKET_TIMEOUT). Will retry in 1 minute. 1 retries left.
WARN GET https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.7.2.tgz error (ERR_SOCKET_TIMEOUT). Will retry in 1 minute. 1 retries left.
WARN GET https://registry.npmjs.org/ace-builds/-/ace-builds-1.37.4.tgz error (ERR_SOCKET_TIMEOUT). Will retry in 1 minute. 1 retries left.
ERR_SOCKET_TIMEOUT request to https://registry.npmjs.org/@embroider/compat/-/compat-3.8.0.tgz failed, reason: Socket timeout
FetchError: request to https://registry.npmjs.org/@embroider/compat/-/compat-3.8.0.tgz failed, reason: Socket timeout
at ClientRequest.<anonymous> (/usr/lib/node_modules/pnpm/dist/pnpm.cjs:66979:18)
at ClientRequest.emit (node:events:517:28)
at TLSSocket.socketErrorListener (node:_http_client:501:9)
at TLSSocket.emit (node:events:529:35)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
I, [2025-01-14T10:21:45.402602 #1] INFO -- : Terminating async processes
I, [2025-01-14T10:21:45.402652 #1] INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main pid: 39
107:signal-handler (1736850105) Received SIGTERM scheduling shutdown...
I, [2025-01-14T10:21:45.402684 #1] INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 107
2025-01-14 10:21:45.402 UTC [39] LOG: received fast shutdown request
2025-01-14 10:21:45.404 UTC [39] LOG: aborting any active transactions
2025-01-14 10:21:45.406 UTC [39] LOG: background worker "logical replication launcher" (PID 54) exited with exit code 1
2025-01-14 10:21:45.407 UTC [49] LOG: shutting down
2025-01-14 10:21:45.431 UTC [39] LOG: database system is shut down
107:M 14 Jan 2025 10:21:45.436 # User requested shutdown...
107:M 14 Jan 2025 10:21:45.436 * Saving the final RDB snapshot before exiting.
107:M 14 Jan 2025 10:21:45.441 * DB saved on disk
107:M 14 Jan 2025 10:21:45.441 # Redis is now ready to exit, bye bye...
FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && if [ -f yarn.lock ]; then
if [ -d node_modules/.pnpm ]; then
echo "This version of Discourse uses yarn, but pnpm node_modules are preset. Cleaning up..."
find ./node_modules ./app/assets/javascripts/*/node_modules -mindepth 1 -maxdepth 1 -exec rm -rf {} +
fi
su discourse -c 'yarn install --frozen-lockfile && yarn cache clean'
else
su discourse -c 'CI=1 pnpm install --frozen-lockfile && pnpm prune'
fi failed with return #<Process::Status: pid 301 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"yarn", "cmd"=>["if [ -f yarn.lock ]; then\n if [ -d node_modules/.pnpm ]; then\n echo \"This version of Discourse uses yarn, but pnpm node_modules are preset. Cleaning up...\"\n find ./node_modules ./app/assets/javascripts/*/node_modules -mindepth 1 -maxdepth 1 -exec rm -rf {} +\n fi\n su discourse -c 'yarn install --frozen-lockfile && yarn cache clean'\nelse\n su discourse -c 'CI=1 pnpm install --frozen-lockfile && pnpm prune'\nfi"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
58bc76b977b8eb7c806f0308caacabe389605c6242852e8f17c30076b728de67
It seems the failure is caused by the inability to fetch packages or dependencies (e.g., from GitHub or npm) due to network restrictions in mainland China.
What I’ve Tried
Using a Proxy: I attempted to set up a proxy server using Shell Clash and successfully accessed Google (which is typically inaccessible from mainland China). Here’s the test output:
root@lavm-hypge0pc5w:/var/discourse# sudo wget google.com
--2025-01-14 18:35:22-- http://google.com/
Resolving google.com (google.com)... 198.18.0.5
Connecting to google.com (google.com)|198.18.0.5|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.google.com/ [following]
--2025-01-14 18:35:22-- http://www.google.com/
Resolving www.google.com (www.google.com)... 198.18.0.6
Connecting to www.google.com (www.google.com)|198.18.0.6|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html.2’
index.html.2 [ <=> ] 19.38K --.-KB/s in 0.05s
2025-01-14 18:35:22 (372 KB/s) - ‘index.html.2’ saved [19841]
root@lavm-hypge0pc5w:/var/discourse#
However, after running ./launcher rebuild app
, I still get the same error as before.
Questions
Is there any way to successfully deploy Discourse on a server located in mainland China?