parent
13efbf5f98
commit
8631c90290
@ -0,0 +1,3 @@
|
||||
*Open-IM-SDK-Core.tar.gz
|
||||
*Open-IM-Server.tar.gz
|
||||
*development.yaml
|
@ -0,0 +1,32 @@
|
||||
# openim开源项目k8s部署
|
||||
## 需要的环境
|
||||
MacOS OR Linux
|
||||
## 需要安装的软件
|
||||
- wget
|
||||
- docker
|
||||
- kubectl
|
||||
## k8s配置
|
||||
编辑 setting.env
|
||||
```shell
|
||||
#docker镜像tag前缀
|
||||
DOCKER_REGISTRY_ADDR="harbor.local/"
|
||||
#nodePort暴露端口号 api
|
||||
NODE_PORT_API="10100"
|
||||
#nodePort暴露端口号 msg_gateway
|
||||
NODE_PORT_MSG_GATEWAY="10101"
|
||||
#nodePort暴露端口号 sdk_server
|
||||
NODE_PORT_SDK_SERVER="10102"
|
||||
#nodePort暴露端口号 demo
|
||||
NODE_PORT_DEMO="10103"
|
||||
#部署在哪个命名空间
|
||||
K8S_NAMESPACE="openim"
|
||||
```
|
||||
## 单个服务部署
|
||||
```shell
|
||||
cd $服务路径 && \
|
||||
bash build.sh
|
||||
```
|
||||
## 全部部署
|
||||
```shell
|
||||
go run .
|
||||
```
|
@ -0,0 +1,111 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"golang.org/x/text/encoding/simplifiedchinese"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// docker rm -f registry-srv && rm -rf /root/docker/dockerRegistry && mkdir -p dockerRegistry && docker run -d -p 80:5000 --restart=always --name registry-srv -v /root/docker/dockerRegistry:/var/lib/registry registry
|
||||
func main() {
|
||||
var paths = map[string]string{}
|
||||
pwd, _ := os.Getwd()
|
||||
readDir, _ := os.ReadDir(".")
|
||||
for _, dir := range readDir {
|
||||
if dir.IsDir() {
|
||||
if strings.HasPrefix(dir.Name(), "open_im") {
|
||||
paths[path.Join(pwd, dir.Name())] = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
for dir := range paths {
|
||||
//execCommand("docker", "rmi", "$(docker images -a | awk '/<none>/{print $3}')")
|
||||
/*go */func(dir string) {
|
||||
fmt.Printf("\n----------------------------------------%s构建开始----------------------------------------\n", dir)
|
||||
execCommand("bash", "-c", fmt.Sprintf(""+
|
||||
"cd %s"+
|
||||
" && "+
|
||||
"bash build.sh", dir))
|
||||
fmt.Printf("\n----------------------------------------%s构建完成----------------------------------------\n", dir)
|
||||
delete(paths, dir)
|
||||
}(dir)
|
||||
}
|
||||
for {
|
||||
if len(paths) == 0 {
|
||||
fmt.Println("----------------------------------------全部构建成功----------------------------------------")
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//封装一个函数来执行命令
|
||||
func execCommand(commandName string, params ...string) bool {
|
||||
|
||||
//执行命令
|
||||
cmd := exec.Command(commandName, params...)
|
||||
|
||||
//显示运行的命令
|
||||
fmt.Println(cmd.Args)
|
||||
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
errReader, errr := cmd.StderrPipe()
|
||||
|
||||
if errr != nil {
|
||||
fmt.Println("err:" + errr.Error())
|
||||
}
|
||||
|
||||
//开启错误处理
|
||||
go handlerErr(errReader)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return false
|
||||
}
|
||||
|
||||
cmd.Start()
|
||||
in := bufio.NewScanner(stdout)
|
||||
for in.Scan() {
|
||||
cmdRe := ConvertByte2String(in.Bytes(), "UTF-8")
|
||||
fmt.Println(cmdRe)
|
||||
}
|
||||
|
||||
cmd.Wait()
|
||||
cmd.Wait()
|
||||
return true
|
||||
}
|
||||
|
||||
//开启一个协程来错误
|
||||
func handlerErr(errReader io.ReadCloser) {
|
||||
in := bufio.NewScanner(errReader)
|
||||
for in.Scan() {
|
||||
cmdRe := ConvertByte2String(in.Bytes(), "UTF-8")
|
||||
fmt.Errorf(cmdRe)
|
||||
}
|
||||
}
|
||||
|
||||
type Charset string
|
||||
|
||||
const (
|
||||
UTF8 = Charset("UTF-8")
|
||||
GB18030 = Charset("GB18030")
|
||||
)
|
||||
|
||||
//对字符进行转码
|
||||
func ConvertByte2String(byte []byte, charset Charset) string {
|
||||
var str string
|
||||
switch charset {
|
||||
case GB18030:
|
||||
var decodeBytes, _ = simplifiedchinese.GB18030.NewDecoder().Bytes(byte)
|
||||
str = string(decodeBytes)
|
||||
case UTF8:
|
||||
fallthrough
|
||||
default:
|
||||
str = string(byte)
|
||||
}
|
||||
return str
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
module github.com/showurl/deploy-openim
|
||||
|
||||
go 1.17
|
||||
|
||||
require golang.org/x/text v0.3.7
|
@ -0,0 +1,46 @@
|
||||
FROM golang as build
|
||||
|
||||
# go mod Installation source, container environment variable addition will override the default variable value
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV VERSION_TAG="2.0.2"
|
||||
|
||||
# Set up the working directory
|
||||
#WORKDIR /Open-IM-Server
|
||||
# add all files to the container
|
||||
#COPY . .
|
||||
|
||||
COPY Open-IM-Server.tar.gz /
|
||||
COPY Open-IM-SDK-Core.tar.gz /
|
||||
|
||||
WORKDIR /
|
||||
RUN tar -zxvf Open-IM-Server.tar.gz && \
|
||||
mv Open-IM-Server-$VERSION_TAG Open-IM-Server && \
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
tar -zxvf Open-IM-SDK-Core.tar.gz && \
|
||||
rm -rf Open-IM-Server/cmd/Open-IM-SDK-Core/ && \
|
||||
mv Open-IM-SDK-Core-$VERSION_TAG Open-IM-Server/cmd/Open-IM-SDK-Core && \
|
||||
rm -rf Open-IM-Server.tar.gz
|
||||
|
||||
COPY build-open_im_admin_cms.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
RUN chmod +x *.sh && \
|
||||
cd /Open-IM-Server/cmd && sed -i "s#GOARCH=amd64##g" `grep "amd64" -rl .` && \
|
||||
cd /Open-IM-Server/script && \
|
||||
/bin/sh -c ./build-open_im_admin_cms.sh
|
||||
|
||||
#Blank image Multi-Stage Build
|
||||
FROM showurl/openim-base:v2.0.2
|
||||
|
||||
#set directory to map logs,config file,script file.
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||
|
||||
#Copy scripts files and binary files to the blank image
|
||||
COPY --from=build /Open-IM-Server/script /Open-IM-Server/script
|
||||
COPY --from=build /Open-IM-Server/bin /Open-IM-Server/bin
|
||||
COPY start-open_im_admin_cms.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
|
||||
CMD ["bash", "start-open_im_admin_cms.sh"]
|
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
serviceName="open_im_admin_cms"
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
bin_dir="../bin"
|
||||
logs_dir="../logs"
|
||||
sdk_db_dir="../db/sdk/"
|
||||
#Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $bin_dir ]; then
|
||||
mkdir -p $bin_dir
|
||||
fi
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
if [ ! -d $sdk_db_dir ]; then
|
||||
mkdir -p $sdk_db_dir
|
||||
fi
|
||||
|
||||
#begin path
|
||||
|
||||
cd /Open-IM-Server/cmd/rpc/${serviceName} && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
|
||||
make install && echo -e "${SKY_BLUE_PREFIX}build ${serviceName} success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
|
||||
echo -e "${SKY_BLUE_PREFIX}Successful moved ${serviceName} to the bin directory${COLOR_SUFFIX}\n"
|
@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
source ../setting.env
|
||||
VERSION_TAG="2.0.2"
|
||||
IMAGE_TAG="${DOCKER_REGISTRY_ADDR}open_im_admin_cms:v$VERSION_TAG"
|
||||
|
||||
if [ ! -f "./Open-IM-SDK-Core.tar.gz" ];then
|
||||
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-Server/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-SDK-Core/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-SDK-Core.tar.gz
|
||||
|
||||
fi
|
||||
echo "下载完成" && \
|
||||
docker build . -t $IMAGE_TAG --no-cache && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
docker push $IMAGE_TAG && \
|
||||
rm -rf development.yaml
|
||||
cp development.tmp.yaml development.yaml
|
||||
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
sed -i "" "s#IMAGE_TAG#${IMAGE_TAG}#g" ./development.yaml
|
||||
sed -i "" "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
elif [[ `uname` == 'Linux' ]]; then
|
||||
sed -i "s#IMAGE_TAG#${IMAGE_TAG}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
fi
|
||||
echo "推送镜像完成"
|
||||
kubectl -n ${K8S_NAMESPACE} delete -f development.yaml
|
||||
kubectl -n ${K8S_NAMESPACE} apply -f development.yaml
|
@ -0,0 +1,92 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: admin-cms
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: admin-cms
|
||||
workload.auth.cattle.io/workloadselector: statefulSet-openim-admin-cms
|
||||
serviceName: admin-cms
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: admin-cms
|
||||
workload.auth.cattle.io/workloadselector: statefulSet-openim-admin-cms
|
||||
spec:
|
||||
containers:
|
||||
- image: "IMAGE_TAG"
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.hostIP
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
- name: NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.namespace
|
||||
ports:
|
||||
- name: p11000
|
||||
protocol: TCP
|
||||
containerPort: 11000
|
||||
imagePullPolicy: Always
|
||||
name: admin-cms
|
||||
stdin: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
tty: true
|
||||
volumeMounts:
|
||||
- mountPath: /Open-IM-Server/config.tmp.yaml
|
||||
name: vol2
|
||||
readOnly: true
|
||||
subPath: config.yaml
|
||||
dnsConfig: {}
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- configMap:
|
||||
defaultMode: 256
|
||||
name: config.yaml
|
||||
optional: false
|
||||
name: vol2
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: admin-cms
|
||||
spec:
|
||||
ports:
|
||||
- name: p11000
|
||||
port: 11000
|
||||
protocol: TCP
|
||||
targetPort: 11000
|
||||
selector:
|
||||
app: admin-cms
|
||||
type: ClusterIP
|
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
service_filename="open_im_admin_cms"
|
||||
service_port_name="openImAdminCmsPort"
|
||||
K8sServiceName="admin-cms"
|
||||
|
||||
#Check whether the service exists
|
||||
service_name="ps -aux |grep -w ${service_filename} |grep -v grep"
|
||||
count="${service_name}| wc -l"
|
||||
|
||||
rm -rf /Open-IM-Server/config
|
||||
mkdir /Open-IM-Server/config
|
||||
cp /Open-IM-Server/config.tmp.yaml /Open-IM-Server/config/config.yaml
|
||||
sed -i "s#openim-all#$POD_NAME.$K8sServiceName.$NAMESPACE.svc.cluster.local#g" /Open-IM-Server/config/config.yaml
|
||||
|
||||
if [ $(eval ${count}) -gt 0 ]; then
|
||||
pid="${service_name}| awk '{print \$2}'"
|
||||
echo -e "${SKY_BLUE_PREFIX}${service_filename} service has been started,pid:$(eval $pid)$COLOR_SUFFIX"
|
||||
echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename} pid:$(eval $pid)${COLOR_SUFFIX}"
|
||||
#kill the service that existed
|
||||
kill -9 $(eval $pid)
|
||||
sleep 0.5
|
||||
fi
|
||||
cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename} service is starting${COLOR_SUFFIX}"
|
||||
#Get the rpc port in the configuration file
|
||||
portList=$(cat $config_path | grep ${service_port_name} | awk -F '[:]' '{print $NF}')
|
||||
list_to_string ${portList}
|
||||
#Start related rpc services based on the number of ports
|
||||
for j in ${ports_array}; do
|
||||
echo -e "${SKY_BLUE_PREFIX}${POD_NAME} Service is starting,port number:$j $COLOR_SUFFIX"
|
||||
./${service_filename} -port $j
|
||||
done
|
@ -0,0 +1,46 @@
|
||||
FROM golang as build
|
||||
|
||||
# go mod Installation source, container environment variable addition will override the default variable value
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV VERSION_TAG="2.0.2"
|
||||
|
||||
# Set up the working directory
|
||||
#WORKDIR /Open-IM-Server
|
||||
# add all files to the container
|
||||
#COPY . .
|
||||
|
||||
COPY Open-IM-Server.tar.gz /
|
||||
COPY Open-IM-SDK-Core.tar.gz /
|
||||
|
||||
WORKDIR /
|
||||
RUN tar -zxvf Open-IM-Server.tar.gz && \
|
||||
mv Open-IM-Server-$VERSION_TAG Open-IM-Server && \
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
tar -zxvf Open-IM-SDK-Core.tar.gz && \
|
||||
rm -rf Open-IM-Server/cmd/Open-IM-SDK-Core/ && \
|
||||
mv Open-IM-SDK-Core-$VERSION_TAG Open-IM-Server/cmd/Open-IM-SDK-Core && \
|
||||
rm -rf Open-IM-Server.tar.gz
|
||||
|
||||
COPY build-open_im_api.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
RUN chmod +x *.sh && \
|
||||
cd /Open-IM-Server/cmd && sed -i "s#GOARCH=amd64##g" `grep "amd64" -rl .` && \
|
||||
cd /Open-IM-Server/script && \
|
||||
/bin/sh -c ./build-open_im_api.sh
|
||||
|
||||
#Blank image Multi-Stage Build
|
||||
FROM showurl/openim-base:v2.0.2
|
||||
|
||||
#set directory to map logs,config file,script file.
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||
|
||||
#Copy scripts files and binary files to the blank image
|
||||
COPY --from=build /Open-IM-Server/script /Open-IM-Server/script
|
||||
COPY --from=build /Open-IM-Server/bin /Open-IM-Server/bin
|
||||
COPY start-open_im_api.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
|
||||
CMD ["bash", "start-open_im_api.sh"]
|
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
bin_dir="../bin"
|
||||
logs_dir="../logs"
|
||||
sdk_db_dir="../db/sdk/"
|
||||
#Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $bin_dir ]; then
|
||||
mkdir -p $bin_dir
|
||||
fi
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
if [ ! -d $sdk_db_dir ]; then
|
||||
mkdir -p $sdk_db_dir
|
||||
fi
|
||||
|
||||
#begin path
|
||||
|
||||
cd /Open-IM-Server/cmd/open_im_api && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
|
||||
make install && echo -e "${SKY_BLUE_PREFIX}build open_im_api success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
|
||||
echo -e "${SKY_BLUE_PREFIX}Successful moved open_im_api to the bin directory${COLOR_SUFFIX}\n"
|
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
source ../setting.env
|
||||
VERSION_TAG="2.0.2"
|
||||
IMAGE_TAG="${DOCKER_REGISTRY_ADDR}open_im_api:v$VERSION_TAG"
|
||||
|
||||
if [ ! -f "./Open-IM-SDK-Core.tar.gz" ];then
|
||||
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-Server/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-SDK-Core/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-SDK-Core.tar.gz
|
||||
|
||||
fi
|
||||
echo "下载完成" && \
|
||||
docker build . -t $IMAGE_TAG --no-cache && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
docker push $IMAGE_TAG && \
|
||||
cp development.tmp.yaml development.yaml
|
||||
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
sed -i "" "s#IMAGE_TAG#${IMAGE_TAG}#g" ./development.yaml
|
||||
sed -i "" "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
elif [[ `uname` == 'Linux' ]]; then
|
||||
sed -i "s#IMAGE_TAG#${IMAGE_TAG}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
fi
|
||||
echo "推送镜像完成" && kubectl -n ${K8S_NAMESPACE} delete -f development.yaml
|
||||
kubectl -n ${K8S_NAMESPACE} apply -f development.yaml
|
@ -0,0 +1,94 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: api
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: api
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-api
|
||||
serviceName: api
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: api
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-api
|
||||
spec:
|
||||
containers:
|
||||
- image: "IMAGE_TAG"
|
||||
env:
|
||||
- name: NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.namespace
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.hostIP
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
ports:
|
||||
- name: p10000
|
||||
protocol: TCP
|
||||
containerPort: 10000
|
||||
imagePullPolicy: Always
|
||||
name: api
|
||||
stdin: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
tty: true
|
||||
volumeMounts:
|
||||
- mountPath: /Open-IM-Server/config.tmp.yaml
|
||||
name: vol2
|
||||
readOnly: true
|
||||
subPath: config.yaml
|
||||
dnsConfig: {}
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- configMap:
|
||||
defaultMode: 256
|
||||
name: config.yaml
|
||||
optional: false
|
||||
name: vol2
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: api
|
||||
spec:
|
||||
externalTrafficPolicy: Cluster
|
||||
ports:
|
||||
- name: p10000
|
||||
nodePort: NODE_PORT_API
|
||||
port: 10000
|
||||
protocol: TCP
|
||||
targetPort: 10000
|
||||
selector:
|
||||
app: api
|
||||
type: NodePort
|
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
service_filename="open_im_api"
|
||||
service_port_name="openImApiPort"
|
||||
K8sServiceName="api"
|
||||
|
||||
#Check whether the service exists
|
||||
service_name="ps -aux |grep -w ${service_filename} |grep -v grep"
|
||||
count="${service_name}| wc -l"
|
||||
|
||||
rm -rf /Open-IM-Server/config
|
||||
mkdir /Open-IM-Server/config
|
||||
cp /Open-IM-Server/config.tmp.yaml /Open-IM-Server/config/config.yaml
|
||||
sed -i "s#openim-all#$POD_NAME.$K8sServiceName.$NAMESPACE.svc.cluster.local#g" /Open-IM-Server/config/config.yaml
|
||||
|
||||
if [ $(eval ${count}) -gt 0 ]; then
|
||||
pid="${service_name}| awk '{print \$2}'"
|
||||
echo -e "${SKY_BLUE_PREFIX}${service_filename} service has been started,pid:$(eval $pid)$COLOR_SUFFIX"
|
||||
echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename} pid:$(eval $pid)${COLOR_SUFFIX}"
|
||||
#kill the service that existed
|
||||
kill -9 $(eval $pid)
|
||||
sleep 0.5
|
||||
fi
|
||||
cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename} service is starting${COLOR_SUFFIX}"
|
||||
#Get the rpc port in the configuration file
|
||||
portList=$(cat $config_path | grep ${service_port_name} | awk -F '[:]' '{print $NF}')
|
||||
list_to_string ${portList}
|
||||
#Start related rpc services based on the number of ports
|
||||
for j in ${ports_array}; do
|
||||
echo -e "${SKY_BLUE_PREFIX}${service_filename} Service is starting,port number:$j $COLOR_SUFFIX"
|
||||
./${service_filename} -port $j
|
||||
done
|
@ -0,0 +1,46 @@
|
||||
FROM golang as build
|
||||
|
||||
# go mod Installation source, container environment variable addition will override the default variable value
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV VERSION_TAG="2.0.2"
|
||||
|
||||
# Set up the working directory
|
||||
#WORKDIR /Open-IM-Server
|
||||
# add all files to the container
|
||||
#COPY . .
|
||||
|
||||
COPY Open-IM-Server.tar.gz /
|
||||
COPY Open-IM-SDK-Core.tar.gz /
|
||||
|
||||
WORKDIR /
|
||||
RUN tar -zxvf Open-IM-Server.tar.gz && \
|
||||
mv Open-IM-Server-$VERSION_TAG Open-IM-Server && \
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
tar -zxvf Open-IM-SDK-Core.tar.gz && \
|
||||
rm -rf Open-IM-Server/cmd/Open-IM-SDK-Core/ && \
|
||||
mv Open-IM-SDK-Core-$VERSION_TAG Open-IM-Server/cmd/Open-IM-SDK-Core && \
|
||||
rm -rf Open-IM-Server.tar.gz
|
||||
|
||||
COPY build-open_im_auth.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
RUN chmod +x *.sh && \
|
||||
cd /Open-IM-Server/cmd && sed -i "s#GOARCH=amd64##g" `grep "amd64" -rl .` && \
|
||||
cd /Open-IM-Server/script && \
|
||||
/bin/sh -c ./build-open_im_auth.sh
|
||||
|
||||
#Blank image Multi-Stage Build
|
||||
FROM showurl/openim-base:v2.0.2
|
||||
|
||||
#set directory to map logs,config file,script file.
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||
|
||||
#Copy scripts files and binary files to the blank image
|
||||
COPY --from=build /Open-IM-Server/script /Open-IM-Server/script
|
||||
COPY --from=build /Open-IM-Server/bin /Open-IM-Server/bin
|
||||
COPY start-open_im_auth.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
|
||||
CMD ["bash", "start-open_im_auth.sh"]
|
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
serviceName="open_im_auth"
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
bin_dir="../bin"
|
||||
logs_dir="../logs"
|
||||
sdk_db_dir="../db/sdk/"
|
||||
#Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $bin_dir ]; then
|
||||
mkdir -p $bin_dir
|
||||
fi
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
if [ ! -d $sdk_db_dir ]; then
|
||||
mkdir -p $sdk_db_dir
|
||||
fi
|
||||
|
||||
#begin path
|
||||
|
||||
cd /Open-IM-Server/cmd/rpc/${serviceName} && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
|
||||
make install && echo -e "${SKY_BLUE_PREFIX}build ${serviceName} success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
|
||||
echo -e "${SKY_BLUE_PREFIX}Successful moved ${serviceName} to the bin directory${COLOR_SUFFIX}\n"
|
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
source ../setting.env
|
||||
VERSION_TAG="2.0.2"
|
||||
IMAGE_TAG="${DOCKER_REGISTRY_ADDR}open_im_auth:v$VERSION_TAG"
|
||||
|
||||
if [ ! -f "./Open-IM-SDK-Core.tar.gz" ];then
|
||||
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-Server/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-SDK-Core/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-SDK-Core.tar.gz
|
||||
|
||||
fi
|
||||
echo "下载完成" && \
|
||||
docker build . -t $IMAGE_TAG --no-cache && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
docker push $IMAGE_TAG && \
|
||||
cp development.tmp.yaml development.yaml
|
||||
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
sed -i "" "s#IMAGE_TAG#${IMAGE_TAG}#g" ./development.yaml
|
||||
sed -i "" "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
elif [[ `uname` == 'Linux' ]]; then
|
||||
sed -i "s#IMAGE_TAG#${IMAGE_TAG}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
fi
|
||||
echo "推送镜像完成" && kubectl -n ${K8S_NAMESPACE} delete -f development.yaml
|
||||
kubectl -n ${K8S_NAMESPACE} apply -f development.yaml
|
@ -0,0 +1,92 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: auth
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: auth
|
||||
workload.auth.cattle.io/workloadselector: statefulSet-openim-auth
|
||||
serviceName: auth
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: auth
|
||||
workload.auth.cattle.io/workloadselector: statefulSet-openim-auth
|
||||
spec:
|
||||
containers:
|
||||
- image: "IMAGE_TAG"
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.hostIP
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
- name: NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.namespace
|
||||
ports:
|
||||
- name: p10600
|
||||
protocol: TCP
|
||||
containerPort: 10600
|
||||
imagePullPolicy: Always
|
||||
name: auth
|
||||
stdin: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
tty: true
|
||||
volumeMounts:
|
||||
- mountPath: /Open-IM-Server/config.tmp.yaml
|
||||
name: vol2
|
||||
readOnly: true
|
||||
subPath: config.yaml
|
||||
dnsConfig: {}
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- configMap:
|
||||
defaultMode: 256
|
||||
name: config.yaml
|
||||
optional: false
|
||||
name: vol2
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: auth
|
||||
spec:
|
||||
ports:
|
||||
- name: p10600
|
||||
port: 10600
|
||||
protocol: TCP
|
||||
targetPort: 10600
|
||||
selector:
|
||||
app: auth
|
||||
type: ClusterIP
|
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
service_filename="open_im_auth"
|
||||
service_port_name="openImAuthPort"
|
||||
K8sServiceName="auth"
|
||||
|
||||
#Check whether the service exists
|
||||
service_name="ps -aux |grep -w ${service_filename} |grep -v grep"
|
||||
count="${service_name}| wc -l"
|
||||
|
||||
rm -rf /Open-IM-Server/config
|
||||
mkdir /Open-IM-Server/config
|
||||
cp /Open-IM-Server/config.tmp.yaml /Open-IM-Server/config/config.yaml
|
||||
sed -i "s#openim-all#$POD_NAME.$K8sServiceName.$NAMESPACE.svc.cluster.local#g" /Open-IM-Server/config/config.yaml
|
||||
|
||||
if [ $(eval ${count}) -gt 0 ]; then
|
||||
pid="${service_name}| awk '{print \$2}'"
|
||||
echo -e "${SKY_BLUE_PREFIX}${service_filename} service has been started,pid:$(eval $pid)$COLOR_SUFFIX"
|
||||
echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename} pid:$(eval $pid)${COLOR_SUFFIX}"
|
||||
#kill the service that existed
|
||||
kill -9 $(eval $pid)
|
||||
sleep 0.5
|
||||
fi
|
||||
cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename} service is starting${COLOR_SUFFIX}"
|
||||
#Get the rpc port in the configuration file
|
||||
portList=$(cat $config_path | grep ${service_port_name} | awk -F '[:]' '{print $NF}')
|
||||
list_to_string ${portList}
|
||||
#Start related rpc services based on the number of ports
|
||||
for j in ${ports_array}; do
|
||||
echo -e "${SKY_BLUE_PREFIX}${POD_NAME} Service is starting,port number:$j $COLOR_SUFFIX"
|
||||
./${service_filename} -port $j
|
||||
done
|
@ -0,0 +1,46 @@
|
||||
FROM golang as build
|
||||
|
||||
# go mod Installation source, container environment variable addition will override the default variable value
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV VERSION_TAG="2.0.2"
|
||||
|
||||
# Set up the working directory
|
||||
#WORKDIR /Open-IM-Server
|
||||
# add all files to the container
|
||||
#COPY . .
|
||||
|
||||
COPY Open-IM-Server.tar.gz /
|
||||
COPY Open-IM-SDK-Core.tar.gz /
|
||||
|
||||
WORKDIR /
|
||||
RUN tar -zxvf Open-IM-Server.tar.gz && \
|
||||
mv Open-IM-Server-$VERSION_TAG Open-IM-Server && \
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
tar -zxvf Open-IM-SDK-Core.tar.gz && \
|
||||
rm -rf Open-IM-Server/cmd/Open-IM-SDK-Core/ && \
|
||||
mv Open-IM-SDK-Core-$VERSION_TAG Open-IM-Server/cmd/Open-IM-SDK-Core && \
|
||||
rm -rf Open-IM-Server.tar.gz
|
||||
|
||||
COPY build-open_im_cms_api.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
RUN chmod +x *.sh && \
|
||||
cd /Open-IM-Server/cmd && sed -i "s#GOARCH=amd64##g" `grep "amd64" -rl .` && \
|
||||
cd /Open-IM-Server/script && \
|
||||
/bin/sh -c ./build-open_im_cms_api.sh
|
||||
|
||||
#Blank image Multi-Stage Build
|
||||
FROM showurl/openim-base:v2.0.2
|
||||
|
||||
#set directory to map logs,config file,script file.
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||
|
||||
#Copy scripts files and binary files to the blank image
|
||||
COPY --from=build /Open-IM-Server/script /Open-IM-Server/script
|
||||
COPY --from=build /Open-IM-Server/bin /Open-IM-Server/bin
|
||||
COPY start-open_im_cms_api.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
|
||||
CMD ["bash", "start-open_im_cms_api.sh"]
|
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
serviceName="open_im_cms_api"
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
bin_dir="../bin"
|
||||
logs_dir="../logs"
|
||||
sdk_db_dir="../db/sdk/"
|
||||
#Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $bin_dir ]; then
|
||||
mkdir -p $bin_dir
|
||||
fi
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
if [ ! -d $sdk_db_dir ]; then
|
||||
mkdir -p $sdk_db_dir
|
||||
fi
|
||||
|
||||
#begin path
|
||||
|
||||
cd /Open-IM-Server/cmd/${serviceName} && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
|
||||
make install && echo -e "${SKY_BLUE_PREFIX}build ${serviceName} success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
|
||||
echo -e "${SKY_BLUE_PREFIX}Successful moved ${serviceName} to the bin directory${COLOR_SUFFIX}\n"
|
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
source ../setting.env
|
||||
VERSION_TAG="2.0.2"
|
||||
IMAGE_TAG="${DOCKER_REGISTRY_ADDR}open_im_cms_api:v$VERSION_TAG"
|
||||
|
||||
if [ ! -f "./Open-IM-SDK-Core.tar.gz" ];then
|
||||
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-Server/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-SDK-Core/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-SDK-Core.tar.gz
|
||||
|
||||
fi
|
||||
echo "下载完成" && \
|
||||
docker build . -t $IMAGE_TAG --no-cache && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
docker push $IMAGE_TAG && \
|
||||
cp development.tmp.yaml development.yaml
|
||||
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
sed -i "" "s#IMAGE_TAG#${IMAGE_TAG}#g" ./development.yaml
|
||||
sed -i "" "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
elif [[ `uname` == 'Linux' ]]; then
|
||||
sed -i "s#IMAGE_TAG#${IMAGE_TAG}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
fi
|
||||
echo "推送镜像完成" && kubectl -n ${K8S_NAMESPACE} delete -f development.yaml
|
||||
kubectl -n ${K8S_NAMESPACE} apply -f development.yaml
|
@ -0,0 +1,94 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: cms-api
|
||||
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: cms-api
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-cms-api
|
||||
serviceName: cms-api
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: cms-api
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-cms-api
|
||||
spec:
|
||||
containers:
|
||||
- image: "IMAGE_TAG"
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.hostIP
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
- name: NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.namespace
|
||||
ports:
|
||||
- name: p10000
|
||||
protocol: TCP
|
||||
containerPort: 10000
|
||||
imagePullPolicy: Always
|
||||
name: cms-api
|
||||
stdin: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
tty: true
|
||||
volumeMounts:
|
||||
- mountPath: /Open-IM-Server/config.tmp.yaml
|
||||
name: vol2
|
||||
readOnly: true
|
||||
subPath: config.yaml
|
||||
dnsConfig: {}
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- configMap:
|
||||
defaultMode: 256
|
||||
name: config.yaml
|
||||
optional: false
|
||||
name: vol2
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: cms-api
|
||||
|
||||
spec:
|
||||
ports:
|
||||
- name: p8000
|
||||
port: 8000
|
||||
protocol: TCP
|
||||
targetPort: 8000
|
||||
selector:
|
||||
app: cms-api
|
||||
type: ClusterIP
|
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
service_filename="open_im_cms_api"
|
||||
service_port_name="openImCmsApiPort"
|
||||
K8sServiceName="cms-api"
|
||||
|
||||
#Check whether the service exists
|
||||
service_name="ps -aux |grep -w ${service_filename} |grep -v grep"
|
||||
count="${service_name}| wc -l"
|
||||
|
||||
rm -rf /Open-IM-Server/config
|
||||
mkdir /Open-IM-Server/config
|
||||
cp /Open-IM-Server/config.tmp.yaml /Open-IM-Server/config/config.yaml
|
||||
echo "$POD_IP $K8sServiceName">> /etc/hosts
|
||||
sed -i "s#openim-all#$POD_NAME.$K8sServiceName.$NAMESPACE.svc.cluster.local#g" /Open-IM-Server/config/config.yaml
|
||||
|
||||
if [ $(eval ${count}) -gt 0 ]; then
|
||||
pid="${service_name}| awk '{print \$2}'"
|
||||
echo -e "${SKY_BLUE_PREFIX}${service_filename} service has been started,pid:$(eval $pid)$COLOR_SUFFIX"
|
||||
echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename} pid:$(eval $pid)${COLOR_SUFFIX}"
|
||||
#kill the service that existed
|
||||
kill -9 $(eval $pid)
|
||||
sleep 0.5
|
||||
fi
|
||||
cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename} service is starting${COLOR_SUFFIX}"
|
||||
#Get the rpc port in the configuration file
|
||||
portList=$(cat $config_path | grep ${service_port_name} | awk -F '[:]' '{print $NF}')
|
||||
list_to_string ${portList}
|
||||
#Start related rpc services based on the number of ports
|
||||
for j in ${ports_array}; do
|
||||
echo -e "${SKY_BLUE_PREFIX}${service_filename} Service is starting,port number:$j $COLOR_SUFFIX"
|
||||
./${service_filename} -port $j
|
||||
done
|
@ -0,0 +1,46 @@
|
||||
FROM golang as build
|
||||
|
||||
# go mod Installation source, container environment variable addition will override the default variable value
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV VERSION_TAG="2.0.2"
|
||||
|
||||
# Set up the working directory
|
||||
#WORKDIR /Open-IM-Server
|
||||
# add all files to the container
|
||||
#COPY . .
|
||||
|
||||
COPY Open-IM-Server.tar.gz /
|
||||
COPY Open-IM-SDK-Core.tar.gz /
|
||||
|
||||
WORKDIR /
|
||||
RUN tar -zxvf Open-IM-Server.tar.gz && \
|
||||
mv Open-IM-Server-$VERSION_TAG Open-IM-Server && \
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
tar -zxvf Open-IM-SDK-Core.tar.gz && \
|
||||
rm -rf Open-IM-Server/cmd/Open-IM-SDK-Core/ && \
|
||||
mv Open-IM-SDK-Core-$VERSION_TAG Open-IM-Server/cmd/Open-IM-SDK-Core && \
|
||||
rm -rf Open-IM-Server.tar.gz
|
||||
|
||||
COPY build-open_im_demo.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
RUN chmod +x *.sh && \
|
||||
cd /Open-IM-Server/cmd && sed -i "s#GOARCH=amd64##g" `grep "amd64" -rl .` && \
|
||||
cd /Open-IM-Server/script && \
|
||||
/bin/sh -c ./build-open_im_demo.sh
|
||||
|
||||
#Blank image Multi-Stage Build
|
||||
FROM showurl/openim-base:v2.0.2
|
||||
|
||||
#set directory to map logs,config file,script file.
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||
|
||||
#Copy scripts files and binary files to the blank image
|
||||
COPY --from=build /Open-IM-Server/script /Open-IM-Server/script
|
||||
COPY --from=build /Open-IM-Server/bin /Open-IM-Server/bin
|
||||
COPY start-open_im_demo.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
|
||||
CMD ["bash", "start-open_im_demo.sh"]
|
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
serviceName="open_im_demo"
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
bin_dir="../bin"
|
||||
logs_dir="../logs"
|
||||
sdk_db_dir="../db/sdk/"
|
||||
#Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $bin_dir ]; then
|
||||
mkdir -p $bin_dir
|
||||
fi
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
if [ ! -d $sdk_db_dir ]; then
|
||||
mkdir -p $sdk_db_dir
|
||||
fi
|
||||
|
||||
#begin path
|
||||
|
||||
cd /Open-IM-Server/cmd/${serviceName} && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
|
||||
sed -i 's#utils.ServerIP#"api"#g' /Open-IM-Server/internal/demo/register/login.go
|
||||
sed -i 's#"Open_IM/pkg/utils"##g' /Open-IM-Server/internal/demo/register/login.go
|
||||
make install && echo -e "${SKY_BLUE_PREFIX}build ${serviceName} success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
|
||||
echo -e "${SKY_BLUE_PREFIX}Successful moved ${serviceName} to the bin directory${COLOR_SUFFIX}\n"
|
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
source ../setting.env
|
||||
VERSION_TAG="2.0.2"
|
||||
IMAGE_TAG="${DOCKER_REGISTRY_ADDR}open_im_demo:v$VERSION_TAG"
|
||||
|
||||
if [ ! -f "./Open-IM-SDK-Core.tar.gz" ];then
|
||||
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-Server/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-SDK-Core/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-SDK-Core.tar.gz
|
||||
|
||||
fi
|
||||
echo "下载完成" && \
|
||||
docker build . -t $IMAGE_TAG --no-cache && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
docker push $IMAGE_TAG && \
|
||||
cp development.tmp.yaml development.yaml
|
||||
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
sed -i "" "s#IMAGE_TAG#${IMAGE_TAG}#g" ./development.yaml
|
||||
sed -i "" "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
elif [[ `uname` == 'Linux' ]]; then
|
||||
sed -i "s#IMAGE_TAG#${IMAGE_TAG}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
fi
|
||||
echo "推送镜像完成" && kubectl -n ${K8S_NAMESPACE} delete -f development.yaml
|
||||
kubectl -n ${K8S_NAMESPACE} apply -f development.yaml
|
@ -0,0 +1,96 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: demo
|
||||
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: demo
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-demo
|
||||
serviceName: demo
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: demo
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-demo
|
||||
spec:
|
||||
containers:
|
||||
- image: "IMAGE_TAG"
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.hostIP
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
- name: NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.namespace
|
||||
ports:
|
||||
- name: p42233
|
||||
protocol: TCP
|
||||
containerPort: 42233
|
||||
imagePullPolicy: Always
|
||||
name: demo
|
||||
stdin: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
tty: true
|
||||
volumeMounts:
|
||||
- mountPath: /Open-IM-Server/config.tmp.yaml
|
||||
name: vol2
|
||||
readOnly: true
|
||||
subPath: config.yaml
|
||||
dnsConfig: {}
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- configMap:
|
||||
defaultMode: 256
|
||||
name: config.yaml
|
||||
optional: false
|
||||
name: vol2
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: demo-remote
|
||||
|
||||
spec:
|
||||
externalTrafficPolicy: Cluster
|
||||
ports:
|
||||
- name: p42233
|
||||
nodePort: NODE_PORT_DEMO
|
||||
port: 42233
|
||||
protocol: TCP
|
||||
targetPort: 42233
|
||||
selector:
|
||||
app: demo
|
||||
type: NodePort
|
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
ulimit -n 200000
|
||||
|
||||
service_filename="open_im_demo"
|
||||
K8sServiceName="demo"
|
||||
binary_root="/Open-IM-Server/bin"
|
||||
|
||||
rm -rf /Open-IM-Server/config
|
||||
mkdir /Open-IM-Server/config
|
||||
cp /Open-IM-Server/config.tmp.yaml /Open-IM-Server/config/config.yaml
|
||||
sed -i "s#openim-all#$POD_NAME.$K8sServiceName.$NAMESPACE.svc.cluster.local#g" /Open-IM-Server/config/config.yaml
|
||||
|
||||
switch=$(cat $config_path | grep demoswitch |awk -F '[:]' '{print $NF}')
|
||||
if [ ${switch} != "true" ]; then
|
||||
echo -e ${YELLOW_PREFIX}" demo service switch is false not start demo "${COLOR_SUFFIX}
|
||||
exit 0
|
||||
fi
|
||||
list1=$(cat $config_path | grep openImDemoPort | awk -F '[:]' '{print $NF}')
|
||||
list_to_string $list1
|
||||
api_ports=($ports_array)
|
||||
|
||||
#Check if the service exists
|
||||
#If it is exists,kill this process
|
||||
check=$(ps aux | grep -w ./${service_filename} | grep -v grep | wc -l)
|
||||
if [ $check -ge 1 ]; then
|
||||
oldPid=$(ps aux | grep -w ./${service_filename} | grep -v grep | awk '{print $2}')
|
||||
kill -9 ${oldPid}
|
||||
fi
|
||||
#Waiting port recycling
|
||||
sleep 1
|
||||
cd ${binary_root}
|
||||
./${service_filename} -port ${api_ports[$i]}
|
@ -0,0 +1,46 @@
|
||||
FROM golang as build
|
||||
|
||||
# go mod Installation source, container environment variable addition will override the default variable value
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV VERSION_TAG="2.0.2"
|
||||
|
||||
# Set up the working directory
|
||||
#WORKDIR /Open-IM-Server
|
||||
# add all files to the container
|
||||
#COPY . .
|
||||
|
||||
COPY Open-IM-Server.tar.gz /
|
||||
COPY Open-IM-SDK-Core.tar.gz /
|
||||
|
||||
WORKDIR /
|
||||
RUN tar -zxvf Open-IM-Server.tar.gz && \
|
||||
mv Open-IM-Server-$VERSION_TAG Open-IM-Server && \
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
tar -zxvf Open-IM-SDK-Core.tar.gz && \
|
||||
rm -rf Open-IM-Server/cmd/Open-IM-SDK-Core/ && \
|
||||
mv Open-IM-SDK-Core-$VERSION_TAG Open-IM-Server/cmd/Open-IM-SDK-Core && \
|
||||
rm -rf Open-IM-Server.tar.gz
|
||||
|
||||
COPY build-open_im_friend.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
RUN chmod +x *.sh && \
|
||||
cd /Open-IM-Server/cmd && sed -i "s#GOARCH=amd64##g" `grep "amd64" -rl .` && \
|
||||
cd /Open-IM-Server/script && \
|
||||
/bin/sh -c ./build-open_im_friend.sh
|
||||
|
||||
#Blank image Multi-Stage Build
|
||||
FROM showurl/openim-base:v2.0.2
|
||||
|
||||
#set directory to map logs,config file,script file.
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||
|
||||
#Copy scripts files and binary files to the blank image
|
||||
COPY --from=build /Open-IM-Server/script /Open-IM-Server/script
|
||||
COPY --from=build /Open-IM-Server/bin /Open-IM-Server/bin
|
||||
COPY start-open_im_friend.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
|
||||
CMD ["bash", "start-open_im_friend.sh"]
|
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
serviceName="open_im_friend"
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
bin_dir="../bin"
|
||||
logs_dir="../logs"
|
||||
sdk_db_dir="../db/sdk/"
|
||||
#Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $bin_dir ]; then
|
||||
mkdir -p $bin_dir
|
||||
fi
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
if [ ! -d $sdk_db_dir ]; then
|
||||
mkdir -p $sdk_db_dir
|
||||
fi
|
||||
|
||||
#begin path
|
||||
|
||||
cd /Open-IM-Server/cmd/rpc/${serviceName} && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
|
||||
make install && echo -e "${SKY_BLUE_PREFIX}build ${serviceName} success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
|
||||
echo -e "${SKY_BLUE_PREFIX}Successful moved ${serviceName} to the bin directory${COLOR_SUFFIX}\n"
|
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
source ../setting.env
|
||||
VERSION_TAG="2.0.2"
|
||||
IMAGE_TAG="${DOCKER_REGISTRY_ADDR}open_im_friend:v$VERSION_TAG"
|
||||
|
||||
if [ ! -f "./Open-IM-SDK-Core.tar.gz" ];then
|
||||
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-Server/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-SDK-Core/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-SDK-Core.tar.gz
|
||||
|
||||
fi
|
||||
echo "下载完成" && \
|
||||
docker build . -t $IMAGE_TAG --no-cache && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
docker push $IMAGE_TAG && \
|
||||
cp development.tmp.yaml development.yaml
|
||||
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
sed -i "" "s#IMAGE_TAG#${IMAGE_TAG}#g" ./development.yaml
|
||||
sed -i "" "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
elif [[ `uname` == 'Linux' ]]; then
|
||||
sed -i "s#IMAGE_TAG#${IMAGE_TAG}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
fi
|
||||
echo "推送镜像完成" && kubectl -n ${K8S_NAMESPACE} delete -f development.yaml
|
||||
kubectl -n ${K8S_NAMESPACE} apply -f development.yaml
|
@ -0,0 +1,94 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: friend
|
||||
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: friend
|
||||
workload.friend.cattle.io/workloadselector: statefulSet-openim-friend
|
||||
serviceName: friend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: friend
|
||||
workload.friend.cattle.io/workloadselector: statefulSet-openim-friend
|
||||
spec:
|
||||
containers:
|
||||
- image: "IMAGE_TAG"
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.hostIP
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
- name: NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.namespace
|
||||
ports:
|
||||
- name: p10200
|
||||
protocol: TCP
|
||||
containerPort: 10200
|
||||
imagePullPolicy: Always
|
||||
name: friend
|
||||
stdin: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
tty: true
|
||||
volumeMounts:
|
||||
- mountPath: /Open-IM-Server/config.tmp.yaml
|
||||
name: vol2
|
||||
readOnly: true
|
||||
subPath: config.yaml
|
||||
dnsConfig: {}
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- configMap:
|
||||
defaultMode: 256
|
||||
name: config.yaml
|
||||
optional: false
|
||||
name: vol2
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: friend
|
||||
|
||||
spec:
|
||||
ports:
|
||||
- name: p10200
|
||||
port: 10200
|
||||
protocol: TCP
|
||||
targetPort: 10200
|
||||
selector:
|
||||
app: friend
|
||||
type: ClusterIP
|
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
service_filename="open_im_friend"
|
||||
service_port_name="openImFriendPort"
|
||||
K8sServiceName="friend"
|
||||
|
||||
#Check whether the service exists
|
||||
service_name="ps -aux |grep -w ${service_filename} |grep -v grep"
|
||||
count="${service_name}| wc -l"
|
||||
|
||||
rm -rf /Open-IM-Server/config
|
||||
mkdir /Open-IM-Server/config
|
||||
cp /Open-IM-Server/config.tmp.yaml /Open-IM-Server/config/config.yaml
|
||||
sed -i "s#openim-all#$POD_NAME.$K8sServiceName.$NAMESPACE.svc.cluster.local#g" /Open-IM-Server/config/config.yaml
|
||||
|
||||
if [ $(eval ${count}) -gt 0 ]; then
|
||||
pid="${service_name}| awk '{print \$2}'"
|
||||
echo -e "${SKY_BLUE_PREFIX}${service_filename} service has been started,pid:$(eval $pid)$COLOR_SUFFIX"
|
||||
echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename} pid:$(eval $pid)${COLOR_SUFFIX}"
|
||||
#kill the service that existed
|
||||
kill -9 $(eval $pid)
|
||||
sleep 0.5
|
||||
fi
|
||||
cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename} service is starting${COLOR_SUFFIX}"
|
||||
#Get the rpc port in the configuration file
|
||||
portList=$(cat $config_path | grep ${service_port_name} | awk -F '[:]' '{print $NF}')
|
||||
list_to_string ${portList}
|
||||
#Start related rpc services based on the number of ports
|
||||
for j in ${ports_array}; do
|
||||
echo -e "${SKY_BLUE_PREFIX}${POD_NAME} Service is starting,port number:$j $COLOR_SUFFIX"
|
||||
./${service_filename} -port $j
|
||||
done
|
@ -0,0 +1,46 @@
|
||||
FROM golang as build
|
||||
|
||||
# go mod Installation source, container environment variable addition will override the default variable value
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV VERSION_TAG="2.0.2"
|
||||
|
||||
# Set up the working directory
|
||||
#WORKDIR /Open-IM-Server
|
||||
# add all files to the container
|
||||
#COPY . .
|
||||
|
||||
COPY Open-IM-Server.tar.gz /
|
||||
COPY Open-IM-SDK-Core.tar.gz /
|
||||
|
||||
WORKDIR /
|
||||
RUN tar -zxvf Open-IM-Server.tar.gz && \
|
||||
mv Open-IM-Server-$VERSION_TAG Open-IM-Server && \
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
tar -zxvf Open-IM-SDK-Core.tar.gz && \
|
||||
rm -rf Open-IM-Server/cmd/Open-IM-SDK-Core/ && \
|
||||
mv Open-IM-SDK-Core-$VERSION_TAG Open-IM-Server/cmd/Open-IM-SDK-Core && \
|
||||
rm -rf Open-IM-Server.tar.gz
|
||||
|
||||
COPY build-open_im_group.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
RUN chmod +x *.sh && \
|
||||
cd /Open-IM-Server/cmd && sed -i "s#GOARCH=amd64##g" `grep "amd64" -rl .` && \
|
||||
cd /Open-IM-Server/script && \
|
||||
/bin/sh -c ./build-open_im_group.sh
|
||||
|
||||
#Blank image Multi-Stage Build
|
||||
FROM showurl/openim-base:v2.0.2
|
||||
|
||||
#set directory to map logs,config file,script file.
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||
|
||||
#Copy scripts files and binary files to the blank image
|
||||
COPY --from=build /Open-IM-Server/script /Open-IM-Server/script
|
||||
COPY --from=build /Open-IM-Server/bin /Open-IM-Server/bin
|
||||
COPY start-open_im_group.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
|
||||
CMD ["bash", "start-open_im_group.sh"]
|
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
serviceName="open_im_group"
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
bin_dir="../bin"
|
||||
logs_dir="../logs"
|
||||
sdk_db_dir="../db/sdk/"
|
||||
#Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $bin_dir ]; then
|
||||
mkdir -p $bin_dir
|
||||
fi
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
if [ ! -d $sdk_db_dir ]; then
|
||||
mkdir -p $sdk_db_dir
|
||||
fi
|
||||
|
||||
#begin path
|
||||
|
||||
cd /Open-IM-Server/cmd/rpc/${serviceName} && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
|
||||
make install && echo -e "${SKY_BLUE_PREFIX}build ${serviceName} success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
|
||||
echo -e "${SKY_BLUE_PREFIX}Successful moved ${serviceName} to the bin directory${COLOR_SUFFIX}\n"
|
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
source ../setting.env
|
||||
VERSION_TAG="2.0.2"
|
||||
IMAGE_TAG="${DOCKER_REGISTRY_ADDR}open_im_group:v$VERSION_TAG"
|
||||
|
||||
if [ ! -f "./Open-IM-SDK-Core.tar.gz" ];then
|
||||
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-Server/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-SDK-Core/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-SDK-Core.tar.gz
|
||||
|
||||
fi
|
||||
echo "下载完成" && \
|
||||
docker build . -t $IMAGE_TAG --no-cache && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
docker push $IMAGE_TAG && \
|
||||
cp development.tmp.yaml development.yaml
|
||||
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
sed -i "" "s#IMAGE_TAG#${IMAGE_TAG}#g" ./development.yaml
|
||||
sed -i "" "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
elif [[ `uname` == 'Linux' ]]; then
|
||||
sed -i "s#IMAGE_TAG#${IMAGE_TAG}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
fi
|
||||
echo "推送镜像完成" && kubectl -n ${K8S_NAMESPACE} delete -f development.yaml
|
||||
kubectl -n ${K8S_NAMESPACE} apply -f development.yaml
|
@ -0,0 +1,94 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: group
|
||||
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: group
|
||||
workload.group.cattle.io/workloadselector: statefulSet-openim-group
|
||||
serviceName: group
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: group
|
||||
workload.group.cattle.io/workloadselector: statefulSet-openim-group
|
||||
spec:
|
||||
containers:
|
||||
- image: "IMAGE_TAG"
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.hostIP
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
- name: NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.namespace
|
||||
ports:
|
||||
- name: p10500
|
||||
protocol: TCP
|
||||
containerPort: 10500
|
||||
imagePullPolicy: Always
|
||||
name: group
|
||||
stdin: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
tty: true
|
||||
volumeMounts:
|
||||
- mountPath: /Open-IM-Server/config.tmp.yaml
|
||||
name: vol2
|
||||
readOnly: true
|
||||
subPath: config.yaml
|
||||
dnsConfig: {}
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- configMap:
|
||||
defaultMode: 256
|
||||
name: config.yaml
|
||||
optional: false
|
||||
name: vol2
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: group
|
||||
|
||||
spec:
|
||||
ports:
|
||||
- name: p10500
|
||||
port: 10500
|
||||
protocol: TCP
|
||||
targetPort: 10500
|
||||
selector:
|
||||
app: group
|
||||
type: ClusterIP
|
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
service_filename="open_im_group"
|
||||
service_port_name="openImGroupPort"
|
||||
K8sServiceName="group"
|
||||
|
||||
#Check whether the service exists
|
||||
service_name="ps -aux |grep -w ${service_filename} |grep -v grep"
|
||||
count="${service_name}| wc -l"
|
||||
|
||||
rm -rf /Open-IM-Server/config
|
||||
mkdir /Open-IM-Server/config
|
||||
cp /Open-IM-Server/config.tmp.yaml /Open-IM-Server/config/config.yaml
|
||||
sed -i "s#openim-all#$POD_NAME.$K8sServiceName.$NAMESPACE.svc.cluster.local#g" /Open-IM-Server/config/config.yaml
|
||||
|
||||
if [ $(eval ${count}) -gt 0 ]; then
|
||||
pid="${service_name}| awk '{print \$2}'"
|
||||
echo -e "${SKY_BLUE_PREFIX}${service_filename} service has been started,pid:$(eval $pid)$COLOR_SUFFIX"
|
||||
echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename} pid:$(eval $pid)${COLOR_SUFFIX}"
|
||||
#kill the service that existed
|
||||
kill -9 $(eval $pid)
|
||||
sleep 0.5
|
||||
fi
|
||||
cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename} service is starting${COLOR_SUFFIX}"
|
||||
#Get the rpc port in the configuration file
|
||||
portList=$(cat $config_path | grep ${service_port_name} | awk -F '[:]' '{print $NF}')
|
||||
list_to_string ${portList}
|
||||
#Start related rpc services based on the number of ports
|
||||
for j in ${ports_array}; do
|
||||
echo -e "${SKY_BLUE_PREFIX}${POD_NAME} Service is starting,port number:$j $COLOR_SUFFIX"
|
||||
./${service_filename} -port $j
|
||||
done
|
@ -0,0 +1,46 @@
|
||||
FROM golang as build
|
||||
|
||||
# go mod Installation source, container environment variable addition will override the default variable value
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV VERSION_TAG="2.0.2"
|
||||
|
||||
# Set up the working directory
|
||||
#WORKDIR /Open-IM-Server
|
||||
# add all files to the container
|
||||
#COPY . .
|
||||
|
||||
COPY Open-IM-Server.tar.gz /
|
||||
COPY Open-IM-SDK-Core.tar.gz /
|
||||
|
||||
WORKDIR /
|
||||
RUN tar -zxvf Open-IM-Server.tar.gz && \
|
||||
mv Open-IM-Server-$VERSION_TAG Open-IM-Server && \
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
tar -zxvf Open-IM-SDK-Core.tar.gz && \
|
||||
rm -rf Open-IM-Server/cmd/Open-IM-SDK-Core/ && \
|
||||
mv Open-IM-SDK-Core-$VERSION_TAG Open-IM-Server/cmd/Open-IM-SDK-Core && \
|
||||
rm -rf Open-IM-Server.tar.gz
|
||||
|
||||
COPY build-open_im_message_cms.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
RUN chmod +x *.sh && \
|
||||
cd /Open-IM-Server/cmd && sed -i "s#GOARCH=amd64##g" `grep "amd64" -rl .` && \
|
||||
cd /Open-IM-Server/script && \
|
||||
/bin/sh -c ./build-open_im_message_cms.sh
|
||||
|
||||
#Blank image Multi-Stage Build
|
||||
FROM showurl/openim-base:v2.0.2
|
||||
|
||||
#set directory to map logs,config file,script file.
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||
|
||||
#Copy scripts files and binary files to the blank image
|
||||
COPY --from=build /Open-IM-Server/script /Open-IM-Server/script
|
||||
COPY --from=build /Open-IM-Server/bin /Open-IM-Server/bin
|
||||
COPY start-open_im_message_cms.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
|
||||
CMD ["bash", "start-open_im_message_cms.sh"]
|
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
serviceName="open_im_message_cms"
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
bin_dir="../bin"
|
||||
logs_dir="../logs"
|
||||
sdk_db_dir="../db/sdk/"
|
||||
#Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $bin_dir ]; then
|
||||
mkdir -p $bin_dir
|
||||
fi
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
if [ ! -d $sdk_db_dir ]; then
|
||||
mkdir -p $sdk_db_dir
|
||||
fi
|
||||
|
||||
#begin path
|
||||
|
||||
cd /Open-IM-Server/cmd/rpc/${serviceName} && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
|
||||
make install && echo -e "${SKY_BLUE_PREFIX}build ${serviceName} success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
|
||||
echo -e "${SKY_BLUE_PREFIX}Successful moved ${serviceName} to the bin directory${COLOR_SUFFIX}\n"
|
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
source ../setting.env
|
||||
VERSION_TAG="2.0.2"
|
||||
IMAGE_TAG="${DOCKER_REGISTRY_ADDR}open_im_message_cms:v$VERSION_TAG"
|
||||
|
||||
if [ ! -f "./Open-IM-SDK-Core.tar.gz" ];then
|
||||
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-Server/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-SDK-Core/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-SDK-Core.tar.gz
|
||||
|
||||
fi
|
||||
echo "下载完成" && \
|
||||
docker build . -t $IMAGE_TAG --no-cache && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
docker push $IMAGE_TAG && \
|
||||
cp development.tmp.yaml development.yaml
|
||||
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
sed -i "" "s#IMAGE_TAG#${IMAGE_TAG}#g" ./development.yaml
|
||||
sed -i "" "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
elif [[ `uname` == 'Linux' ]]; then
|
||||
sed -i "s#IMAGE_TAG#${IMAGE_TAG}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
fi
|
||||
echo "推送镜像完成" && kubectl -n ${K8S_NAMESPACE} delete -f development.yaml
|
||||
kubectl -n ${K8S_NAMESPACE} apply -f development.yaml
|
@ -0,0 +1,94 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: message-cms
|
||||
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: message-cms
|
||||
workload.auth.cattle.io/workloadselector: statefulSet-openim-message-cms
|
||||
serviceName: message-cms
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: message-cms
|
||||
workload.auth.cattle.io/workloadselector: statefulSet-openim-message-cms
|
||||
spec:
|
||||
containers:
|
||||
- image: "IMAGE_TAG"
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.hostIP
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
- name: NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.namespace
|
||||
ports:
|
||||
- name: p10900
|
||||
protocol: TCP
|
||||
containerPort: 10900
|
||||
imagePullPolicy: Always
|
||||
name: message-cms
|
||||
stdin: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
tty: true
|
||||
volumeMounts:
|
||||
- mountPath: /Open-IM-Server/config.tmp.yaml
|
||||
name: vol2
|
||||
readOnly: true
|
||||
subPath: config.yaml
|
||||
dnsConfig: {}
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- configMap:
|
||||
defaultMode: 256
|
||||
name: config.yaml
|
||||
optional: false
|
||||
name: vol2
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: message-cms
|
||||
|
||||
spec:
|
||||
ports:
|
||||
- name: p10900
|
||||
port: 10900
|
||||
protocol: TCP
|
||||
targetPort: 10900
|
||||
selector:
|
||||
app: message-cms
|
||||
type: ClusterIP
|
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
service_filename="open_im_message_cms"
|
||||
service_port_name="openImMessageCmsPort"
|
||||
K8sServiceName="message-cms"
|
||||
|
||||
#Check whether the service exists
|
||||
service_name="ps -aux |grep -w ${service_filename} |grep -v grep"
|
||||
count="${service_name}| wc -l"
|
||||
|
||||
rm -rf /Open-IM-Server/config
|
||||
mkdir /Open-IM-Server/config
|
||||
cp /Open-IM-Server/config.tmp.yaml /Open-IM-Server/config/config.yaml
|
||||
sed -i "s#openim-all#$POD_NAME.$K8sServiceName.$NAMESPACE.svc.cluster.local#g" /Open-IM-Server/config/config.yaml
|
||||
|
||||
if [ $(eval ${count}) -gt 0 ]; then
|
||||
pid="${service_name}| awk '{print \$2}'"
|
||||
echo -e "${SKY_BLUE_PREFIX}${service_filename} service has been started,pid:$(eval $pid)$COLOR_SUFFIX"
|
||||
echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename} pid:$(eval $pid)${COLOR_SUFFIX}"
|
||||
#kill the service that existed
|
||||
kill -9 $(eval $pid)
|
||||
sleep 0.5
|
||||
fi
|
||||
cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename} service is starting${COLOR_SUFFIX}"
|
||||
#Get the rpc port in the configuration file
|
||||
portList=$(cat $config_path | grep ${service_port_name} | awk -F '[:]' '{print $NF}')
|
||||
list_to_string ${portList}
|
||||
#Start related rpc services based on the number of ports
|
||||
for j in ${ports_array}; do
|
||||
echo -e "${SKY_BLUE_PREFIX}${POD_NAME} Service is starting,port number:$j $COLOR_SUFFIX"
|
||||
./${service_filename} -port $j
|
||||
done
|
@ -0,0 +1,46 @@
|
||||
FROM golang as build
|
||||
|
||||
# go mod Installation source, container environment variable addition will override the default variable value
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV VERSION_TAG="2.0.2"
|
||||
|
||||
# Set up the working directory
|
||||
#WORKDIR /Open-IM-Server
|
||||
# add all files to the container
|
||||
#COPY . .
|
||||
|
||||
COPY Open-IM-Server.tar.gz /
|
||||
COPY Open-IM-SDK-Core.tar.gz /
|
||||
|
||||
WORKDIR /
|
||||
RUN tar -zxvf Open-IM-Server.tar.gz && \
|
||||
mv Open-IM-Server-$VERSION_TAG Open-IM-Server && \
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
tar -zxvf Open-IM-SDK-Core.tar.gz && \
|
||||
rm -rf Open-IM-Server/cmd/Open-IM-SDK-Core/ && \
|
||||
mv Open-IM-SDK-Core-$VERSION_TAG Open-IM-Server/cmd/Open-IM-SDK-Core && \
|
||||
rm -rf Open-IM-Server.tar.gz
|
||||
|
||||
COPY build-open_im_msg.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
RUN chmod +x *.sh && \
|
||||
cd /Open-IM-Server/cmd && sed -i "s#GOARCH=amd64##g" `grep "amd64" -rl .` && \
|
||||
cd /Open-IM-Server/script && \
|
||||
/bin/sh -c ./build-open_im_msg.sh
|
||||
|
||||
#Blank image Multi-Stage Build
|
||||
FROM showurl/openim-base:v2.0.2
|
||||
|
||||
#set directory to map logs,config file,script file.
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||
|
||||
#Copy scripts files and binary files to the blank image
|
||||
COPY --from=build /Open-IM-Server/script /Open-IM-Server/script
|
||||
COPY --from=build /Open-IM-Server/bin /Open-IM-Server/bin
|
||||
COPY start-open_im_msg.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
|
||||
CMD ["bash", "start-open_im_msg.sh"]
|
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
serviceName="open_im_msg"
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
bin_dir="../bin"
|
||||
logs_dir="../logs"
|
||||
sdk_db_dir="../db/sdk/"
|
||||
#Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $bin_dir ]; then
|
||||
mkdir -p $bin_dir
|
||||
fi
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
if [ ! -d $sdk_db_dir ]; then
|
||||
mkdir -p $sdk_db_dir
|
||||
fi
|
||||
|
||||
#begin path
|
||||
|
||||
cd /Open-IM-Server/cmd/rpc/${serviceName} && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
|
||||
make install && echo -e "${SKY_BLUE_PREFIX}build ${serviceName} success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
|
||||
echo -e "${SKY_BLUE_PREFIX}Successful moved ${serviceName} to the bin directory${COLOR_SUFFIX}\n"
|
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
source ../setting.env
|
||||
VERSION_TAG="2.0.2"
|
||||
IMAGE_TAG="${DOCKER_REGISTRY_ADDR}open_im_msg:v$VERSION_TAG"
|
||||
|
||||
if [ ! -f "./Open-IM-SDK-Core.tar.gz" ];then
|
||||
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-Server/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-SDK-Core/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-SDK-Core.tar.gz
|
||||
|
||||
fi
|
||||
echo "下载完成" && \
|
||||
docker build . -t $IMAGE_TAG --no-cache && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
docker push $IMAGE_TAG && \
|
||||
cp development.tmp.yaml development.yaml
|
||||
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
sed -i "" "s#IMAGE_TAG#${IMAGE_TAG}#g" ./development.yaml
|
||||
sed -i "" "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
elif [[ `uname` == 'Linux' ]]; then
|
||||
sed -i "s#IMAGE_TAG#${IMAGE_TAG}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
fi
|
||||
echo "推送镜像完成" && kubectl -n ${K8S_NAMESPACE} delete -f development.yaml
|
||||
kubectl -n ${K8S_NAMESPACE} apply -f development.yaml
|
@ -0,0 +1,94 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: msg
|
||||
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: msg
|
||||
workload.msg.cattle.io/workloadselector: statefulSet-openim-msg
|
||||
serviceName: msg
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: msg
|
||||
workload.msg.cattle.io/workloadselector: statefulSet-openim-msg
|
||||
spec:
|
||||
containers:
|
||||
- image: "IMAGE_TAG"
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.hostIP
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
- name: NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.namespace
|
||||
ports:
|
||||
- name: p10300
|
||||
protocol: TCP
|
||||
containerPort: 10300
|
||||
imagePullPolicy: Always
|
||||
name: msg
|
||||
stdin: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
tty: true
|
||||
volumeMounts:
|
||||
- mountPath: /Open-IM-Server/config.tmp.yaml
|
||||
name: vol2
|
||||
readOnly: true
|
||||
subPath: config.yaml
|
||||
dnsConfig: {}
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- configMap:
|
||||
defaultMode: 256
|
||||
name: config.yaml
|
||||
optional: false
|
||||
name: vol2
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: msg
|
||||
|
||||
spec:
|
||||
ports:
|
||||
- name: p10300
|
||||
port: 10300
|
||||
protocol: TCP
|
||||
targetPort: 10300
|
||||
selector:
|
||||
app: msg
|
||||
type: ClusterIP
|
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
service_filename="open_im_msg"
|
||||
service_port_name="openImOfflineMessagePort"
|
||||
K8sServiceName="msg"
|
||||
|
||||
#Check whether the service exists
|
||||
service_name="ps -aux |grep -w ${service_filename} |grep -v grep"
|
||||
count="${service_name}| wc -l"
|
||||
|
||||
rm -rf /Open-IM-Server/config
|
||||
mkdir /Open-IM-Server/config
|
||||
cp /Open-IM-Server/config.tmp.yaml /Open-IM-Server/config/config.yaml
|
||||
sed -i "s#openim-all#$POD_NAME.$K8sServiceName.$NAMESPACE.svc.cluster.local#g" /Open-IM-Server/config/config.yaml
|
||||
|
||||
if [ $(eval ${count}) -gt 0 ]; then
|
||||
pid="${service_name}| awk '{print \$2}'"
|
||||
echo -e "${SKY_BLUE_PREFIX}${service_filename} service has been started,pid:$(eval $pid)$COLOR_SUFFIX"
|
||||
echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename} pid:$(eval $pid)${COLOR_SUFFIX}"
|
||||
#kill the service that existed
|
||||
kill -9 $(eval $pid)
|
||||
sleep 0.5
|
||||
fi
|
||||
cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename} service is starting${COLOR_SUFFIX}"
|
||||
#Get the rpc port in the configuration file
|
||||
portList=$(cat $config_path | grep ${service_port_name} | awk -F '[:]' '{print $NF}')
|
||||
list_to_string ${portList}
|
||||
#Start related rpc services based on the number of ports
|
||||
for j in ${ports_array}; do
|
||||
echo -e "${SKY_BLUE_PREFIX}${POD_NAME} Service is starting,port number:$j $COLOR_SUFFIX"
|
||||
./${service_filename} -port $j
|
||||
done
|
@ -0,0 +1,46 @@
|
||||
FROM golang as build
|
||||
|
||||
# go mod Installation source, container environment variable addition will override the default variable value
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV VERSION_TAG="2.0.2"
|
||||
|
||||
# Set up the working directory
|
||||
#WORKDIR /Open-IM-Server
|
||||
# add all files to the container
|
||||
#COPY . .
|
||||
|
||||
COPY Open-IM-Server.tar.gz /
|
||||
COPY Open-IM-SDK-Core.tar.gz /
|
||||
|
||||
WORKDIR /
|
||||
RUN tar -zxvf Open-IM-Server.tar.gz && \
|
||||
mv Open-IM-Server-$VERSION_TAG Open-IM-Server && \
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
tar -zxvf Open-IM-SDK-Core.tar.gz && \
|
||||
rm -rf Open-IM-Server/cmd/Open-IM-SDK-Core/ && \
|
||||
mv Open-IM-SDK-Core-$VERSION_TAG Open-IM-Server/cmd/Open-IM-SDK-Core && \
|
||||
rm -rf Open-IM-Server.tar.gz
|
||||
|
||||
COPY build-open_im_msg_gateway.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
RUN chmod +x *.sh && \
|
||||
cd /Open-IM-Server/cmd && sed -i "s#GOARCH=amd64##g" `grep "amd64" -rl .` && \
|
||||
cd /Open-IM-Server/script && \
|
||||
/bin/sh -c ./build-open_im_msg_gateway.sh
|
||||
|
||||
#Blank image Multi-Stage Build
|
||||
FROM showurl/openim-base:v2.0.2
|
||||
|
||||
#set directory to map logs,config file,script file.
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||
|
||||
#Copy scripts files and binary files to the blank image
|
||||
COPY --from=build /Open-IM-Server/script /Open-IM-Server/script
|
||||
COPY --from=build /Open-IM-Server/bin /Open-IM-Server/bin
|
||||
COPY start-open_im_msg_gateway.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
|
||||
CMD ["bash", "start-open_im_msg_gateway.sh"]
|
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
serviceName="open_im_msg_gateway"
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
bin_dir="../bin"
|
||||
logs_dir="../logs"
|
||||
sdk_db_dir="../db/sdk/"
|
||||
#Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $bin_dir ]; then
|
||||
mkdir -p $bin_dir
|
||||
fi
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
if [ ! -d $sdk_db_dir ]; then
|
||||
mkdir -p $sdk_db_dir
|
||||
fi
|
||||
|
||||
#begin path
|
||||
|
||||
cd /Open-IM-Server/cmd/${serviceName} && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
|
||||
make install && echo -e "${SKY_BLUE_PREFIX}build ${serviceName} success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
|
||||
echo -e "${SKY_BLUE_PREFIX}Successful moved ${serviceName} to the bin directory${COLOR_SUFFIX}\n"
|
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
source ../setting.env
|
||||
VERSION_TAG="2.0.2"
|
||||
IMAGE_TAG="${DOCKER_REGISTRY_ADDR}open_im_msg_gateway:v$VERSION_TAG"
|
||||
|
||||
if [ ! -f "./Open-IM-SDK-Core.tar.gz" ];then
|
||||
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-Server/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-SDK-Core/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-SDK-Core.tar.gz
|
||||
|
||||
fi
|
||||
echo "下载完成" && \
|
||||
docker build . -t $IMAGE_TAG --no-cache && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
docker push $IMAGE_TAG && \
|
||||
cp development.tmp.yaml development.yaml
|
||||
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
sed -i "" "s#IMAGE_TAG#${IMAGE_TAG}#g" ./development.yaml
|
||||
sed -i "" "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
elif [[ `uname` == 'Linux' ]]; then
|
||||
sed -i "s#IMAGE_TAG#${IMAGE_TAG}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
fi
|
||||
echo "推送镜像完成" && kubectl -n ${K8S_NAMESPACE} delete -f development.yaml
|
||||
kubectl -n ${K8S_NAMESPACE} apply -f development.yaml
|
@ -0,0 +1,119 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: msg-gateway
|
||||
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: msg-gateway
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-msg-gateway
|
||||
serviceName: msg-gateway
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: msg-gateway
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-msg-gateway
|
||||
spec:
|
||||
containers:
|
||||
- image: "IMAGE_TAG"
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.hostIP
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
- name: NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.namespace
|
||||
ports:
|
||||
- name: p10400
|
||||
protocol: TCP
|
||||
containerPort: 10400
|
||||
- name: p17778
|
||||
protocol: TCP
|
||||
containerPort: 17778
|
||||
imagePullPolicy: Always
|
||||
name: msg-gateway
|
||||
stdin: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
tty: true
|
||||
volumeMounts:
|
||||
- mountPath: /Open-IM-Server/config.tmp.yaml
|
||||
name: vol2
|
||||
readOnly: true
|
||||
subPath: config.yaml
|
||||
dnsConfig: {}
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- configMap:
|
||||
defaultMode: 256
|
||||
name: config.yaml
|
||||
optional: false
|
||||
name: vol2
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: msg-gateway
|
||||
|
||||
spec:
|
||||
ports:
|
||||
- name: p10400
|
||||
port: 10400
|
||||
protocol: TCP
|
||||
targetPort: 10400
|
||||
- name: p17778
|
||||
port: 17778
|
||||
protocol: TCP
|
||||
targetPort: 17778
|
||||
selector:
|
||||
app: msg-gateway
|
||||
type: ClusterIP
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: msg-gateway-remote
|
||||
|
||||
spec:
|
||||
externalTrafficPolicy: Cluster
|
||||
ports:
|
||||
- name: p17778
|
||||
nodePort: NODE_PORT_MSG_GATEWAY
|
||||
port: 17778
|
||||
protocol: TCP
|
||||
targetPort: 17778
|
||||
selector:
|
||||
app: msg-gateway
|
||||
type: NodePort
|
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
ulimit -n 200000
|
||||
|
||||
service_filename="open_im_msg_gateway"
|
||||
K8sServiceName="msg-gateway"
|
||||
binary_root="/Open-IM-Server/bin"
|
||||
|
||||
rm -rf /Open-IM-Server/config
|
||||
mkdir /Open-IM-Server/config
|
||||
cp /Open-IM-Server/config.tmp.yaml /Open-IM-Server/config/config.yaml
|
||||
sed -i "s#openim-all#$POD_NAME.$K8sServiceName.$NAMESPACE.svc.cluster.local#g" /Open-IM-Server/config/config.yaml
|
||||
|
||||
list1=$(cat $config_path | grep openImOnlineRelayPort | awk -F '[:]' '{print $NF}')
|
||||
list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}')
|
||||
list_to_string $list1
|
||||
rpc_ports=($ports_array)
|
||||
list_to_string $list2
|
||||
ws_ports=($ports_array)
|
||||
if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then
|
||||
|
||||
echo -e ${RED_PREFIX}"ws_ports does not match push_rpc_ports in quantity!!!"${COLOR_SUFFIX}
|
||||
exit 0
|
||||
|
||||
fi
|
||||
#Check if the service exists
|
||||
#If it is exists,kill this process
|
||||
check=$(ps aux | grep -w ./${service_filename} | grep -v grep | wc -l)
|
||||
if [ $check -ge 1 ]; then
|
||||
oldPid=$(ps aux | grep -w ./${service_filename} | grep -v grep | awk '{print $2}')
|
||||
kill -9 ${oldPid}
|
||||
fi
|
||||
#Waiting port recycling
|
||||
sleep 1
|
||||
cd ${binary_root}
|
||||
./${service_filename} -rpc_port ${rpc_ports[$i]} -ws_port ${ws_ports[$i]}
|
@ -0,0 +1,46 @@
|
||||
FROM golang as build
|
||||
|
||||
# go mod Installation source, container environment variable addition will override the default variable value
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV VERSION_TAG="2.0.2"
|
||||
|
||||
# Set up the working directory
|
||||
#WORKDIR /Open-IM-Server
|
||||
# add all files to the container
|
||||
#COPY . .
|
||||
|
||||
COPY Open-IM-Server.tar.gz /
|
||||
COPY Open-IM-SDK-Core.tar.gz /
|
||||
|
||||
WORKDIR /
|
||||
RUN tar -zxvf Open-IM-Server.tar.gz && \
|
||||
mv Open-IM-Server-$VERSION_TAG Open-IM-Server && \
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
tar -zxvf Open-IM-SDK-Core.tar.gz && \
|
||||
rm -rf Open-IM-Server/cmd/Open-IM-SDK-Core/ && \
|
||||
mv Open-IM-SDK-Core-$VERSION_TAG Open-IM-Server/cmd/Open-IM-SDK-Core && \
|
||||
rm -rf Open-IM-Server.tar.gz
|
||||
|
||||
COPY build-open_im_msg_transfer.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
RUN chmod +x *.sh && \
|
||||
cd /Open-IM-Server/cmd && sed -i "s#GOARCH=amd64##g" `grep "amd64" -rl .` && \
|
||||
cd /Open-IM-Server/script && \
|
||||
/bin/sh -c ./build-open_im_msg_transfer.sh
|
||||
|
||||
#Blank image Multi-Stage Build
|
||||
FROM showurl/openim-base:v2.0.2
|
||||
|
||||
#set directory to map logs,config file,script file.
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||
|
||||
#Copy scripts files and binary files to the blank image
|
||||
COPY --from=build /Open-IM-Server/script /Open-IM-Server/script
|
||||
COPY --from=build /Open-IM-Server/bin /Open-IM-Server/bin
|
||||
COPY start-open_im_msg_transfer.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
|
||||
CMD ["bash", "start-open_im_msg_transfer.sh"]
|
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
serviceName="open_im_msg_transfer"
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
bin_dir="../bin"
|
||||
logs_dir="../logs"
|
||||
sdk_db_dir="../db/sdk/"
|
||||
#Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $bin_dir ]; then
|
||||
mkdir -p $bin_dir
|
||||
fi
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
if [ ! -d $sdk_db_dir ]; then
|
||||
mkdir -p $sdk_db_dir
|
||||
fi
|
||||
|
||||
#begin path
|
||||
|
||||
cd /Open-IM-Server/cmd/${serviceName} && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
|
||||
make install && echo -e "${SKY_BLUE_PREFIX}build ${serviceName} success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
|
||||
echo -e "${SKY_BLUE_PREFIX}Successful moved ${serviceName} to the bin directory${COLOR_SUFFIX}\n"
|
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
source ../setting.env
|
||||
VERSION_TAG="2.0.2"
|
||||
IMAGE_TAG="${DOCKER_REGISTRY_ADDR}open_im_msg_transfer:v$VERSION_TAG"
|
||||
|
||||
if [ ! -f "./Open-IM-SDK-Core.tar.gz" ];then
|
||||
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-Server/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-SDK-Core/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-SDK-Core.tar.gz
|
||||
|
||||
fi
|
||||
echo "下载完成" && \
|
||||
docker build . -t $IMAGE_TAG --no-cache && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
docker push $IMAGE_TAG && \
|
||||
cp development.tmp.yaml development.yaml
|
||||
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
sed -i "" "s#IMAGE_TAG#${IMAGE_TAG}#g" ./development.yaml
|
||||
sed -i "" "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
elif [[ `uname` == 'Linux' ]]; then
|
||||
sed -i "s#IMAGE_TAG#${IMAGE_TAG}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
fi
|
||||
echo "推送镜像完成" && kubectl -n ${K8S_NAMESPACE} delete -f development.yaml
|
||||
kubectl -n ${K8S_NAMESPACE} apply -f development.yaml
|
@ -0,0 +1,75 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: msg-transfer
|
||||
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: msg-transfer
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-msg-transfer
|
||||
serviceName: msg-transfer
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: msg-transfer
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-msg-transfer
|
||||
spec:
|
||||
containers:
|
||||
- image: "IMAGE_TAG"
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.hostIP
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
- name: NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.namespace
|
||||
imagePullPolicy: Always
|
||||
name: msg-transfer
|
||||
stdin: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
tty: true
|
||||
volumeMounts:
|
||||
- mountPath: /Open-IM-Server/config.tmp.yaml
|
||||
name: vol2
|
||||
readOnly: true
|
||||
subPath: config.yaml
|
||||
dnsConfig: {}
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- configMap:
|
||||
defaultMode: 256
|
||||
name: config.yaml
|
||||
optional: false
|
||||
name: vol2
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
ulimit -n 200000
|
||||
|
||||
service_filename="open_im_msg_transfer"
|
||||
K8sServiceName="msg-transfer"
|
||||
binary_root="/Open-IM-Server/bin"
|
||||
|
||||
rm -rf /Open-IM-Server/config
|
||||
mkdir /Open-IM-Server/config
|
||||
cp /Open-IM-Server/config.tmp.yaml /Open-IM-Server/config/config.yaml
|
||||
sed -i "s#openim-all#$POD_NAME.$K8sServiceName.$NAMESPACE.svc.cluster.local#g" /Open-IM-Server/config/config.yaml
|
||||
|
||||
list1=$(cat $config_path | grep openImOnlineRelayPort | awk -F '[:]' '{print $NF}')
|
||||
list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}')
|
||||
list_to_string $list1
|
||||
rpc_ports=($ports_array)
|
||||
list_to_string $list2
|
||||
ws_ports=($ports_array)
|
||||
if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then
|
||||
|
||||
echo -e ${RED_PREFIX}"ws_ports does not match push_rpc_ports in quantity!!!"${COLOR_SUFFIX}
|
||||
exit 0
|
||||
|
||||
fi
|
||||
#Check if the service exists
|
||||
#If it is exists,kill this process
|
||||
check=$(ps aux | grep -w ./${service_filename} | grep -v grep | wc -l)
|
||||
if [ $check -ge 1 ]; then
|
||||
oldPid=$(ps aux | grep -w ./${service_filename} | grep -v grep | awk '{print $2}')
|
||||
kill -9 ${oldPid}
|
||||
fi
|
||||
#Waiting port recycling
|
||||
sleep 1
|
||||
cd ${binary_root}
|
||||
./${service_filename} -rpc_port ${rpc_ports[$i]} -ws_port ${ws_ports[$i]}
|
@ -0,0 +1,46 @@
|
||||
FROM golang as build
|
||||
|
||||
# go mod Installation source, container environment variable addition will override the default variable value
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV VERSION_TAG="2.0.2"
|
||||
|
||||
# Set up the working directory
|
||||
#WORKDIR /Open-IM-Server
|
||||
# add all files to the container
|
||||
#COPY . .
|
||||
|
||||
COPY Open-IM-Server.tar.gz /
|
||||
COPY Open-IM-SDK-Core.tar.gz /
|
||||
|
||||
WORKDIR /
|
||||
RUN tar -zxvf Open-IM-Server.tar.gz && \
|
||||
mv Open-IM-Server-$VERSION_TAG Open-IM-Server && \
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
tar -zxvf Open-IM-SDK-Core.tar.gz && \
|
||||
rm -rf Open-IM-Server/cmd/Open-IM-SDK-Core/ && \
|
||||
mv Open-IM-SDK-Core-$VERSION_TAG Open-IM-Server/cmd/Open-IM-SDK-Core && \
|
||||
rm -rf Open-IM-Server.tar.gz
|
||||
|
||||
COPY build-open_im_push.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
RUN chmod +x *.sh && \
|
||||
cd /Open-IM-Server/cmd && sed -i "s#GOARCH=amd64##g" `grep "amd64" -rl .` && \
|
||||
cd /Open-IM-Server/script && \
|
||||
/bin/sh -c ./build-open_im_push.sh
|
||||
|
||||
#Blank image Multi-Stage Build
|
||||
FROM showurl/openim-base:v2.0.2
|
||||
|
||||
#set directory to map logs,config file,script file.
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||
|
||||
#Copy scripts files and binary files to the blank image
|
||||
COPY --from=build /Open-IM-Server/script /Open-IM-Server/script
|
||||
COPY --from=build /Open-IM-Server/bin /Open-IM-Server/bin
|
||||
COPY start-open_im_push.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
|
||||
CMD ["bash", "start-open_im_push.sh"]
|
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
serviceName="open_im_push"
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
bin_dir="../bin"
|
||||
logs_dir="../logs"
|
||||
sdk_db_dir="../db/sdk/"
|
||||
#Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $bin_dir ]; then
|
||||
mkdir -p $bin_dir
|
||||
fi
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
if [ ! -d $sdk_db_dir ]; then
|
||||
mkdir -p $sdk_db_dir
|
||||
fi
|
||||
|
||||
#begin path
|
||||
|
||||
cd /Open-IM-Server/cmd/${serviceName} && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
|
||||
make install && echo -e "${SKY_BLUE_PREFIX}build ${serviceName} success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
|
||||
echo -e "${SKY_BLUE_PREFIX}Successful moved ${serviceName} to the bin directory${COLOR_SUFFIX}\n"
|
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
source ../setting.env
|
||||
VERSION_TAG="2.0.2"
|
||||
IMAGE_TAG="${DOCKER_REGISTRY_ADDR}open_im_push:v$VERSION_TAG"
|
||||
|
||||
if [ ! -f "./Open-IM-SDK-Core.tar.gz" ];then
|
||||
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-Server/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-SDK-Core/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-SDK-Core.tar.gz
|
||||
|
||||
fi
|
||||
echo "下载完成" && \
|
||||
docker build . -t $IMAGE_TAG --no-cache && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
docker push $IMAGE_TAG && \
|
||||
cp development.tmp.yaml development.yaml
|
||||
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
sed -i "" "s#IMAGE_TAG#${IMAGE_TAG}#g" ./development.yaml
|
||||
sed -i "" "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
elif [[ `uname` == 'Linux' ]]; then
|
||||
sed -i "s#IMAGE_TAG#${IMAGE_TAG}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
fi
|
||||
echo "推送镜像完成" && kubectl -n ${K8S_NAMESPACE} delete -f development.yaml
|
||||
kubectl -n ${K8S_NAMESPACE} apply -f development.yaml
|
@ -0,0 +1,94 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: push
|
||||
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: push
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-push
|
||||
serviceName: push
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: push
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-push
|
||||
spec:
|
||||
containers:
|
||||
- image: "IMAGE_TAG"
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.hostIP
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
- name: NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.namespace
|
||||
ports:
|
||||
- name: p10700
|
||||
protocol: TCP
|
||||
containerPort: 10700
|
||||
imagePullPolicy: Always
|
||||
name: push
|
||||
stdin: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
tty: true
|
||||
volumeMounts:
|
||||
- mountPath: /Open-IM-Server/config.tmp.yaml
|
||||
name: vol2
|
||||
readOnly: true
|
||||
subPath: config.yaml
|
||||
dnsConfig: {}
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- configMap:
|
||||
defaultMode: 256
|
||||
name: config.yaml
|
||||
optional: false
|
||||
name: vol2
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: push
|
||||
|
||||
spec:
|
||||
ports:
|
||||
- name: p10700
|
||||
port: 10700
|
||||
protocol: TCP
|
||||
targetPort: 10700
|
||||
selector:
|
||||
app: push
|
||||
type: ClusterIP
|
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
ulimit -n 200000
|
||||
|
||||
service_filename="open_im_push"
|
||||
K8sServiceName="push"
|
||||
binary_root="/Open-IM-Server/bin"
|
||||
|
||||
rm -rf /Open-IM-Server/config
|
||||
mkdir /Open-IM-Server/config
|
||||
cp /Open-IM-Server/config.tmp.yaml /Open-IM-Server/config/config.yaml
|
||||
sed -i "s#openim-all#$POD_NAME.$K8sServiceName.$NAMESPACE.svc.cluster.local#g" /Open-IM-Server/config/config.yaml
|
||||
|
||||
|
||||
list1=$(cat $config_path | grep openImPushPort | awk -F '[:]' '{print $NF}')
|
||||
list_to_string $list1
|
||||
rpc_ports=($ports_array)
|
||||
|
||||
#Check if the service exists
|
||||
#If it is exists,kill this process
|
||||
check=$(ps aux | grep -w ./${service_filename} | grep -v grep | wc -l)
|
||||
if [ $check -ge 1 ]; then
|
||||
oldPid=$(ps aux | grep -w ./${service_filename} | grep -v grep | awk '{print $2}')
|
||||
kill -9 ${oldPid}
|
||||
fi
|
||||
#Waiting port recycling
|
||||
sleep 1
|
||||
cd ${binary_root}
|
||||
./${service_filename} -port ${rpc_ports[$i]}
|
@ -0,0 +1,48 @@
|
||||
FROM golang as build
|
||||
|
||||
# go mod Installation source, container environment variable addition will override the default variable value
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV VERSION_TAG="2.0.2"
|
||||
|
||||
# Set up the working directory
|
||||
#WORKDIR /Open-IM-Server
|
||||
# add all files to the container
|
||||
#COPY . .
|
||||
|
||||
COPY Open-IM-Server.tar.gz /
|
||||
COPY Open-IM-SDK-Core.tar.gz /
|
||||
|
||||
WORKDIR /
|
||||
RUN tar -zxvf Open-IM-Server.tar.gz && \
|
||||
mv Open-IM-Server-$VERSION_TAG Open-IM-Server && \
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
tar -zxvf Open-IM-SDK-Core.tar.gz && \
|
||||
rm -rf Open-IM-Server/cmd/Open-IM-SDK-Core/ && \
|
||||
mv Open-IM-SDK-Core-$VERSION_TAG Open-IM-Server/cmd/Open-IM-SDK-Core && \
|
||||
rm -rf Open-IM-Server.tar.gz
|
||||
RUN rm -rf /Open-IM-Server/cmd/Open-IM-SDK-Core/ws_wrapper/cmd/open_im_sdk_server.go
|
||||
COPY open_im_sdk_server.go /Open-IM-Server/cmd/Open-IM-SDK-Core/ws_wrapper/cmd
|
||||
COPY build-open_im_sdk_server.sh /Open-IM-Server/script
|
||||
COPY serverip.go /Open-IM-Server/cmd/Open-IM-SDK-Core/ws_wrapper/utils
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
RUN chmod +x *.sh && \
|
||||
cd /Open-IM-Server/cmd && sed -i "s#GOARCH=amd64##g" `grep "amd64" -rl .` && \
|
||||
cd /Open-IM-Server/script && \
|
||||
/bin/sh -c ./build-open_im_sdk_server.sh
|
||||
|
||||
#Blank image Multi-Stage Build
|
||||
FROM showurl/openim-base:v2.0.2
|
||||
|
||||
#set directory to map logs,config file,script file.
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||
|
||||
#Copy scripts files and binary files to the blank image
|
||||
COPY --from=build /Open-IM-Server/script /Open-IM-Server/script
|
||||
COPY --from=build /Open-IM-Server/bin /Open-IM-Server/bin
|
||||
COPY start-open_im_sdk_server.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
|
||||
CMD ["bash", "start-open_im_sdk_server.sh"]
|
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
serviceName="Open-IM-SDK-Core"
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
bin_dir="../bin"
|
||||
logs_dir="../logs"
|
||||
sdk_db_dir="../db/sdk/"
|
||||
#Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $bin_dir ]; then
|
||||
mkdir -p $bin_dir
|
||||
fi
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
if [ ! -d $sdk_db_dir ]; then
|
||||
mkdir -p $sdk_db_dir
|
||||
fi
|
||||
|
||||
#begin path
|
||||
cd /Open-IM-Server/cmd/${serviceName} && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
|
||||
make install && echo -e "${SKY_BLUE_PREFIX}build ${serviceName} success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
|
||||
echo -e "${SKY_BLUE_PREFIX}Successful moved ${serviceName} to the bin directory${COLOR_SUFFIX}\n"
|
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
source ../setting.env
|
||||
VERSION_TAG="2.0.2"
|
||||
IMAGE_TAG="${DOCKER_REGISTRY_ADDR}open_im_sdk_server:v$VERSION_TAG"
|
||||
|
||||
if [ ! -f "./Open-IM-SDK-Core.tar.gz" ];then
|
||||
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-Server/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-SDK-Core/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-SDK-Core.tar.gz
|
||||
|
||||
fi
|
||||
echo "下载完成" && \
|
||||
docker build . -t $IMAGE_TAG --no-cache && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
docker push $IMAGE_TAG && \
|
||||
cp development.tmp.yaml development.yaml
|
||||
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
sed -i "" "s#IMAGE_TAG#${IMAGE_TAG}#g" ./development.yaml
|
||||
sed -i "" "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
elif [[ `uname` == 'Linux' ]]; then
|
||||
sed -i "s#IMAGE_TAG#${IMAGE_TAG}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
fi
|
||||
echo "推送镜像完成" && kubectl -n ${K8S_NAMESPACE} delete -f development.yaml
|
||||
kubectl -n ${K8S_NAMESPACE} apply -f development.yaml
|
@ -0,0 +1,96 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: sdk-server
|
||||
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: sdk-server
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-sdk-server
|
||||
serviceName: sdk-server
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: sdk-server
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-sdk-server
|
||||
spec:
|
||||
containers:
|
||||
- image: "IMAGE_TAG"
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.hostIP
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
- name: NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.namespace
|
||||
ports:
|
||||
- name: p30000
|
||||
protocol: TCP
|
||||
containerPort: 30000
|
||||
imagePullPolicy: Always
|
||||
name: sdk-server
|
||||
stdin: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
tty: true
|
||||
volumeMounts:
|
||||
- mountPath: /Open-IM-Server/config.tmp.yaml
|
||||
name: vol2
|
||||
readOnly: true
|
||||
subPath: config.yaml
|
||||
dnsConfig: {}
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- configMap:
|
||||
defaultMode: 256
|
||||
name: config.yaml
|
||||
optional: false
|
||||
name: vol2
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: sdk-server-remote
|
||||
|
||||
spec:
|
||||
externalTrafficPolicy: Cluster
|
||||
ports:
|
||||
- name: p30000
|
||||
nodePort: NODE_PORT_SDK_SERVER
|
||||
port: 30000
|
||||
protocol: TCP
|
||||
targetPort: 30000
|
||||
selector:
|
||||
app: sdk-server
|
||||
type: NodePort
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
** description("").
|
||||
** copyright('open-im,www.open-im.io').
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/9/8 14:35).
|
||||
*/
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"open_im_sdk/sdk_struct"
|
||||
|
||||
//"open_im_sdk/open_im_sdk"
|
||||
"open_im_sdk/pkg/log"
|
||||
"open_im_sdk/ws_wrapper/utils"
|
||||
"open_im_sdk/ws_wrapper/ws_local_server"
|
||||
"runtime"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var sdkWsPort, openIMApiPort, openIMWsPort *int
|
||||
var openIMWsAddress, openIMApiAddress *string
|
||||
//
|
||||
//openIMTerminalType := flag.String("terminal_type", "web", "different terminal types")
|
||||
|
||||
sdkWsPort = flag.Int("sdk_ws_port", 30000, "openIMSDK ws listening port")
|
||||
openIMApiPort = flag.Int("openIM_api_port", 10000, "openIM api listening port")
|
||||
openIMWsPort = flag.Int("openIM_ws_port", 17778, "openIM ws listening port")
|
||||
flag.Parse()
|
||||
//switch *openIMTerminalType {
|
||||
//case "pc":
|
||||
// openIMWsAddress = flag.String("openIM_ws_address", "web", "different terminal types")
|
||||
// openIMApiAddress = flag.String("openIM_api_address", "web", "different terminal types")
|
||||
// flag.Parse()
|
||||
//case "web":
|
||||
// openIMApiPort = flag.Int("openIM_api_port", 0, "openIM api listening port")
|
||||
// openIMWsPort = flag.Int("openIM_ws_port", 0, "openIM ws listening port")
|
||||
// flag.Parse()
|
||||
//}
|
||||
APIADDR := "http://1.14.194.38:10000"
|
||||
WSADDR := "ws://1.14.194.38:17778"
|
||||
|
||||
sysType := runtime.GOOS
|
||||
switch sysType {
|
||||
|
||||
case "darwin":
|
||||
ws_local_server.InitServer(&sdk_struct.IMConfig{ApiAddr: *openIMApiAddress,
|
||||
WsAddr: *openIMWsAddress, Platform: utils.OSXPlatformID, DataDir: "./"})
|
||||
case "linux":
|
||||
//sdkDBDir:= flag.String("sdk_db_dir","","openIMSDK initialization path")
|
||||
ws_local_server.InitServer(&sdk_struct.IMConfig{ApiAddr: "http://" + utils.ApiServerIP + ":" + utils.IntToString(*openIMApiPort),
|
||||
WsAddr: "ws://" + utils.WsServerIP + ":" + utils.IntToString(*openIMWsPort), Platform: utils.WebPlatformID, DataDir: "../db/sdk/"})
|
||||
|
||||
case "windows":
|
||||
// sdkWsPort = flag.Int("sdk_ws_port", 7799, "openIM ws listening port")
|
||||
//flag.Parse()
|
||||
ws_local_server.InitServer(&sdk_struct.IMConfig{ApiAddr: APIADDR,
|
||||
WsAddr: WSADDR, Platform: utils.WebPlatformID, DataDir: "./"})
|
||||
default:
|
||||
fmt.Println("this os not support", sysType)
|
||||
|
||||
}
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
log.NewPrivateLog("sdk", 6)
|
||||
fmt.Println("ws server is starting")
|
||||
ws_local_server.WS.OnInit(*sdkWsPort)
|
||||
ws_local_server.WS.Run()
|
||||
wg.Wait()
|
||||
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package utils
|
||||
|
||||
const (
|
||||
ApiServerIP = "api"
|
||||
WsServerIP = "msg-gateway"
|
||||
)
|
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
ulimit -n 200000
|
||||
|
||||
|
||||
service_filename="open_im_sdk_server"
|
||||
binary_root="/Open-IM-Server/bin"
|
||||
K8sServiceName="sdk-server"
|
||||
K8sServiceNameForApi="api"
|
||||
rm -rf /Open-IM-Server/config
|
||||
mkdir /Open-IM-Server/config
|
||||
cp /Open-IM-Server/config.tmp.yaml /Open-IM-Server/config/config.yaml
|
||||
sed -i "s#openim-all#$K8sServiceNameForApi.$NAMESPACE#g" /Open-IM-Server/config/config.yaml
|
||||
|
||||
list1=$(cat $config_path | grep openImApiPort | awk -F '[:]' '{print $NF}')
|
||||
list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}')
|
||||
list3=$(cat $config_path | grep openImSdkWsPort | awk -F '[:]' '{print $NF}')
|
||||
logLevel=$(cat $config_path | grep remainLogLevel | awk -F '[:]' '{print $NF}')
|
||||
list_to_string $list1
|
||||
api_ports=($ports_array)
|
||||
list_to_string $list2
|
||||
ws_ports=($ports_array)
|
||||
list_to_string $list3
|
||||
sdk_ws_ports=($ports_array)
|
||||
list_to_string $list4
|
||||
|
||||
|
||||
check=$(ps aux | grep -w ./${service_filename} | grep -v grep | wc -l)
|
||||
if [ $check -ge 1 ]; then
|
||||
oldPid=$(ps aux | grep -w ./${service_filename} | grep -v grep | awk '{print $2}')
|
||||
kill -9 ${oldPid}
|
||||
fi
|
||||
#Check if the service exists
|
||||
#If it is exists,kill this process
|
||||
check=$(ps aux | grep -w ./${service_filename} | grep -v grep | wc -l)
|
||||
if [ $check -ge 1 ]; then
|
||||
oldPid=$(ps aux | grep -w ./${service_filename} | grep -v grep | awk '{print $2}')
|
||||
kill -9 ${oldPid}
|
||||
fi
|
||||
#Waiting port recycling
|
||||
sleep 1
|
||||
cd ${binary_root}
|
||||
./${service_filename} -openIM_api_port ${api_ports[0]} -openIM_ws_port ${ws_ports[0]} -sdk_ws_port ${sdk_ws_ports[0]}
|
@ -0,0 +1,46 @@
|
||||
FROM golang as build
|
||||
|
||||
# go mod Installation source, container environment variable addition will override the default variable value
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV VERSION_TAG="2.0.2"
|
||||
|
||||
# Set up the working directory
|
||||
#WORKDIR /Open-IM-Server
|
||||
# add all files to the container
|
||||
#COPY . .
|
||||
|
||||
COPY Open-IM-Server.tar.gz /
|
||||
COPY Open-IM-SDK-Core.tar.gz /
|
||||
|
||||
WORKDIR /
|
||||
RUN tar -zxvf Open-IM-Server.tar.gz && \
|
||||
mv Open-IM-Server-$VERSION_TAG Open-IM-Server && \
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
tar -zxvf Open-IM-SDK-Core.tar.gz && \
|
||||
rm -rf Open-IM-Server/cmd/Open-IM-SDK-Core/ && \
|
||||
mv Open-IM-SDK-Core-$VERSION_TAG Open-IM-Server/cmd/Open-IM-SDK-Core && \
|
||||
rm -rf Open-IM-Server.tar.gz
|
||||
|
||||
COPY build-open_im_statistics.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
RUN chmod +x *.sh && \
|
||||
cd /Open-IM-Server/cmd && sed -i "s#GOARCH=amd64##g" `grep "amd64" -rl .` && \
|
||||
cd /Open-IM-Server/script && \
|
||||
/bin/sh -c ./build-open_im_statistics.sh
|
||||
|
||||
#Blank image Multi-Stage Build
|
||||
FROM showurl/openim-base:v2.0.2
|
||||
|
||||
#set directory to map logs,config file,script file.
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||
|
||||
#Copy scripts files and binary files to the blank image
|
||||
COPY --from=build /Open-IM-Server/script /Open-IM-Server/script
|
||||
COPY --from=build /Open-IM-Server/bin /Open-IM-Server/bin
|
||||
COPY start-open_im_statistics.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
|
||||
CMD ["bash", "start-open_im_statistics.sh"]
|
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
serviceName="open_im_statistics"
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
bin_dir="../bin"
|
||||
logs_dir="../logs"
|
||||
sdk_db_dir="../db/sdk/"
|
||||
#Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $bin_dir ]; then
|
||||
mkdir -p $bin_dir
|
||||
fi
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
if [ ! -d $sdk_db_dir ]; then
|
||||
mkdir -p $sdk_db_dir
|
||||
fi
|
||||
|
||||
#begin path
|
||||
|
||||
cd /Open-IM-Server/cmd/rpc/${serviceName} && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
|
||||
make install && echo -e "${SKY_BLUE_PREFIX}build ${serviceName} success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
|
||||
echo -e "${SKY_BLUE_PREFIX}Successful moved ${serviceName} to the bin directory${COLOR_SUFFIX}\n"
|
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
source ../setting.env
|
||||
VERSION_TAG="2.0.2"
|
||||
IMAGE_TAG="${DOCKER_REGISTRY_ADDR}open_im_statistics:v$VERSION_TAG"
|
||||
|
||||
if [ ! -f "./Open-IM-SDK-Core.tar.gz" ];then
|
||||
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-Server/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-SDK-Core/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-SDK-Core.tar.gz
|
||||
|
||||
fi
|
||||
echo "下载完成" && \
|
||||
docker build . -t $IMAGE_TAG --no-cache && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
docker push $IMAGE_TAG && \
|
||||
cp development.tmp.yaml development.yaml
|
||||
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
sed -i "" "s#IMAGE_TAG#${IMAGE_TAG}#g" ./development.yaml
|
||||
sed -i "" "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
elif [[ `uname` == 'Linux' ]]; then
|
||||
sed -i "s#IMAGE_TAG#${IMAGE_TAG}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
fi
|
||||
echo "推送镜像完成" && kubectl -n ${K8S_NAMESPACE} delete -f development.yaml
|
||||
kubectl -n ${K8S_NAMESPACE} apply -f development.yaml
|
@ -0,0 +1,94 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: statistics
|
||||
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: statistics
|
||||
workload.statistics.cattle.io/workloadselector: statefulSet-openim-statistics
|
||||
serviceName: statistics
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: statistics
|
||||
workload.statistics.cattle.io/workloadselector: statefulSet-openim-statistics
|
||||
spec:
|
||||
containers:
|
||||
- image: "IMAGE_TAG"
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.hostIP
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
- name: NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.namespace
|
||||
ports:
|
||||
- name: p10800
|
||||
protocol: TCP
|
||||
containerPort: 10800
|
||||
imagePullPolicy: Always
|
||||
name: statistics
|
||||
stdin: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
tty: true
|
||||
volumeMounts:
|
||||
- mountPath: /Open-IM-Server/config.tmp.yaml
|
||||
name: vol2
|
||||
readOnly: true
|
||||
subPath: config.yaml
|
||||
dnsConfig: {}
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- configMap:
|
||||
defaultMode: 256
|
||||
name: config.yaml
|
||||
optional: false
|
||||
name: vol2
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: statistics
|
||||
|
||||
spec:
|
||||
ports:
|
||||
- name: p10800
|
||||
port: 10800
|
||||
protocol: TCP
|
||||
targetPort: 10800
|
||||
selector:
|
||||
app: statistics
|
||||
type: ClusterIP
|
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
service_filename="open_im_statistics"
|
||||
service_port_name="openImStatisticsPort"
|
||||
K8sServiceName="statistics"
|
||||
|
||||
#Check whether the service exists
|
||||
service_name="ps -aux |grep -w ${service_filename} |grep -v grep"
|
||||
count="${service_name}| wc -l"
|
||||
|
||||
rm -rf /Open-IM-Server/config
|
||||
mkdir /Open-IM-Server/config
|
||||
cp /Open-IM-Server/config.tmp.yaml /Open-IM-Server/config/config.yaml
|
||||
sed -i "s#openim-all#$POD_NAME.$K8sServiceName.$NAMESPACE.svc.cluster.local#g" /Open-IM-Server/config/config.yaml
|
||||
|
||||
if [ $(eval ${count}) -gt 0 ]; then
|
||||
pid="${service_name}| awk '{print \$2}'"
|
||||
echo -e "${SKY_BLUE_PREFIX}${service_filename} service has been started,pid:$(eval $pid)$COLOR_SUFFIX"
|
||||
echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename} pid:$(eval $pid)${COLOR_SUFFIX}"
|
||||
#kill the service that existed
|
||||
kill -9 $(eval $pid)
|
||||
sleep 0.5
|
||||
fi
|
||||
cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename} service is starting${COLOR_SUFFIX}"
|
||||
#Get the rpc port in the configuration file
|
||||
portList=$(cat $config_path | grep ${service_port_name} | awk -F '[:]' '{print $NF}')
|
||||
list_to_string ${portList}
|
||||
#Start related rpc services based on the number of ports
|
||||
for j in ${ports_array}; do
|
||||
echo -e "${SKY_BLUE_PREFIX}${POD_NAME} Service is starting,port number:$j $COLOR_SUFFIX"
|
||||
./${service_filename} -port $j
|
||||
done
|
@ -0,0 +1,46 @@
|
||||
FROM golang as build
|
||||
|
||||
# go mod Installation source, container environment variable addition will override the default variable value
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV VERSION_TAG="2.0.2"
|
||||
|
||||
# Set up the working directory
|
||||
#WORKDIR /Open-IM-Server
|
||||
# add all files to the container
|
||||
#COPY . .
|
||||
|
||||
COPY Open-IM-Server.tar.gz /
|
||||
COPY Open-IM-SDK-Core.tar.gz /
|
||||
|
||||
WORKDIR /
|
||||
RUN tar -zxvf Open-IM-Server.tar.gz && \
|
||||
mv Open-IM-Server-$VERSION_TAG Open-IM-Server && \
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
tar -zxvf Open-IM-SDK-Core.tar.gz && \
|
||||
rm -rf Open-IM-Server/cmd/Open-IM-SDK-Core/ && \
|
||||
mv Open-IM-SDK-Core-$VERSION_TAG Open-IM-Server/cmd/Open-IM-SDK-Core && \
|
||||
rm -rf Open-IM-Server.tar.gz
|
||||
|
||||
COPY build-open_im_timer_task.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
RUN chmod +x *.sh && \
|
||||
cd /Open-IM-Server/cmd && sed -i "s#GOARCH=amd64##g" `grep "amd64" -rl .` && \
|
||||
cd /Open-IM-Server/script && \
|
||||
/bin/sh -c ./build-open_im_timer_task.sh
|
||||
|
||||
#Blank image Multi-Stage Build
|
||||
FROM showurl/openim-base:v2.0.2
|
||||
|
||||
#set directory to map logs,config file,script file.
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||
|
||||
#Copy scripts files and binary files to the blank image
|
||||
COPY --from=build /Open-IM-Server/script /Open-IM-Server/script
|
||||
COPY --from=build /Open-IM-Server/bin /Open-IM-Server/bin
|
||||
COPY start-open_im_timer_task.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
|
||||
CMD ["bash", "start-open_im_timer_task.sh"]
|
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
serviceName="open_im_timer_task"
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
bin_dir="../bin"
|
||||
logs_dir="../logs"
|
||||
sdk_db_dir="../db/sdk/"
|
||||
#Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $bin_dir ]; then
|
||||
mkdir -p $bin_dir
|
||||
fi
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
if [ ! -d $sdk_db_dir ]; then
|
||||
mkdir -p $sdk_db_dir
|
||||
fi
|
||||
|
||||
#begin path
|
||||
|
||||
cd /Open-IM-Server/cmd/${serviceName} && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
|
||||
make install && echo -e "${SKY_BLUE_PREFIX}build ${serviceName} success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
|
||||
echo -e "${SKY_BLUE_PREFIX}Successful moved ${serviceName} to the bin directory${COLOR_SUFFIX}\n"
|
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
source ../setting.env
|
||||
VERSION_TAG="2.0.2"
|
||||
IMAGE_TAG="${DOCKER_REGISTRY_ADDR}open_im_timer_task:v$VERSION_TAG"
|
||||
|
||||
if [ ! -f "./Open-IM-SDK-Core.tar.gz" ];then
|
||||
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-Server/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-SDK-Core/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-SDK-Core.tar.gz
|
||||
|
||||
fi
|
||||
echo "下载完成" && \
|
||||
docker build . -t $IMAGE_TAG --no-cache && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
docker push $IMAGE_TAG && \
|
||||
cp development.tmp.yaml development.yaml
|
||||
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
sed -i "" "s#IMAGE_TAG#${IMAGE_TAG}#g" ./development.yaml
|
||||
sed -i "" "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
elif [[ `uname` == 'Linux' ]]; then
|
||||
sed -i "s#IMAGE_TAG#${IMAGE_TAG}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
fi
|
||||
echo "推送镜像完成" && kubectl -n ${K8S_NAMESPACE} delete -f development.yaml
|
||||
kubectl -n ${K8S_NAMESPACE} apply -f development.yaml
|
@ -0,0 +1,75 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: timer-task
|
||||
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: timer-task
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-timer-task
|
||||
serviceName: timer-task
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: timer-task
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-timer-task
|
||||
spec:
|
||||
containers:
|
||||
- image: "IMAGE_TAG"
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.hostIP
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
- name: NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.namespace
|
||||
imagePullPolicy: Always
|
||||
name: timer-task
|
||||
stdin: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
tty: true
|
||||
volumeMounts:
|
||||
- mountPath: /Open-IM-Server/config.tmp.yaml
|
||||
name: vol2
|
||||
readOnly: true
|
||||
subPath: config.yaml
|
||||
dnsConfig: {}
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- configMap:
|
||||
defaultMode: 256
|
||||
name: config.yaml
|
||||
optional: false
|
||||
name: vol2
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
ulimit -n 200000
|
||||
|
||||
service_filename="open_im_timer_task"
|
||||
K8sServiceName="timer-task"
|
||||
binary_root="/Open-IM-Server/bin"
|
||||
|
||||
rm -rf /Open-IM-Server/config
|
||||
mkdir /Open-IM-Server/config
|
||||
cp /Open-IM-Server/config.tmp.yaml /Open-IM-Server/config/config.yaml
|
||||
sed -i "s#openim-all#$POD_NAME.$K8sServiceName.$NAMESPACE.svc.cluster.local#g" /Open-IM-Server/config/config.yaml
|
||||
|
||||
list1=$(cat $config_path | grep openImOnlineRelayPort | awk -F '[:]' '{print $NF}')
|
||||
list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}')
|
||||
list_to_string $list1
|
||||
rpc_ports=($ports_array)
|
||||
list_to_string $list2
|
||||
ws_ports=($ports_array)
|
||||
if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then
|
||||
|
||||
echo -e ${RED_PREFIX}"ws_ports does not match push_rpc_ports in quantity!!!"${COLOR_SUFFIX}
|
||||
exit 0
|
||||
|
||||
fi
|
||||
#Check if the service exists
|
||||
#If it is exists,kill this process
|
||||
check=$(ps aux | grep -w ./${service_filename} | grep -v grep | wc -l)
|
||||
if [ $check -ge 1 ]; then
|
||||
oldPid=$(ps aux | grep -w ./${service_filename} | grep -v grep | awk '{print $2}')
|
||||
kill -9 ${oldPid}
|
||||
fi
|
||||
#Waiting port recycling
|
||||
sleep 1
|
||||
cd ${binary_root}
|
||||
./${service_filename}
|
@ -0,0 +1,46 @@
|
||||
FROM golang as build
|
||||
|
||||
# go mod Installation source, container environment variable addition will override the default variable value
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV VERSION_TAG="2.0.2"
|
||||
|
||||
# Set up the working directory
|
||||
#WORKDIR /Open-IM-Server
|
||||
# add all files to the container
|
||||
#COPY . .
|
||||
|
||||
COPY Open-IM-Server.tar.gz /
|
||||
COPY Open-IM-SDK-Core.tar.gz /
|
||||
|
||||
WORKDIR /
|
||||
RUN tar -zxvf Open-IM-Server.tar.gz && \
|
||||
mv Open-IM-Server-$VERSION_TAG Open-IM-Server && \
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
tar -zxvf Open-IM-SDK-Core.tar.gz && \
|
||||
rm -rf Open-IM-Server/cmd/Open-IM-SDK-Core/ && \
|
||||
mv Open-IM-SDK-Core-$VERSION_TAG Open-IM-Server/cmd/Open-IM-SDK-Core && \
|
||||
rm -rf Open-IM-Server.tar.gz
|
||||
|
||||
COPY build-open_im_user.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
RUN chmod +x *.sh && \
|
||||
cd /Open-IM-Server/cmd && sed -i "s#GOARCH=amd64##g" `grep "amd64" -rl .` && \
|
||||
cd /Open-IM-Server/script && \
|
||||
/bin/sh -c ./build-open_im_user.sh
|
||||
|
||||
#Blank image Multi-Stage Build
|
||||
FROM showurl/openim-base:v2.0.2
|
||||
|
||||
#set directory to map logs,config file,script file.
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||
|
||||
#Copy scripts files and binary files to the blank image
|
||||
COPY --from=build /Open-IM-Server/script /Open-IM-Server/script
|
||||
COPY --from=build /Open-IM-Server/bin /Open-IM-Server/bin
|
||||
COPY start-open_im_user.sh /Open-IM-Server/script
|
||||
|
||||
WORKDIR /Open-IM-Server/script
|
||||
|
||||
CMD ["bash", "start-open_im_user.sh"]
|
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
serviceName="open_im_user"
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
bin_dir="../bin"
|
||||
logs_dir="../logs"
|
||||
sdk_db_dir="../db/sdk/"
|
||||
#Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $bin_dir ]; then
|
||||
mkdir -p $bin_dir
|
||||
fi
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
if [ ! -d $sdk_db_dir ]; then
|
||||
mkdir -p $sdk_db_dir
|
||||
fi
|
||||
|
||||
#begin path
|
||||
|
||||
cd /Open-IM-Server/cmd/rpc/${serviceName} && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
|
||||
make install && echo -e "${SKY_BLUE_PREFIX}build ${serviceName} success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
|
||||
echo -e "${SKY_BLUE_PREFIX}Successful moved ${serviceName} to the bin directory${COLOR_SUFFIX}\n"
|
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
source ../setting.env
|
||||
VERSION_TAG="2.0.2"
|
||||
IMAGE_TAG="${DOCKER_REGISTRY_ADDR}open_im_user:v$VERSION_TAG"
|
||||
|
||||
if [ ! -f "./Open-IM-SDK-Core.tar.gz" ];then
|
||||
|
||||
rm -rf Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-Server/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-Server.tar.gz && \
|
||||
wget https://github.91chi.fun//https://github.com//OpenIMSDK/Open-IM-SDK-Core/archive/refs/tags/v$VERSION_TAG.tar.gz && \
|
||||
mv v$VERSION_TAG.tar.gz Open-IM-SDK-Core.tar.gz
|
||||
|
||||
fi
|
||||
echo "下载完成" && \
|
||||
docker build . -t $IMAGE_TAG --no-cache && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
echo "构建完成" && \
|
||||
docker push $IMAGE_TAG && \
|
||||
cp development.tmp.yaml development.yaml
|
||||
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
sed -i "" "s#IMAGE_TAG#${IMAGE_TAG}#g" ./development.yaml
|
||||
sed -i "" "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "" "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
elif [[ `uname` == 'Linux' ]]; then
|
||||
sed -i "s#IMAGE_TAG#${IMAGE_TAG}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_API#${NODE_PORT_API}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_MSG_GATEWAY#${NODE_PORT_MSG_GATEWAY}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_SDK_SERVER#${NODE_PORT_SDK_SERVER}#g" development.yaml
|
||||
sed -i "s#NODE_PORT_DEMO#${NODE_PORT_DEMO}#g" development.yaml
|
||||
fi
|
||||
echo "推送镜像完成" && kubectl -n ${K8S_NAMESPACE} delete -f development.yaml
|
||||
kubectl -n ${K8S_NAMESPACE} apply -f development.yaml
|
@ -0,0 +1,94 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: user
|
||||
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: user
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-user
|
||||
serviceName: user
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: user
|
||||
workload.user.cattle.io/workloadselector: statefulSet-openim-user
|
||||
spec:
|
||||
containers:
|
||||
- image: "IMAGE_TAG"
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.hostIP
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
- name: NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.namespace
|
||||
ports:
|
||||
- name: p10100
|
||||
protocol: TCP
|
||||
containerPort: 10100
|
||||
imagePullPolicy: Always
|
||||
name: user
|
||||
stdin: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
tty: true
|
||||
volumeMounts:
|
||||
- mountPath: /Open-IM-Server/config.tmp.yaml
|
||||
name: vol2
|
||||
readOnly: true
|
||||
subPath: config.yaml
|
||||
dnsConfig: {}
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- configMap:
|
||||
defaultMode: 256
|
||||
name: config.yaml
|
||||
optional: false
|
||||
name: vol2
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: user
|
||||
|
||||
spec:
|
||||
ports:
|
||||
- name: p10100
|
||||
port: 10100
|
||||
protocol: TCP
|
||||
targetPort: 10100
|
||||
selector:
|
||||
app: user
|
||||
type: ClusterIP
|
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
service_filename="open_im_user"
|
||||
service_port_name="openImUserPort"
|
||||
K8sServiceName="user"
|
||||
|
||||
|
||||
#Check whether the service exists
|
||||
service_name="ps -aux |grep -w ${service_filename} |grep -v grep"
|
||||
count="${service_name}| wc -l"
|
||||
|
||||
rm -rf /Open-IM-Server/config
|
||||
mkdir /Open-IM-Server/config
|
||||
cp /Open-IM-Server/config.tmp.yaml /Open-IM-Server/config/config.yaml
|
||||
sed -i "s#openim-all#$POD_NAME.$K8sServiceName.$NAMESPACE.svc.cluster.local#g" /Open-IM-Server/config/config.yaml
|
||||
|
||||
if [ $(eval ${count}) -gt 0 ]; then
|
||||
pid="${service_name}| awk '{print \$2}'"
|
||||
echo -e "${SKY_BLUE_PREFIX}${service_filename} service has been started,pid:$(eval $pid)$COLOR_SUFFIX"
|
||||
echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename} pid:$(eval $pid)${COLOR_SUFFIX}"
|
||||
#kill the service that existed
|
||||
kill -9 $(eval $pid)
|
||||
sleep 0.5
|
||||
fi
|
||||
cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename} service is starting${COLOR_SUFFIX}"
|
||||
#Get the rpc port in the configuration file
|
||||
portList=$(cat $config_path | grep ${service_port_name} | awk -F '[:]' '{print $NF}')
|
||||
list_to_string ${portList}
|
||||
#Start related rpc services based on the number of ports
|
||||
for j in ${ports_array}; do
|
||||
echo -e "${SKY_BLUE_PREFIX}${POD_NAME} Service is starting,port number:$j $COLOR_SUFFIX"
|
||||
./${service_filename} -port $j
|
||||
done
|
@ -0,0 +1,6 @@
|
||||
DOCKER_REGISTRY_ADDR="harbor.local/"
|
||||
NODE_PORT_API="10100"
|
||||
NODE_PORT_MSG_GATEWAY="10101"
|
||||
NODE_PORT_SDK_SERVER="10102"
|
||||
NODE_PORT_DEMO="10103"
|
||||
K8S_NAMESPACE="openim"
|
Loading…
Reference in new issue