# Discourse 现在升级真费劲

**URL:** <https://www.isharkfly.com/t/discourse/10381>\
**Category:** Discourse\
**Tags:** discourse\
**Created:** [April 8, 2026, 4:00am UTC](https://www.isharkfly.com/t/discourse/10381 "2026-04-08T04:00:00Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![sober](https://www.isharkfly.com/user_avatar/www.isharkfly.com/sober/32/13356_2.png) [@sober](https://www.isharkfly.com/u/sober)\
**Post date:** [April 11, 2026, 2:44am UTC](https://www.isharkfly.com/t/discourse/10381/7 "2026-04-11T02:44:24Z")

</div>

国内加速方案，无需vpn，带宽拉满

web.china.template.yml

```auto
hooks:
  before_code:
    - exec:
        cmd:
          - su discourse -c 'git config --global url."https://ghfast.top/https://github.com/".insteadOf "https://github.com/"'

  after_code:
    - exec:
        cmd:
          - |-
            cd /var/www/discourse
            su discourse -c '
              set -o errexit
              target="/var/www/discourse/script/assemble_ember_build.rb"
              old="https://get.discourse.org/discourse-assets"
              new="https://ghfast.top/https://github.com/discourse/discourse-assets/releases/download"

              grep -q "$old" "$target"
              sed -i "s#${old}#${new}#g" "$target"
              grep -q "$new" "$target"
              grep -Fq "url = \"#{PRE_BUILD_ROOT}/#{version_string}/#{resolved_ember_env}.tar.gz\"" "$target"
              sed -i "s|url = \"#{PRE_BUILD_ROOT}/#{version_string}/#{resolved_ember_env}.tar.gz\"|url = \"#{PRE_BUILD_ROOT}/v#{version_string}/#{resolved_ember_env}.tar.gz\"|g" "$target"
              grep -Fq "url = \"#{PRE_BUILD_ROOT}/v#{version_string}/#{resolved_ember_env}.tar.gz\"" "$target"

              if grep -q "$old" "$target"; then
                echo "ERROR: old prebuilt assets URL still present in $target" >&2
                exit 1
              fi

              if grep -Fq "url = \"#{PRE_BUILD_ROOT}/#{version_string}/#{resolved_ember_env}.tar.gz\"" "$target"; then
                echo "ERROR: old prebuilt assets URL expression still present in $target" >&2
                exit 1
              fi
            '

  before_web:
    - exec:
        cmd:
          - su discourse -c 'gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://rubygems.org/'
          - su discourse -c 'gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://api.rubygems.org/'

  before_yarn:
    - exec:
        cmd:
          - su discourse -c 'pnpm config set registry https://registry.npmmirror.com --global'

  before_bundle_exec:
    - exec:
        cmd:
          - su discourse -c 'bundle config mirror.https://rubygems.org https://mirrors.tuna.tsinghua.edu.cn/rubygems'
          - su discourse -c 'bundle config mirror.https://api.rubygems.org https://mirrors.tuna.tsinghua.edu.cn/rubygems'
          - cd /var/www/discourse && su discourse -c 'bundle config set frozen false' && su discourse -c 'bundle update diffy' && su discourse -c 'bundle config set frozen true'

```

web\_only.yml

通过[https://ghfast.top加速github](https://ghfast.xn--topgithub-7v5ov525c)

```auto
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://ghfast.top/https://github.com/discourse/docker_manager.git
          # - git clone https://ghfast.top/https://github.com/discourse/discourse-graphviz.git
          # - git clone https://ghfast.top/https://github.com/discourse/discourse-math.git
          #- git clone https://ghfast.top/https://github.com/discourse/discourse-gamification.git
          #- git clone https://ghfast.top/https://github.com/discourse/discourse-translator.git
          # - git clone https://ghfast.top/https://github.com/discourse/discourse-cakeday.git
          - git clone https://ghfast.top/https://github.com/discourse/discourse-saved-searches.git

```

---

_[View the full topic](https://www.isharkfly.com/t/discourse/10381)._
