1. 筹备工作
1.1 装置git(略)
1.2 装置Docker(略)
1.3 git换行符配置
Windows下应用CRLF
作为换行符. Linux和Mac应用LF
作为换行符.
咱们对立应用LF作为换行符,否则Linux上运行sh文件和解析配置文件会呈现谬误.
在命令行窗口执行如下命令:
git config --global core.autocrlf inputgit config --global core.safecrlf true
- 提交时转换为
LF
,检出时不转换 - 回绝提交蕴含混合换行符的文件
如果你想转换某个目录下以及子文件夹下的文件换行符为LF
,在git bash中执行:
find . -type f|xargs dos2unix
2. 下载代码
2.1 如果能够失常拜访github,执行如下命令
git clone https://github.com/OpenIMSDK/Open-IM-Server.git --recursive
--recursive
示意把所有的子模块都下载下来.
2.2 如果无奈失常拜访github:
只下载根工程,子模块不下载
git clone https://hub.fastgit.xyz/OpenIMSDK/Open-IM-Server.git
下载子模块
cmd/Open-IM-SDK-Core
.
执行cd Open-IM-Server
进入我的项目根目录,批改.gitmodules
文件,把github.com
改成hub.fastgit.xyz
.最终文件内容为:
[submodule "cmd/Open-IM-SDK-Core"] path = cmd/Open-IM-SDK-Core url = https://hub.fastgit.xyz/OpenIMSDK/Open-IM-SDK-Core.git
或者,你也能够执行以下代码替换URL:
git submodule set-url cmd/Open-IM-SDK-Core https://hub.fastgit.xyz/OpenIMSDK/Open-IM-SDK-Core.git
而后执行
git submodule update --init
下载子模块cmd/Open-IM-SDK-Core
.下载子模块
cmd/Open-IM-SDK-Core
的子模块internal/sdk_advanced_function
执行cd cmd/Open-IM-SDK-Core
进入子模块的目录,批改.gitmodules
文件,把github.com
改成hub.fastgit.xyz
.最终文件内容为:
[submodule "internal/sdk_advanced_function"] path = internal/sdk_advanced_function url = https://hub.fastgit.xyz/OpenIMSDK/sdk_advanced_function.git
或者,你也能够执行以下代码替换URL:
git submodule set-url internal/sdk_advanced_function https://hub.fastgit.xyz/OpenIMSDK/sdk_advanced_function.git
而后执行
git submodule update --init
下载子模块internal/sdk_advanced_function
.
3. 应用Docker部署
因为官网的镜像太旧,咱们本人build一个.
进入工程根目录docker build -t open-im-server -f deploy.Dockerfile .
(留神结尾有个点.
)
留神:Open-IM-Server\config\config.yaml
中有大量的配置,蕴含一些服务的IP和端口,第三方服务(比方在线存储,推送,短信),如果你要用本人的须要在这里批改.
关上docker-compose.yaml
文件:
KAFKA_ADVERTISED_LISTENERS: INSIDE://127.0.0.1:9092,OUTSIDE://103.116.45.174:9092
中OUTSIDE
的地址为你的宿主IP,我这里应用本机的内网地址192.168.2.2,如果你须要让外网能拜访到你,则须要改成外网IP批改minio映射地址. 把
/mnt/data:/data/mnt/config:/root/.minio
改为
./components/minio/data:/data./components/minio/config:/root/.minio
批改open-im-server的镜像为方才咱们本人创立的,把
image: openim/open_im_server:v2.2.0
改为
image: open-im-server
最初,在控制台中执行
docker-compose up -d
.留神当前目录是工程根目录.