mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-11 23:47:32 +08:00
Merge branch 'main' of https://github.com/openimsdk/open-im-server into chore/remove-cm
This commit is contained in:
commit
b962062261
155
.github/workflows/publish-docker-image.yml
vendored
155
.github/workflows/publish-docker-image.yml
vendored
@ -4,42 +4,80 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- release-*
|
- release-*
|
||||||
# tags:
|
|
||||||
# - 'v*'
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
types: [published]
|
types: [published]
|
||||||
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
tag:
|
tag:
|
||||||
description: "Tag version to be used for Docker image"
|
description: "Tag version to be used for Docker image"
|
||||||
required: true
|
required: true
|
||||||
default: "v3.8.0"
|
default: "v3.8.3"
|
||||||
|
|
||||||
|
env:
|
||||||
|
GO_VERSION: "1.22"
|
||||||
|
IMAGE_NAME: "openim-server"
|
||||||
|
# IMAGE_NAME: ${{ github.event.repository.name }}
|
||||||
|
DOCKER_BUILDKIT: 1
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-test:
|
publish-docker-images:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.merged == false) }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout main repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
path: main-repo
|
path: main-repo
|
||||||
|
|
||||||
# - name: Set up QEMU
|
- name: Set up QEMU
|
||||||
# uses: docker/setup-qemu-action@v3.3.0
|
uses: docker/setup-qemu-action@v3.3.0
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3.8.0
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
- name: Build Docker image
|
|
||||||
id: build
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
with:
|
||||||
context: ./main-repo
|
driver-opts: network=host
|
||||||
load: true
|
|
||||||
tags: "openim/openim-server:local"
|
- name: Extract metadata for Docker
|
||||||
cache-from: type=gha,scope=build
|
id: meta
|
||||||
cache-to: type=gha,mode=max,scope=build
|
uses: docker/metadata-action@v5.6.0
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}
|
||||||
|
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
|
||||||
|
registry.cn-hangzhou.aliyuncs.com/openimsdk/${{ env.IMAGE_NAME }}
|
||||||
|
tags: |
|
||||||
|
type=ref,event=tag
|
||||||
|
type=schedule
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=pr
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern=v{{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
type=sha
|
||||||
|
|
||||||
|
- name: Install skopeo
|
||||||
|
run: |
|
||||||
|
sudo apt-get update && sudo apt-get install -y skopeo
|
||||||
|
|
||||||
|
- name: Build multi-arch images as OCI
|
||||||
|
run: |
|
||||||
|
mkdir -p /tmp/oci-image /tmp/docker-cache
|
||||||
|
|
||||||
|
# Build multi-architecture image and save in OCI format
|
||||||
|
docker buildx build \
|
||||||
|
--platform linux/amd64,linux/arm64 \
|
||||||
|
--output type=oci,dest=/tmp/oci-image/multi-arch.tar \
|
||||||
|
--cache-to type=local,dest=/tmp/docker-cache \
|
||||||
|
--cache-from type=gha \
|
||||||
|
./main-repo
|
||||||
|
|
||||||
|
# Use skopeo to convert the amd64 image from OCI format to Docker format and load it
|
||||||
|
skopeo copy --override-arch amd64 oci-archive:/tmp/oci-image/multi-arch.tar docker-daemon:${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:local
|
||||||
|
|
||||||
|
# check image
|
||||||
|
docker image ls | grep openim
|
||||||
|
|
||||||
- name: Checkout compose repository
|
- name: Checkout compose repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@ -52,11 +90,11 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
IP=$(hostname -I | awk '{print $1}')
|
IP=$(hostname -I | awk '{print $1}')
|
||||||
echo "The IP Address is: $IP"
|
echo "The IP Address is: $IP"
|
||||||
echo "::set-output name=ip::$IP"
|
echo "ip=$IP" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Update .env to use the local image
|
- name: Update .env to use the local image
|
||||||
run: |
|
run: |
|
||||||
sed -i 's|OPENIM_SERVER_IMAGE=.*|OPENIM_SERVER_IMAGE=openim/openim-server:local|' ${{ github.workspace }}/compose-repo/.env
|
sed -i 's|OPENIM_SERVER_IMAGE=.*|OPENIM_SERVER_IMAGE=${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:local|' ${{ github.workspace }}/compose-repo/.env
|
||||||
sed -i 's|MINIO_EXTERNAL_ADDRESS=.*|MINIO_EXTERNAL_ADDRESS=http://${{ steps.get-ip.outputs.ip }}:10005|' ${{ github.workspace }}/compose-repo/.env
|
sed -i 's|MINIO_EXTERNAL_ADDRESS=.*|MINIO_EXTERNAL_ADDRESS=http://${{ steps.get-ip.outputs.ip }}:10005|' ${{ github.workspace }}/compose-repo/.env
|
||||||
|
|
||||||
- name: Start services using Docker Compose
|
- name: Start services using Docker Compose
|
||||||
@ -66,23 +104,34 @@ jobs:
|
|||||||
|
|
||||||
docker compose ps
|
docker compose ps
|
||||||
|
|
||||||
- name: Extract metadata for Docker (tags, labels)
|
# - name: Check openim-server health
|
||||||
id: meta
|
# run: |
|
||||||
uses: docker/metadata-action@v5.6.0
|
# timeout=300
|
||||||
with:
|
# interval=30
|
||||||
images: |
|
# elapsed=0
|
||||||
openim/openim-server
|
# while [[ $elapsed -le $timeout ]]; do
|
||||||
ghcr.io/openimsdk/openim-server
|
# if ! docker exec openim-server mage check; then
|
||||||
registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server
|
# echo "openim-server is not ready, waiting..."
|
||||||
tags: |
|
# sleep $interval
|
||||||
type=ref,event=tag
|
# elapsed=$(($elapsed + $interval))
|
||||||
type=schedule
|
# else
|
||||||
type=ref,event=branch
|
# echo "Health check successful"
|
||||||
# type=semver,pattern={{version}}
|
# exit 0
|
||||||
type=semver,pattern=v{{version}}
|
# fi
|
||||||
type=semver,pattern=release-{{raw}}
|
# done
|
||||||
type=sha
|
# echo "Health check failed after 5 minutes"
|
||||||
type=raw,value=${{ github.event.inputs.tag }}
|
# exit 1
|
||||||
|
|
||||||
|
# - name: Check openim-chat health
|
||||||
|
# if: success()
|
||||||
|
# run: |
|
||||||
|
# if ! docker exec openim-chat mage check; then
|
||||||
|
# echo "openim-chat check failed"
|
||||||
|
# exit 1
|
||||||
|
# else
|
||||||
|
# echo "Health check successful"
|
||||||
|
# exit 0
|
||||||
|
# fi
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@v3.3.0
|
uses: docker/login-action@v3.3.0
|
||||||
@ -104,22 +153,27 @@ jobs:
|
|||||||
username: ${{ secrets.ALIREGISTRY_USERNAME }}
|
username: ${{ secrets.ALIREGISTRY_USERNAME }}
|
||||||
password: ${{ secrets.ALIREGISTRY_TOKEN }}
|
password: ${{ secrets.ALIREGISTRY_TOKEN }}
|
||||||
|
|
||||||
- name: Push Docker images
|
- name: Push multi-architecture images
|
||||||
uses: docker/build-push-action@v5
|
if: success()
|
||||||
with:
|
run: |
|
||||||
context: ./main-repo
|
docker buildx build \
|
||||||
push: true
|
--platform linux/amd64,linux/arm64 \
|
||||||
platforms: linux/amd64,linux/arm64
|
$(echo "${{ steps.meta.outputs.tags }}" | sed 's/,/ --tag /g' | sed 's/^/--tag /') \
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
--cache-from type=local,src=/tmp/docker-cache \
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
--push \
|
||||||
cache-from: type=gha,scope=build
|
./main-repo
|
||||||
cache-to: type=gha,mode=max,scope=build
|
|
||||||
|
|
||||||
- name: Verify multi-platform support
|
- name: Verify multi-platform support
|
||||||
run: |
|
run: |
|
||||||
images=("openim/openim-server" "ghcr.io/openimsdk/openim-server" "registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server")
|
images=(
|
||||||
|
"${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}"
|
||||||
|
"ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}"
|
||||||
|
"registry.cn-hangzhou.aliyuncs.com/openimsdk/${{ env.IMAGE_NAME }}"
|
||||||
|
)
|
||||||
|
|
||||||
for image in "${images[@]}"; do
|
for image in "${images[@]}"; do
|
||||||
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n'); do
|
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n' | cut -d':' -f2); do
|
||||||
|
echo "Verifying multi-arch support for $image:$tag"
|
||||||
manifest=$(docker manifest inspect "$image:$tag" || echo "error")
|
manifest=$(docker manifest inspect "$image:$tag" || echo "error")
|
||||||
if [[ "$manifest" == "error" ]]; then
|
if [[ "$manifest" == "error" ]]; then
|
||||||
echo "Manifest not found for $image:$tag"
|
echo "Manifest not found for $image:$tag"
|
||||||
@ -135,5 +189,6 @@ jobs:
|
|||||||
echo "Multi-platform support check failed for $image:$tag - missing arm64"
|
echo "Multi-platform support check failed for $image:$tag - missing arm64"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo "✅ $image:$tag supports both amd64 and arm64 architectures"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|||||||
@ -56,6 +56,7 @@ type Client struct {
|
|||||||
UserID string `json:"userID"`
|
UserID string `json:"userID"`
|
||||||
IsBackground bool `json:"isBackground"`
|
IsBackground bool `json:"isBackground"`
|
||||||
SDKType string `json:"sdkType"`
|
SDKType string `json:"sdkType"`
|
||||||
|
SDKVersion string `json:"sdkVersion"`
|
||||||
Encoder Encoder
|
Encoder Encoder
|
||||||
ctx *UserConnContext
|
ctx *UserConnContext
|
||||||
longConnServer LongConnServer
|
longConnServer LongConnServer
|
||||||
@ -83,6 +84,7 @@ func (c *Client) ResetClient(ctx *UserConnContext, conn LongConn, longConnServer
|
|||||||
c.closedErr = nil
|
c.closedErr = nil
|
||||||
c.token = ctx.GetToken()
|
c.token = ctx.GetToken()
|
||||||
c.SDKType = ctx.GetSDKType()
|
c.SDKType = ctx.GetSDKType()
|
||||||
|
c.SDKVersion = ctx.GetSDKVersion()
|
||||||
c.hbCtx, c.hbCancel = context.WithCancel(c.ctx)
|
c.hbCtx, c.hbCancel = context.WithCancel(c.ctx)
|
||||||
c.subLock = new(sync.Mutex)
|
c.subLock = new(sync.Mutex)
|
||||||
if c.subUserIDs != nil {
|
if c.subUserIDs != nil {
|
||||||
|
|||||||
@ -14,6 +14,7 @@ const (
|
|||||||
BackgroundStatus = "isBackground"
|
BackgroundStatus = "isBackground"
|
||||||
SendResponse = "isMsgResp"
|
SendResponse = "isMsgResp"
|
||||||
SDKType = "sdkType"
|
SDKType = "sdkType"
|
||||||
|
SDKVersion = "sdkVersion"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
package msggateway
|
package msggateway
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
||||||
|
|
||||||
"github.com/openimsdk/protocol/constant"
|
"github.com/openimsdk/protocol/constant"
|
||||||
"github.com/openimsdk/tools/utils/encrypt"
|
"github.com/openimsdk/tools/utils/encrypt"
|
||||||
"github.com/openimsdk/tools/utils/stringutil"
|
"github.com/openimsdk/tools/utils/stringutil"
|
||||||
@ -126,6 +127,10 @@ func (c *UserConnContext) GetToken() string {
|
|||||||
return c.Req.URL.Query().Get(Token)
|
return c.Req.URL.Query().Get(Token)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *UserConnContext) GetSDKVersion() string {
|
||||||
|
return c.Req.URL.Query().Get(SDKVersion)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) GetCompression() bool {
|
func (c *UserConnContext) GetCompression() bool {
|
||||||
compression, exists := c.Query(Compression)
|
compression, exists := c.Query(Compression)
|
||||||
if exists && compression == GzipCompressionProtocol {
|
if exists && compression == GzipCompressionProtocol {
|
||||||
|
|||||||
@ -241,6 +241,10 @@ func (ws *WsServer) registerClient(client *Client) {
|
|||||||
oldClients []*Client
|
oldClients []*Client
|
||||||
)
|
)
|
||||||
oldClients, userOK, clientOK = ws.clients.Get(client.UserID, client.PlatformID)
|
oldClients, userOK, clientOK = ws.clients.Get(client.UserID, client.PlatformID)
|
||||||
|
|
||||||
|
log.ZInfo(client.ctx, "registerClient", "userID", client.UserID, "platformID", client.PlatformID,
|
||||||
|
"sdkVersion", client.SDKVersion)
|
||||||
|
|
||||||
if !userOK {
|
if !userOK {
|
||||||
ws.clients.Set(client.UserID, client)
|
ws.clients.Set(client.UserID, client)
|
||||||
log.ZDebug(client.ctx, "user not exist", "userID", client.UserID, "platformID", client.PlatformID)
|
log.ZDebug(client.ctx, "user not exist", "userID", client.UserID, "platformID", client.PlatformID)
|
||||||
|
|||||||
@ -95,7 +95,7 @@ func GetConversationIDBySessionType(sessionType int, ids ...string) string {
|
|||||||
case constant.ReadGroupChatType:
|
case constant.ReadGroupChatType:
|
||||||
return "sg_" + ids[0] // super group chat
|
return "sg_" + ids[0] // super group chat
|
||||||
case constant.NotificationChatType:
|
case constant.NotificationChatType:
|
||||||
return "sn_" + ids[0] // server notification chat
|
return "sn_" + strings.Join(ids, "_") // server notification chat
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user