From e7040d3b26b3e77a55ae5121614171eea3e81841 Mon Sep 17 00:00:00 2001 From: Xinwei Xiong <3293172751@qq.com> Date: Fri, 28 Jul 2023 14:37:39 +0800 Subject: [PATCH] docs: add readme docs (#691) * docs: add readme docs Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add script yaml Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add script yaml Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix bug: reject group req bug * feat: add go relase Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: config env command Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> --------- Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> Co-authored-by: wangchuxiao --- .github/workflows/build-docker-image.yml | 88 ++++++++---------------- .github/workflows/deploy.yml | 72 ++++++++++--------- .goreleaser.yaml | 3 + Dockerfile | 3 +- docs/conversions/images.md | 69 +++++++++++++++++++ docs/conversions/version.md | 6 +- internal/rpc/group/group.go | 11 +-- 7 files changed, 153 insertions(+), 99 deletions(-) create mode 100644 docs/conversions/images.md diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index ef2659724..3dd64c930 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -18,6 +18,7 @@ on: push: branches: - main + - release-* tags: - v* workflow_dispatch: @@ -29,29 +30,38 @@ jobs: - name: Check out the repo uses: actions/checkout@v3 + - name: Build OpenIM Server + run: | + sudo make build + # docker.io/openim/openim-server:latest + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4.6.0 + with: + images: openim/openim-server + - name: Log in to Docker Hub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4.6.0 - with: - images: openim/openim-server - tags: latest - - name: Build and push Docker image uses: docker/build-push-action@v4 with: context: . - push: true + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} # registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server:latest + - name: Extract metadata (tags, labels) for Docker + id: meta2 + uses: docker/metadata-action@v4.6.0 + with: + images: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server + - name: Log in to AliYun Docker Hub uses: docker/login-action@v2 with: @@ -59,22 +69,21 @@ jobs: username: ${{ secrets.ALIREGISTRY_USERNAME }} password: ${{ secrets.ALIREGISTRY_TOKEN }} - - name: Extract metadata (tags, labels) for Docker - id: meta2 - uses: docker/metadata-action@v4.6.0 - with: - images: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server - tags: latest - - name: Build and push Docker image uses: docker/build-push-action@v4 with: context: . - push: true + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta2.outputs.tags }} labels: ${{ steps.meta2.outputs.labels }} -# ghcr.io/openim/openim-server:latest +# ghcr.io/openimsdk/openim-server:latest + - name: Extract metadata (tags, labels) for Docker + id: meta3 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/openim-server + - name: Log in to GitHub Container Registry uses: docker/login-action@v2 with: @@ -82,53 +91,10 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker - id: meta3 - uses: docker/metadata-action@v4.6.0 - with: - images: openim/openim-server - tags: latest - - name: Build and push Docker image uses: docker/build-push-action@v4 with: context: . - push: true + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta3.outputs.tags }} labels: ${{ steps.meta3.outputs.labels }} - -# name: OpenIM Build Docker Images -# on: -# push: -# tags: -# - v* -# jobs: -# build: -# runs-on: ubuntu-latest -# strategy: -# matrix: -# bin: -# - openim-server -# steps: -# - name: Checkout -# uses: actions/checkout@v3 -# - name: Setup Docker Buildx -# uses: docker/setup-buildx-action@v2 -# - name: Login to GitHub Container Registry -# uses: docker/login-action@v2 -# with: -# registry: ghcr.io -# username: ${{ github.repository_owner }} -# password: ${{ secrets.GITHUB_TOKEN }} -# - name: Docker metadata -# id: metadata -# uses: docker/metadata-action@v4 -# with: -# images: ghcr.io/${{ github.repository_owner }}/openim-${{ matrix.bin }} -# - name: Build and release Docker images -# uses: docker/build-push-action@v3 -# with: -# platforms: linux/386,linux/amd64,linux/arm64/v8 -# target: ${{ matrix.bin }} -# tags: ${{ steps.metadata.outputs.tags }} -# push: true \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2d7798916..ea28440e9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -18,6 +18,7 @@ on: push: branches: - 'devops' # Only for the dev branch + - 'main' paths: - '.github/workflows/*' # - '__test__/**' # dev No immediate testing is required @@ -26,38 +27,47 @@ on: - 'docker-compose.yml' - 'bin/*' -env: - SERVER_PRIVATE_KEY: ${{ secrets.SERVER_PRIVATE_KEY }} # server private key - SERVER_HOST: ${{ secrets.SERVER_HOST }} # server ip address - USER_NAME: ${{ secrets.USER_NAME }} # server username - cache-name: note - jobs: deploy-dev: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: set ssh key # Temporarily set up ssh key - run: | - mkdir -p ~/.ssh/ - # secrets.WFP_ID_RSA set in GitHub - echo "${{secrets.WFP_ID_RSA}}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - ssh-keyscan "182.92.xxx.xxx" >> ~/.ssh/known_hosts - - name: deploy # Deployment - run: | - ssh work@182.92.xxx.xxx " - # 【Attention】Log in with the 'work' account, manually create /home/work/imooc-lego directory - # Then git clone https://username:password@github.com/imooc-lego/biz-editor-server.git -b dev (private repository, use GitHub username and password) - # Remember to delete origin to avoid exposing GitHub password - cd /home/work/imooc-lego/biz-editor-server; - git remote add origin https://openimbot:${{secrets.WFP_PASSWORD}}@github.com/OpenIMSDK/open-im-server.git; - git checkout dev; - git pull origin dev; # Download the latest code again - git remote remove origin; # Remove origin to avoid exposing GitHub password - # Start docker - docker-compose build editor-server; # Same as the service name in docker-compose.yml - docker-compose up -d; - " - - name: delete ssh key # Delete ssh key - run: rm -rf ~/.ssh/id_rsa \ No newline at end of file + - uses: actions/checkout@v3 + - name: executing remote ssh commands using password + uses: appleboy/ssh-action@v1.0.0 + env: + OWNER: ${{ github.repository_owner }} + REPO: ${{ github.event.repository.name }} + with: + host: "${{ secrets.SG_M1_HOST }}, ${{ secrets.SG_N1_HOST }}, ${{ secrets.SG_N2_HOST}}" + username: ${{ secrets.SG_USERNAME }} + password: ${{ secrets.SG_PASSWORD }} + port: ${{ secrets.SG_PORT }} + envs: OWNER,REPO + script_stop: true + script: | + mkdir -p /test/openim + cd /test/openim + pwd;ls -al + echo "OWNER: $OWNER" + echo "REPO: $REPO" + git clone -b develop https://github.com/${OWNER}/${REPO}.git; cd ${REPO} + docker compose up -d + + + # - name: deploy # Deployment + # run: | + # ssh work@182.92.xxx.xxx " + # # 【Attention】Log in with the 'work' account, manually create /home/work/imooc-lego directory + # # Then git clone https://username:password@github.com/imooc-lego/biz-editor-server.git -b dev (private repository, use GitHub username and password) + # # Remember to delete origin to avoid exposing GitHub password + # cd /home/work/imooc-lego/biz-editor-server; + # git remote add origin https://openimbot:${{secrets.WFP_PASSWORD}}@github.com/OpenIMSDK/open-im-server.git; + # git checkout dev; + # git pull origin dev; # Download the latest code again + # git remote remove origin; # Remove origin to avoid exposing GitHub password + # # Start docker + # docker-compose build editor-server; # Same as the service name in docker-compose.yml + # docker-compose up -d; + # " + # - name: delete ssh key # Delete ssh key + # run: rm -rf ~/.ssh/id_rsa \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml index e9eb44c94..fc7c0cd01 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -480,6 +480,9 @@ checksum: release: footer: | + + ## Welcome to the {{ .Tag }} release of [chat](https://github.com/OpenIMSDK/chat)!🎉🎉! + **Full Changelog**: https://github.com/OpenIMSDK/Open-IM-Server/compare/{{ .PreviousTag }}...{{ .Tag }} ## Helping out diff --git a/Dockerfile b/Dockerfile index 33c4651c9..290aa02c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,8 @@ RUN /bin/sh -c "make build" # Production Stage FROM alpine -RUN apk --no-cache add tzdata +RUN apk --no-cache add tzdata; \ + apt --no-cache add ca-certificates # Set directory to map logs, config files, scripts, and SDK VOLUME ["/Open-IM-Server/logs", "/Open-IM-Server/config", "/Open-IM-Server/scripts", "/Open-IM-Server/db/sdk"] diff --git a/docs/conversions/images.md b/docs/conversions/images.md new file mode 100644 index 000000000..ae85a5bab --- /dev/null +++ b/docs/conversions/images.md @@ -0,0 +1,69 @@ +# OpenIM Image Management Strategy and Pulling Guide + +OpenIM is an efficient, stable, and scalable instant messaging framework that provides convenient deployment methods through Docker images. OpenIM manages multiple image sources, hosted respectively on GitHub (ghcr), Alibaba Cloud, and Docker Hub. This document is aimed at detailing the image management strategy of OpenIM and providing the steps for pulling these images. + +## Image Management Strategy + +OpenIM's versions correspond to GitHub's tag versions. Each time we release a new version and tag it on GitHub, an automated process is triggered that pushes the new Docker image version to the following three platforms: + +1. **GitHub (ghcr.io):** We use GitHub Container Registry (ghcr.io) to host OpenIM's Docker images. This allows us to better integrate with the GitHub source code repository, providing better version control and continuous integration/deployment (CI/CD) features. You can view all GitHub images [here](https://github.com/orgs/OpenIMSDK/packages). +2. **Alibaba Cloud (registry.cn-hangzhou.aliyuncs.com):** For users in Mainland China, we also host OpenIM's Docker images on Alibaba Cloud to provide faster pull speeds. You can view all Alibaba Cloud images on this [page](https://cr.console.aliyun.com/cn-hangzhou/instances/repositories) of Alibaba Cloud Image Service (note that you need to log in to your Alibaba Cloud account first). +3. **Docker Hub (docker.io):** Docker Hub is the most commonly used Docker image hosting platform, and we also host OpenIM's images there to facilitate developers worldwide. You can view all Docker Hub images on the [OpenIM's Docker Hub page](https://hub.docker.com/r/openim). + +## Methods and Steps for Pulling Images + +When pulling OpenIM's Docker images, you can choose the most suitable source based on your geographic location and network conditions. Here are the steps to pull OpenIM images from each source: + +1. First, make sure Docker is installed on your machine. If not, you can refer to the [Docker official documentation](https://docs.docker.com/get-docker/) for installation. + +2. Open the terminal and run the following commands to pull the images: + + For OpenIM Server: + + - Pull from GitHub: + + ``` + bashCopy code + docker pull ghcr.io/openimsdk/openim-server:latest + ``` + + - Pull from Alibaba Cloud: + + ``` + bashCopy code + docker pull registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server:latest + ``` + + - Pull from Docker Hub: + + ``` + bashCopy code + docker pull docker.io/openim/openim-server:latest + ``` + + For OpenIM Chat: + + - Pull from GitHub: + + ``` + bashCopy code + docker pull ghcr.io/openimsdk/openim-chat:latest + ``` + + - Pull from Alibaba Cloud: + + ``` + bashCopy code + docker pull registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:latest + ``` + + - Pull from Docker Hub: + + ``` + bashCopy code + docker pull docker.io/openim/openim-chat:latest + ``` + +3. Run the `docker images` command to confirm that the image has been successfully pulled. + +This concludes OpenIM's image management strategy and the steps for pulling images. If you have any questions, please feel free to ask. \ No newline at end of file diff --git a/docs/conversions/version.md b/docs/conversions/version.md index a421dd549..bf1062b77 100644 --- a/docs/conversions/version.md +++ b/docs/conversions/version.md @@ -54,4 +54,8 @@ git merge release-v3.1 git push origin main ``` -Remember, communication with your team is key throughout this process, keeping everyone up-to-date with the changes being made. \ No newline at end of file +Remember, communication with your team is key throughout this process, keeping everyone up-to-date with the changes being made. + + +## Docker images version management + diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 4ce3d4216..65beae37e 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -17,14 +17,15 @@ package group import ( "context" "fmt" - "github.com/OpenIMSDK/Open-IM-Server/pkg/authverify" - "github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor" "math/big" "math/rand" "strconv" "strings" "time" + "github.com/OpenIMSDK/Open-IM-Server/pkg/authverify" + "github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor" + pbConversation "github.com/OpenIMSDK/protocol/conversation" "github.com/OpenIMSDK/protocol/wrapperspb" @@ -718,11 +719,11 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup if err := s.GroupDatabase.HandlerGroupRequest(ctx, req.GroupID, req.FromUserID, req.HandledMsg, req.HandleResult, member); err != nil { return nil, err } - if err := s.conversationRpcClient.GroupChatFirstCreateConversation(ctx, req.GroupID, []string{req.FromUserID}); err != nil { - return nil, err - } switch req.HandleResult { case constant.GroupResponseAgree: + if err := s.conversationRpcClient.GroupChatFirstCreateConversation(ctx, req.GroupID, []string{req.FromUserID}); err != nil { + return nil, err + } s.Notification.GroupApplicationAcceptedNotification(ctx, req) case constant.GroupResponseRefuse: s.Notification.GroupApplicationRejectedNotification(ctx, req)