docker部署discourse

环境信息:

hostnameip地址cpu内存磁盘系统版本域名
discourse192.168.0.1754c4g20gubuntu1804discourse.onap.vip

证书: certbot自签证书 *.onap.vip
邮件:阿里云邮件推广服务

一、部署docker(两个节点都安装)

apt-get update
apt-get -y install vim apt-transport-https ca-certificates curl software-properties-common
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
apt-get -y update
apt-get -y install docker-ce

mkdir -p /etc/docker
cat > /etc/docker/daemon.json <<EOF
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "registry-mirrors": ["https://t3xbrfwz.mirror.aliyuncs.com"],
  "live-restore": true
}
EOF

systemctl daemon-reload
systemctl start docker
systemctl enable docker

二、部署
1、准备部署文件

apt-get install git
git clone https://github.com/discourse/discourse_docker.git /var/discourse
cp /var/discourse/samples/standalone.yml /var/discourse/containers/app.yml

2、修改修改/var/discourse/containers/app.yml配置文件

DISCOURSE_HOSTNAME: 'discourse.onap.vip' #绑定的域名
DISCOURSE_DEVELOPER_EMAILS: 'duanshuaixing@gmail.com' #管理员邮箱
DISCOURSE_SMTP_ADDRESS: smtpdm.aliyun.com
DISCOURSE_SMTP_PORT: 80
DISCOURSE_SMTP_USER_NAME: discourse@noreply.onap.vip
DISCOURSE_SMTP_PASSWORD: 输入正确的smtp密码
DISCOURSE_SMTP_ENABLE_START_TLS: false
DISCOURSE_DEFAULT_LOCALE: zh_CN #支持中文
- exec: rails r "SiteSetting.notification_email='discourse@noreply.onap.vip'" #免交互配置admin用户

插件参考:
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-solved.git
          - git clone https://github.com/discourse/discourse-math.git
          - git clone https://github.com/discourse/discourse-voting.git
          - git clone https://github.com/discourse/discourse-push-notifications.git
          - git clone https://github.com/discourse/discourse-spoiler-alert.git
          - git clone https://github.com/discourse/discourse-graphviz.git
          - git clone https://github.com/unfoldingWord-dev/discourse-mermaid.git
          - git clone https://github.com/discourse/discourse-checklist.git
          - git clone https://github.com/discourse/discourse-assign.git
          - git clone https://github.com/discourse/discourse-linkify-words.git
          - git clone https://github.com/communiteq/discourse-suppress-category-from-latest.git
          - git clone https://github.com/discourse/discourse-prometheus.git
          - git clone https://github.com/discourse/discourse-docs.git
          - git clone https://github.com/discourse/discourse-docs-card-filter.git

测试邮件是否可以正常发送

格式: swaks --to [收件邮箱] --from [发件邮箱] --server [SMTP服务器地址] --auth [login/plain] --auth-user [发件邮箱] -tls -p [端口]

apt-get -y install swaks
swaks --to duanshuaixing@gmail.com --from discourse@noreply.onap.vip  --server smtpdm.aliyun.com --auth plain --auth-user discourse@noreply.onap.vip -p 80

3、启动discourse

#网速较慢镜像2.2G比较大,可以执行以下命令加速启动
docker pull registry.baidubce.com/docker-hub/discourse/base:2.0.20210217-2235
docker tag registry.baidubce.com/docker-hub/discourse/base:2.0.20210217-2235 discourse/base:2.0.20210217-2235
docker rmi registry.baidubce.com/docker-hub/discourse/base:2.0.20210217-2235

cd /var/discourse
./launcher bootstrap app
./launcher start app

4、创建admin用户

./launcher enter app #进入容器
rake admin:create
Email:  duanshuaixing@gmail.com
Password:  
Repeat password:  
Do you want to grant Admin privileges to this account? (Y/n)  Y

4、安装插件

./launcher enter app
cd /var/www/discourse/
rake plugin:install repo=https://github.com/unfoldingWord-dev/discourse-mermaid.git
rake plugin:install repo=https://github.com/albertchan/discourse-aliyun-oss.git
rake assets:precompile
exit
./launcher restart app

三、支持https
1、https
1>修改app.yml

/var/discourse/containers/app.yml内修改打开这个注释
- "templates/web.ssl.template.yml"

2>、生成证书并导入证书
生成证书参考Certbot自签Let’s Encrypt证书

mkdir -p /var/discourse/shared/standalone/ssl/
cp ssl.crt /var/discourse/shared/standalone/ssl/ssl.crt
cp ssl.key /var/discourse/shared/standalone/ssl/ssl.key

3>重建app

./launcher rebuild app

4>开启强制https
在这里插入图片描述
5>重启应用

./launcher restart app

6>访问测试
在这里插入图片描述
四、备份和恢复
1、备份
在这里插入图片描述
2、恢复,下载的备份导入到另外一个环境

mkdir -p /var/discourse/shared/standalone/backups/default
scp root@192.168.0.175:/var/discourse/shared/standalone/backups/discourse-2021-04-21-151816-v20210328233843.tar.gz /var/discourse/shared/standalone/backups/default

cd /var/discourse
./launcher enter app
discourse enable_restore
discourse restore discourse-2021-04-21-151816-v20210328233843.tar.gz

五、卸载

cd /var/discourse
./launcher destroy app
rm -rf /var/discourse/

FAQ
构建项目git clone慢可以通过给容器配置vpn或者代理方式解决,建议sshuttle 方式,比较方便

1、用sshuttle 配置连接香港精品线路ecs,-x是排除在隧道外的地址,47.57.14.232是香港ecs,172.17.188.0/24是香港ecs 主机网段、172.18.0.0/16是容器网段

sshuttle -l 0.0.0.0:0 -r root@47.57.14.232 -x 47.57.14.232 -x 127.0.0.1 -x 172.18.0.0/16 -x 172.17.188.0/24 0/0 --dns

2、代理搭建参考:https://blog.csdn.net/weixin_47003048/article/details/108436853
docker配置代理

mkdir ~/.docker
cat ~/.docker/config.json
{
 "proxies":
 {
   "default":
   {
     "httpProxy": "http://47.57.14.232:8080",
     "httpsProxy": "http://47.57.14.232:8443",
     "noProxy": "127.0.0.1,localhost,172.17.0.0/16,192.168.0.0/24,gems.ruby-china.com
   }
 }
}


systemctl daemon-reload
systemctl restart docker
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值