在国内构建Discourse最大的问题就是网络。无法访问github,无法拉取镜像,无法从国外下载资源等。
我们解决问题的常用办法就是使用国内镜像。
下面是修改完的app.yml配置
templates:
- templates/postgres.template.yml
- templates/redis.template.yml
- templates/web.template.yml
- templates/web.ratelimited.template.yml
- templates/web.ssl.template.yml
- templates/web.letsencrypt.ssl.template.yml
- templates/web.china.template.yml # 引入国内镜像模板
expose:
- 80:80
- 443:443
params:
db_default_text_search_config: pg_catalog.english
db_shared_buffers: 768MB
env:
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LANGUAGE: en_US.UTF-8
DISCOURSE_HOSTNAME: forum.genxi.top
DISCOURSE_DEVELOPER_EMAILS: xxx@qq.com
DISCOURSE_SMTP_ADDRESS: smtp.163.com
DISCOURSE_SMTP_USER_NAME: xxx@163.com
DISCOURSE_SMTP_PASSWORD: xxx
DISCOURSE_SMTP_PORT: '465'
DISCOURSE_NOTIFICATION_EMAIL: xxx@163.com
DISCOURSE_SMTP_DOMAIN: forum.genxi.top
UNICORN_WORKERS: 4
DISCOURSE_DOWNLOAD_PRE_BUILT_ASSETS: 0 # 开启本地编译,从国外下载zip包太慢了
DISCOURSE_SMTP_FORCE_TLS: true # 发送邮件需要
DISCOURSE_MAXMIND_MIRROR_URL: https://gitee.com/singi/manju/raw/master/res # maxmind的文件下载镜像地址
volumes:
- volume:
host: "/var/discourse/shared/standalone"
guest: "/shared"
- volume:
host: "/var/discourse/shared/standalone/log/var-log"
guest: "/var/log"
hooks:
after_code:
- exec:
cd: "$home/plugins"
cmd:
- git clone https://gh-proxy.com/https://github.com/discourse/docker_manager.git
run:
- exec: echo "Beginning of custom commands"
- exec: echo "End of custom commands"
templates/web.china.template.yml的内容如下:
hooks:
before_code:
- exec:
cmd:
##- su discourse -c 'git config --global url."https://mirror.ghproxy.com/https://github.com/".insteadOf "https://github.com/"'
- su discourse -c 'git config --global url."https://gh-proxy.com/https://github.com/".insteadOf "https://github.com/"'
before_web:
- exec:
cmd:
- su discourse -c 'gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://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'