pushdeer/doc/安装文档.md

155 lines
5.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# PushDeer 安装文档
- ⚠️ 当前PushDeer依然在开发中API和安装文档均有可能调整。
- ⚠️ 当前安装文档支持 iOS、Mac和Android版
- ⚠️ 当前MiPush直接调用官方接口未使用异步队列可能存在性能瓶颈
## API服务器的安装
默认的 `docker-compose` 是为开发准备的,不适合放置到线上,以下做调整:
1. 将`MySQL`服务独立出来,建议直接采用云厂商的数据库服务。
1. 设置环境变量,关闭调试信息和接口
1. 配置https
### STEP0clone 项目代码
`git clone https://github.com/easychen/pushdeer.git`
### STEP1 :编写线上环境的 docker-compose.yml ,替换环境变量
```yml
version: '2'
services:
redis:
image: 'bitnami/redis:6.0.16'
environment:
- ALLOW_EMPTY_PASSWORD=yes
app:
#image: 'webdevops/php-apache:8.0-alpine'
build: './docker/web/'
ports:
- '80:80'
- '443:443' # 开放 https 需要的接口
depends_on:
- redis
volumes:
- './:/app'
environment:
- DB_DATABASE=pushdeer
- DB_HOST=clouddb.com
- DB_PASSWORD=thep@ssw0rd
- DB_PORT=3306
- DB_TIMEZONE=+08:00
- DB_USERNAME=pushdeer
- APP_DEBUG=false
- GO_PUSH_IOS_TOPIC=com.pushdeer.self.ios
- GO_PUSH_IOS_CLIP_TOPIC=com.pushdeer.self.ios.Clip
```
### STEP2配置 SSL 证书
#### 放置证书文件
申请域名对应的 SSL 证书,获得证书文件( `example.crt` )和私钥文件( `example.key`)。
在[项目根目录](https://github.com/easychen/pushdeer)下建立 `ssl` 目录,将证书文件重命名为 `server.crt` 和 私钥文件重命名为 `server.key`
如果你下载的证书中还包含根证书(root_crt),可将根证书文本追加到 `server.crt` 之后。
<!-- #### 通过Dockfile将证书复制到镜像内
[按提示修改Dockerfile](https://github.com/easychen/pushdeer/blob/main/docker/web/Dockerfile#L27)
-->
#### 修改虚拟host配置
修改 `docker/web/vhost.conf` 中被注释掉的[这三行](https://github.com/easychen/pushdeer/blob/10e4d3bb62d8d66d4739598a8f4af32eda4cceef/docker/web/vhost.conf#L27)。
```conf
<VirtualHost *:443>
ServerName yourdomain.com
ServerAlias *.vm docker.vm
DocumentRoot "/app/api/public"
<Directory /app/api/public>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
SSLEngine on
SSLCertificateFile /app/ssl/server.crt
SSLCertificateKeyFile /app/ssl/server.key
</VirtualHost>
```
### STEP3配置推送信息
#### iOS 推送
可直接使用`PushDeer·自架版`客户端。
如自行编译客户端需生成APP和Clip的推送证书并按以下方式配置
进入 push 目录,修改 `*.yml.sample``*.yml`。其中iOS应用和Clip使用两个分开的证书进行推送`ios.yml` 是APP的配置、`clip.yml` 是Clip的配置。注意根据开发和产品状态修改`yml`中的值`production`。
默认配置中,`c.p12` 是APP的推送证书、`cc.p12`是Clip的推送证书。
#### Android 推送( 采用MiPush实现
1. [注册小米开发者,并创建应用](https://dev.mi.com/console/appservice/push.html)(需要企业资质),获得`包名`形如com.pushdeer.app和`AppSecret`(形如RWQf344dF==)
1. 在`docker-compose.yml`中通过环境变量添加包名和AppSecret。
```yml
version: '2'
services:
redis:
image: 'bitnami/redis:6.0.16'
environment:
- ALLOW_EMPTY_PASSWORD=yes
app:
#image: 'webdevops/php-apache:8.0-alpine'
build: './docker/web/'
ports:
- '80:80'
- '443:443' # 开放 https 需要的接口
depends_on:
- redis
volumes:
- './:/app'
environment:
- DB_DATABASE=pushdeer
- DB_HOST=clouddb.com
- DB_PASSWORD=thep@ssw0rd
- DB_PORT=3306
- DB_TIMEZONE=+08:00
- DB_USERNAME=pushdeer
- APP_DEBUG=false
- ANDROID_PACKAGE="这里填写包名"
- MIPUSH_SECRET="这里填写小米推送应用的AppSecret"
```
### STEP4构建并运行镜像
运行 `docker-compose up -d --build`启动API。访问 `https://yourdomain.com` 即可查看到API服务器默认网页。
## iOS客户端的编译
### 编译
参考 ios 目录下的[安装说明](https://github.com/easychen/pushdeer/tree/main/ios/PushDeer-iOS),配置项目
修改以下内容:
1. 更换项目中的名称和标识( 如要上架商店请勿直接使用PushDeer的名称和标识
1. 将项目中的 Bundle Identifier xcode.proj文件、General标签 )改为和通知证书响应的
1. 将项目中的 签名和team更换为用于上架的开发者的xcode.proj文件、Signing & Capabilities标签
1. 修改[API接口中的域名](https://github.com/easychen/pushdeer/blob/10e4d3bb62d8d66d4739598a8f4af32eda4cceef/ios/PushDeer-iOS/PushDeer/Service/PushDeerApi.swift#L37),替换为之前安装的服务
## Android客户端的编译
1. 修改包名为上边小米推送应用中设置,不然推送时会返回`bad target`提示