Long pause in standard installation of command : cd /var/www/discourse && su discourse -c 'bundle install --retry 3 --jobs 4'

hello guys! i am a new user of discourse from china ,and i meet a strange issue in standard installation

after execute the command ./discourse-setup, my terminal stuttered on command for a long time ( more than 20 minutes)

I, [2023-06-04T07:47:29.161469 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle config --local deployment true'
I, [2023-06-04T07:47:29.544117 #1]  INFO -- : 
I, [2023-06-04T07:47:29.544260 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle config --local without "development test"'
I, [2023-06-04T07:47:29.725190 #1]  INFO -- : You are replacing the current local value of without, which is currently "test:development"
I, [2023-06-04T07:47:29.725290 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle install --retry 3 --jobs 4'

i have searched similar questions in out forum, like Local installation of discourse on Centos 7 which prompted it may be a network problem. Maybe just because my server is in China , and i meet network problem but i have test via wget https://rubygems.org/, it worked

i don’t know how to do , thanks for your reply

Well, it is indeed a network problem, because my server is in China
I found the resolutions, copy here in Chinese


Installing Discourse in China 在国内环境下安装Discourse - 主页 - 第 页 - IzIy's Files - MyPress - MyPre.Cn

Discourse version upgrades and maintenance are completed based on GitHub, and Discourse itself is written in Ruby.

Using servers like Tencent Cloud’s CVM, lightweight servers, and Alibaba Cloud’s ECS all have issues with slow access to foreign websites, mainly due to throttling operations to support domestic Git repositories.

When cloning Discourse hosted on GitHub, you can speed up access to GitHub by replacing github.com in the clone link with github.com.cnpmjs.org. For example:

Replace git clone https://github.com/discourse/discourse_docker.git with git clone https://github.com.cnpmjs.org/discourse/discourse_docker.git

In addition, when running ./discourse-setup, the installer will also install some additional projects in Docker, such as gem update, which also requires adding a Ruby mirror.

You can add the Ruby mirror address by modifying the configuration file. The main files involved are docker.git

In addition, when running ./discourse-setup, the installer will also install some additional projects in Docker, such as gem update, which also requires adding a Ruby mirror.

You can add the Ruby mirror address by modifying the configuration file. The main files involved are:

discourse/templates/web.template.yml
discourse/containers/app.yml

Before finding the place where gem update is called in the above files, add the following configuration for mirror sites:

gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
gem update bundler

For bundle, you can add a mirror site using bundle config mirror.https://rubygems.org https://gems.ruby-china.com.

Main modifications are as follows:

diff --git a/templates/web.template.yml b/templates/web.template.yml
index 28fb22d..bb0010c 100644
--- a/templates/web.template.yml
+++ b/templates/web.template.yml
@@ -86,6 +86,9 @@ run:
       cd: $home
       hook: code
       cmd:
+        - git remote -v
+        - git remote set-url origin https://github.com.cnpmjs.org/discourse/discourse.git
+        - gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
         - git reset --hard
         - git clean -f
         - git remote set-branches --add origin master
@@ -145,6 +148,7 @@ run:
       hook: web
       cmd:
         # ensure we are on latest bundler
+        - gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
         - gem update bundler
         - find $home ! -user discourse -exec chown discourse {} \\+

@@ -152,6 +156,9 @@ run:
       cd: $home
       hook: bundle_exec
       cmd:
+        - su discourse -c 'gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/'
+        - su discourse -c 'gem update bundler'
+        - su discourse -c 'bundle config mirror.https://rubygems.org https://gems.ruby-china.com'
         - su discourse -c 'bundle install --deployment --retry 3 --jobs 4 --verbose --without test developme

   - exec:
...skipping...

Regarding Email Settings

Forums usually require an email server to send various verification codes, login messages, password resets, notifications, etc.

NetEase’s free enterprise email (ym.163.com) can meet this need. Using QQ Mail to enable SMTP service is also an option, or you can purchase a paid email service.

NetEase’s free enterprise email has SMTP service enabled by default. Here is an example of setting app.yml: Discourse does not seem to provide support for SSL connections, so we will directly use the SMTP service here. Note that the start_tls function needs to be explicitly disabled.

  DISCOURSE_SMTP_ADDRESS: smtp.ym.163.com
  DISCOURSE_SMTP_PORT: 25
  DISCOURSE_SMTP_USER_NAME: mail@getblog.cn
  DISCOURSE_SMTP_PASSWORD: "password"
  DISCOURSE_SMTP_ENABLE_START_TLS: false           # (optional, default true)
  DISCOURSE_SMTP_DOMAIN: getblog.cn    # (required by some providers)

Additionally, the website administrator’s email address should not be the same as DISCOURSE_SMTP_USER_NAM, otherwise, you may not receive registration emails.

Docker Installation of Discourse Forum/BBS System (Nginx)

If you are in mainland China, you will need to set up mirror acceleration. Find the templates block in the configuration file and add the domestic mirror templates/web.china.template.yml:

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/sshd.template.yml"
  - "templates/web.template.yml"
  - "templates/web.china.template.yml"

This is apparently caused by bundle install. This operation takes a long time even if the server is deployed in a foreign country, not to mention you’ll run into some well-known resistance.
Be careful about the same problem when yarn install later.

It’s better not to put the server in China, because even cloning discourse from github may give you an error…


显然这是由于 bundle install 造成的。这个操作即使服务器在境外都久,何况你还要爬一层墙。
后面 yarn install 的时候也要小心这个问题。

最好还是别把服务器放大陆吧,连从github上clone discourse本体都可能给你爆个错误……

Thanks for the reply!

The server has a proxy and can access GitHub normally. I found tutorials on changing gem/bundle to a domestic source, and it can now be deployed normally (but it’s stuck again due to insufficient memory :face_holding_back_tears:).

I also want to set up an external server, but it’s too expensive :face_holding_back_tears:.

https://www.bugcatt.com/archives/2529

Some servers in China are even more expensive than those abroad (yes, I’m talking about you, Alibaba Cloud), it depends on the manufacturer.
Wait, you actually chose Alibaba Cloud… Oh dear.

Using a student machine (2 cores, 2 GB) :sweat_smile:
I can’t afford a server with higher specs.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.