From 363deff6f8fb078dca0b5493fbac8952bd3f57c8 Mon Sep 17 00:00:00 2001 From: Xinwei Xiong <3293172751@qq.com> Date: Sat, 21 Oct 2023 15:23:33 +0800 Subject: [PATCH] feat(release-v3.4): Enhanced Build, Deployment, and Configuration Management for Optimized Performance and Automation (#1255) * docs: add openim docs Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * docs: add openim images test Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: fix openim ci and deployment Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: fix openim ci and deployment Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: add openim flag api configpath env set Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * fix: fix openim push logger Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * fix: fix openim config path Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * fix: fix openim config path Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * fix: fix openim config path Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> --------- Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> --- .dockerignore | 4 +- .github/workflows/bot-cherry-pick.yml | 3 +- .github/workflows/build-docker-image.yml | 9 + .github/workflows/build-openim-web-image.yml | 43 +--- .github/workflows/openimci.yml | 2 +- README-zh_CN.md | 5 + README.md | 4 +- build/images/Dockerfile | 10 + build/images/openim-api/Dockerfile | 13 +- build/images/openim-api/Dockerfile.release | 8 - build/images/openim-cmdutils/Dockerfile | 10 +- build/images/openim-crontask/Dockerfile | 13 +- build/images/openim-msggateway/Dockerfile | 17 +- build/images/openim-msgtransfer/Dockerfile | 11 +- build/images/openim-push/Dockerfile | 17 +- build/images/openim-rpc-auth/Dockerfile | 17 +- .../images/openim-rpc-conversation/Dockerfile | 17 +- build/images/openim-rpc-friend/Dockerfile | 17 +- build/images/openim-rpc-group/Dockerfile | 17 +- build/images/openim-rpc-msg/Dockerfile | 17 +- build/images/openim-rpc-third/Dockerfile | 16 +- build/images/openim-rpc-user/Dockerfile | 17 +- cmd/openim-api/main.go | 45 ++-- deployments/README.md | 18 +- deployments/openim-chat/.helmignore | 23 -- deployments/openim-chat/Chart.yaml | 38 ---- deployments/openim-chat/LICENSE | 201 ------------------ deployments/openim-chat/templates/NOTES.txt | 22 -- .../openim-chat/templates/_helpers.tpl | 62 ------ .../openim-chat/templates/deployment.yaml | 75 ------- deployments/openim-chat/templates/hpa.yaml | 42 ---- .../openim-chat/templates/ingress.yaml | 75 ------- .../openim-chat/templates/service.yaml | 29 --- .../openim-chat/templates/serviceaccount.yaml | 26 --- deployments/openim-chat/values.yaml | 96 --------- docs/contrib/environment.md | 82 ++++--- go.mod | 2 +- go.sum | 30 +++ go.work | 2 +- install.sh | 8 +- internal/push/offlinepush/fcm/push.go | 13 +- pkg/common/cmd/api.go | 3 + pkg/common/cmd/root.go | 78 +++++-- pkg/common/config/parse.go | 59 +++-- pkg/common/config/version | 2 +- scripts/check-all.sh | 4 +- scripts/demo.sh | 2 + scripts/docker-check-service.sh | 6 +- scripts/install-im-server.sh | 2 + scripts/install_im_compose.sh | 12 +- scripts/lib/util.sh | 37 ++++ scripts/make-rules/common.mk | 1 + scripts/make-rules/golang.mk | 13 +- scripts/make-rules/image.mk | 28 +-- test/typecheck/go.mod | 2 +- tests/group_test.go | 22 -- tests/user_test.go | 51 ----- tools/changelog/go.mod | 2 +- tools/component/go.mod | 2 +- tools/data-conversion/README.md | 103 +++++++++ .../chat/{ => cmd/conversion-chat}/chat.go | 0 tools/data-conversion/go.mod | 2 +- tools/data-conversion/info.md | 68 ------ .../conversion-msg/conversion-msg.go} | 0 .../conversion-mysql/conversion-mysql.go} | 0 tools/imctl/go.mod | 2 +- tools/infra/go.mod | 2 +- tools/ncpu/go.mod | 2 +- tools/openim-web/go.mod | 2 +- tools/versionchecker/go.mod | 2 +- tools/yamlfmt/go.mod | 2 +- 71 files changed, 505 insertions(+), 1182 deletions(-) create mode 100644 build/images/Dockerfile delete mode 100644 build/images/openim-api/Dockerfile.release delete mode 100644 deployments/openim-chat/.helmignore delete mode 100644 deployments/openim-chat/Chart.yaml delete mode 100644 deployments/openim-chat/LICENSE delete mode 100644 deployments/openim-chat/templates/NOTES.txt delete mode 100644 deployments/openim-chat/templates/_helpers.tpl delete mode 100644 deployments/openim-chat/templates/deployment.yaml delete mode 100644 deployments/openim-chat/templates/hpa.yaml delete mode 100644 deployments/openim-chat/templates/ingress.yaml delete mode 100644 deployments/openim-chat/templates/service.yaml delete mode 100644 deployments/openim-chat/templates/serviceaccount.yaml delete mode 100644 deployments/openim-chat/values.yaml delete mode 100644 tests/group_test.go delete mode 100644 tests/user_test.go create mode 100644 tools/data-conversion/README.md rename tools/data-conversion/chat/{ => cmd/conversion-chat}/chat.go (100%) delete mode 100644 tools/data-conversion/info.md rename tools/data-conversion/openim/{msg.go => cmd/conversion-msg/conversion-msg.go} (100%) rename tools/data-conversion/openim/{mysql.go => cmd/conversion-mysql/conversion-mysql.go} (100%) diff --git a/.dockerignore b/.dockerignore index c35303ed6..705512401 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,4 @@ - +.github/ diff --git a/.github/workflows/bot-cherry-pick.yml b/.github/workflows/bot-cherry-pick.yml index ab8993540..e488e97de 100644 --- a/.github/workflows/bot-cherry-pick.yml +++ b/.github/workflows/bot-cherry-pick.yml @@ -19,7 +19,8 @@ on: jobs: cherry-pick: name: Cherry Pick - if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/cherry-pick') && github.event.comment.user.login=='kubbot' + # && github.event.comment.user.login=='kubbot' + if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/cherry-pick') runs-on: ubuntu-latest steps: - name: Checkout the latest code diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 735c160df..79b60fbed 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -120,6 +120,15 @@ jobs: uses: docker/metadata-action@v5.0.0 with: images: ghcr.io/openimsdk/openim-server + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha - name: Log in to GitHub Container Registry uses: docker/login-action@v3 diff --git a/.github/workflows/build-openim-web-image.yml b/.github/workflows/build-openim-web-image.yml index 800500af6..e040d5270 100644 --- a/.github/workflows/build-openim-web-image.yml +++ b/.github/workflows/build-openim-web-image.yml @@ -114,15 +114,12 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 +# ghcr.io/openimsdk/openim-web:latest + - name: Extract metadata (tags, labels) for Docker + id: meta2 + uses: docker/metadata-action@v5.0.0 with: - install: true - - name: Cache Docker layers - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- + images: ghcr.io/openimsdk/openim-web - name: Log in to GitHub Container Registry uses: docker/login-action@v3 @@ -131,38 +128,12 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker openim-web - id: meta1 - uses: docker/metadata-action@v5.0.0 - with: - images: ghcr.io/openimsdk/openim-web - - - name: Build and push Docker image for openim-web + - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . file: ./build/images/openim-tools/openim-web/Dockerfile platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta1.outputs.tags }} - labels: ${{ steps.meta1.outputs.labels }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - - - name: Extract metadata (tags, labels) for Docker openim-web - id: meta2 - uses: docker/metadata-action@v5.0.0 - with: - images: ghcr.io/openimsdk/component - - - name: Build and push Docker image for component - uses: docker/build-push-action@v5 - with: - context: . - file: ./build/images/openim-tools/component/Dockerfile - platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta2.outputs.tags }} - labels: ${{ steps.meta2.outputs.labels }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + labels: ${{ steps.meta2.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/openimci.yml b/.github/workflows/openimci.yml index 0f0aa2049..347f6d762 100644 --- a/.github/workflows/openimci.yml +++ b/.github/workflows/openimci.yml @@ -48,7 +48,7 @@ jobs: strategy: matrix: - go_version: ["1.18","1.19","1.20","1.21"] + go_version: ["1.19","1.20","1.21"] os: [ubuntu-latest] steps: diff --git a/README-zh_CN.md b/README-zh_CN.md index 9234666f4..8addfe20a 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -98,6 +98,11 @@ OpenIM 我们的目标是建立一个顶级的开源社区。我们有一套标 + [接口标准](https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/interface.md) ++ [OpenIM配置和环境变量设置](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md) + +> **Note** +> 针对中国的用户,阅读我们的 [Docker 镜像标准](https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/images.md) 以便使用国内 aliyun 的镜像地址。OpenIM 也有针对中国的 gitee 同步仓库,你可以在 [gitee.com](https://gitee.com/openimsdk) 上找到它。 + ## :link: 链接 + **[完整文档](https://doc.rentsoft.cn/)** diff --git a/README.md b/README.md index d2482f59c..f58625fb0 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ It is recommended to use Docker Compose for deployment, which can easily and qui
Compile from Source -Ur need `Go 1.18` or higher version, and `make`. +Ur need `Go 1.20` or higher version, and `make`. ```bash @@ -212,6 +212,8 @@ Before you start, please make sure your changes are in demand. The best for that - [Interface Standards](https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/api.md) - [Log Standards](https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/logging.md) - [Error Code Standards](https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/error_code.md) +- [OpenIM configuration and environment variable Settings](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md) + ## :busts_in_silhouette: Community diff --git a/build/images/Dockerfile b/build/images/Dockerfile new file mode 100644 index 000000000..518de78b1 --- /dev/null +++ b/build/images/Dockerfile @@ -0,0 +1,10 @@ +FROM BASE_IMAGE + +WORKDIR ${SERVER_WORKDIR} + +# Set HTTP proxy +ARG BINARY_NAME + +COPY BINARY_NAME ./bin/BINARY_NAME + +ENTRYPOINT ["./bin/BINARY_NAME"] \ No newline at end of file diff --git a/build/images/openim-api/Dockerfile b/build/images/openim-api/Dockerfile index 44d4c6ba4..8c3d710f1 100644 --- a/build/images/openim-api/Dockerfile +++ b/build/images/openim-api/Dockerfile @@ -31,20 +31,15 @@ RUN go mod download COPY . . -RUN make clean RUN make build BINS=openim-api +RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-api /usr/bin/openim-api + # FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:latest WORKDIR /openim/openim-server -COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms -COPY --from=builder /openim/openim-server/config /openim/openim-server/config - -ENV PORT 10002 -EXPOSE 10002 - -RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-api /usr/bin/openim-api +COPY --from=builder /usr/bin/openim-api ./bin/openim-api -ENTRYPOINT ["bash", "-c", "openim-api -c $OPENIM_SERVER_CONFIG_NAME --port $PORT"] +ENTRYPOINT ["./bin/openim-api"] diff --git a/build/images/openim-api/Dockerfile.release b/build/images/openim-api/Dockerfile.release deleted file mode 100644 index 8d06221a7..000000000 --- a/build/images/openim-api/Dockerfile.release +++ /dev/null @@ -1,8 +0,0 @@ -FROM ghcr.io/openim-sigs/openim-bash-image:latest - -COPY openim-api /usr/bin/ - -# nosemgrep: dockerfile.security.missing-user.missing-user -ENTRYPOINT ["/usr/bin/openim-api"] -# nosemgrep: dockerfile.security.missing-user.missing-user -CMD ["--help"] \ No newline at end of file diff --git a/build/images/openim-cmdutils/Dockerfile b/build/images/openim-cmdutils/Dockerfile index 56923fe8a..413016f24 100644 --- a/build/images/openim-cmdutils/Dockerfile +++ b/build/images/openim-cmdutils/Dockerfile @@ -31,19 +31,15 @@ RUN go mod download COPY . . -RUN go mod download -RUN make clean RUN make build BINS=openim-cmdutils +RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-cmdutils /usr/bin/openim-cmdutils FROM ghcr.io/openim-sigs/openim-bash-image:latest WORKDIR /openim/openim-server -COPY --from=builder $OPENIM_SERVER_BINDIR/platforms /openim/openim-server/_output/bin/platforms -COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config - -RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-cmdutils /usr/bin/openim-cmdutils +COPY --from=builder /usr/bin/openim-cmdutils ./bin/openim-cmdutils -ENTRYPOINT ["openim-cmdutils"] +ENTRYPOINT ["./bin/openim-cmdutils"] CMD ["--help"] diff --git a/build/images/openim-crontask/Dockerfile b/build/images/openim-crontask/Dockerfile index 04334e4ff..35ba75784 100644 --- a/build/images/openim-crontask/Dockerfile +++ b/build/images/openim-crontask/Dockerfile @@ -31,18 +31,15 @@ RUN go mod download COPY . . -RUN make clean RUN make build BINS=openim-crontask +RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-crontask /usr/bin/openim-crontask + +# FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:latest WORKDIR /openim/openim-server -COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms -COPY --from=builder /openim/openim-server/config /openim/openim-server/config - -ENV OPENIM_SERVER_CONFIG_NAME=/openim/openim-server/config - -RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-crontask /usr/bin/openim-crontask +COPY --from=builder /usr/bin/openim-crontask ./bin/openim-crontask -CMD ["bash", "-c", "openim-crontask -c $OPENIM_SERVER_CONFIG_NAME"] +ENTRYPOINT ["./bin/openim-crontask"] diff --git a/build/images/openim-msggateway/Dockerfile b/build/images/openim-msggateway/Dockerfile index 35c4c7a1d..fe9db8f32 100644 --- a/build/images/openim-msggateway/Dockerfile +++ b/build/images/openim-msggateway/Dockerfile @@ -31,22 +31,15 @@ RUN go mod download COPY . . -RUN make clean RUN make build BINS=openim-msggateway +RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-msggateway /usr/bin/openim-msggateway + +# FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:latest WORKDIR /openim/openim-server -COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms -COPY --from=builder /openim/openim-server/config /openim/openim-server/config - -ENV PORT 10140 \ - WS_PORT 10001 - -EXPOSE 10140 -EXPOSE 10001 - -RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-msggateway /usr/bin/openim-msggateway +COPY --from=builder /usr/bin/openim-msggateway ./bin/openim-msggateway -CMD ["bash", "-c", "openim-msggateway -c $OPENIM_SERVER_CONFIG_NAME --port $PORT --ws_port $WS_PORT"] \ No newline at end of file +ENTRYPOINT ["./bin/openim-msggateway"] diff --git a/build/images/openim-msgtransfer/Dockerfile b/build/images/openim-msgtransfer/Dockerfile index 57d11be52..c04425f94 100644 --- a/build/images/openim-msgtransfer/Dockerfile +++ b/build/images/openim-msgtransfer/Dockerfile @@ -31,16 +31,15 @@ RUN go mod download COPY . . -RUN make clean RUN make build BINS=openim-msgtransfer +RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-msgtransfer /usr/bin/openim-msgtransfer + +# FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:latest WORKDIR /openim/openim-server -COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms -COPY --from=builder /openim/openim-server/config /openim/openim-server/config - -RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-msgtransfer /usr/bin/openim-msgtransfer +COPY --from=builder /usr/bin/openim-msgtransfer ./bin/openim-msgtransfer -ENTRYPOINT ["bash", "-c", "if [[ -n $PROMETHEUS_PORT ]]; then openim-msgtransfer -c $OPENIM_SERVER_CONFIG_NAME --prometheus_port $PROMETHEUS_PORT; else openim-msgtransfer -c $OPENIM_SERVER_CONFIG_NAME; fi"] \ No newline at end of file +ENTRYPOINT ["./bin/openim-msgtransfer"] diff --git a/build/images/openim-push/Dockerfile b/build/images/openim-push/Dockerfile index 287c43450..e51b7a44c 100644 --- a/build/images/openim-push/Dockerfile +++ b/build/images/openim-push/Dockerfile @@ -15,7 +15,6 @@ # OpenIM base image: https://github.com/openim-sigs/openim-base-image # Set go mod installation source and proxy -# docker run -e "PORT=10003" -e "PROMETHEUSORT=4321" --network host -it 67ef891ad1ff FROM golang:1.20 AS builder @@ -32,21 +31,15 @@ RUN go mod download COPY . . -RUN make clean RUN make build BINS=openim-push +RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-push /usr/bin/openim-push + +# FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:latest WORKDIR /openim/openim-server -COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms -COPY --from=builder /openim/openim-server/config /openim/openim-server/config - -ENV PORT 10170 \ - PROMETHEUS_PORT 20170 - -EXPOSE 10170 - -RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-push /usr/bin/openim-push +COPY --from=builder /usr/bin/openim-push ./bin/openim-push -ENTRYPOINT ["bash", "-c", "if [[ -n $PROMETHEUS_PORT ]]; then openim-push -c $OPENIM_SERVER_CONFIG_NAME --port $PORT --prometheus_port $PROMETHEUS_PORT; else openim-push -c $OPENIM_SERVER_CONFIG_NAME --port $PORT; fi"] \ No newline at end of file +ENTRYPOINT ["./bin/openim-push"] diff --git a/build/images/openim-rpc-auth/Dockerfile b/build/images/openim-rpc-auth/Dockerfile index a581bfc04..8054935bd 100644 --- a/build/images/openim-rpc-auth/Dockerfile +++ b/build/images/openim-rpc-auth/Dockerfile @@ -31,22 +31,15 @@ RUN go mod download COPY . . -RUN make clean - RUN make build BINS=openim-rpc-auth +RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth /usr/bin/openim-rpc-auth + +# FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:latest WORKDIR /openim/openim-server -COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms/ -COPY --from=builder /openim/openim-server/config /openim/openim-server/config - -ENV PORT 10160 \ - PROMETHEUS_PORT 20160 - -EXPOSE 10160 - -RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-rpc-auth /usr/bin/openim-rpc-auth +COPY --from=builder /usr/bin/openim-rpc-auth ./bin/openim-rpc-auth -ENTRYPOINT ["bash", "-c", "if [[ -n $PROMETHEUS_PORT ]]; then "openim-rpc-auth --port $PORT -c $OPENIM_SERVER_CONFIG_NAME" --prometheus_port $PROMETHEUS_PORT; else "openim-rpc-auth --port $PORT -c $OPENIM_SERVER_CONFIG_NAME"; fi"] \ No newline at end of file +ENTRYPOINT ["./bin/openim-rpc-auth"] diff --git a/build/images/openim-rpc-conversation/Dockerfile b/build/images/openim-rpc-conversation/Dockerfile index 887a77f36..0cfb681a2 100644 --- a/build/images/openim-rpc-conversation/Dockerfile +++ b/build/images/openim-rpc-conversation/Dockerfile @@ -31,22 +31,15 @@ RUN go mod download COPY . . -RUN make clean - RUN make build BINS=openim-rpc-conversation +RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation /usr/bin/openim-rpc-conversation + +# FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:latest WORKDIR /openim/openim-server -COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms/ -COPY --from=builder /openim/openim-server/config /openim/openim-server/config - -ENV PORT 10230 \ - PROMETHEUS_PORT 20230 - -EXPOSE 10230 - -RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-rpc-conversation /usr/bin/openim-rpc-conversation +COPY --from=builder /usr/bin/openim-rpc-conversation ./bin/openim-rpc-conversation -ENTRYPOINT ["bash", "-c", "if [[ -n $PROMETHEUS_PORT ]]; then "openim-rpc-conversation --port $PORT -c $OPENIM_SERVER_CONFIG_NAME" --prometheus_port $PROMETHEUS_PORT; else "openim-rpc-conversation --port $PORT -c $OPENIM_SERVER_CONFIG_NAME"; fi"] \ No newline at end of file +ENTRYPOINT ["./bin/openim-rpc-conversation"] diff --git a/build/images/openim-rpc-friend/Dockerfile b/build/images/openim-rpc-friend/Dockerfile index 9954daf99..36870bc7e 100644 --- a/build/images/openim-rpc-friend/Dockerfile +++ b/build/images/openim-rpc-friend/Dockerfile @@ -31,22 +31,15 @@ RUN go mod download COPY . . -RUN make clean - RUN make build BINS=openim-rpc-friend +RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-friend /usr/bin/openim-rpc-friend + +# FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:latest WORKDIR /openim/openim-server -COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms/ -COPY --from=builder /openim/openim-server/config /openim/openim-server/config - -ENV PORT 10120 \ - PROMETHEUS_PORT 20120 - -EXPOSE 10120 - -RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-rpc-friend /usr/bin/openim-rpc-friend +COPY --from=builder /usr/bin/openim-rpc-friend ./bin/openim-rpc-friend -ENTRYPOINT ["bash", "-c", "if [[ -n $PROMETHEUS_PORT ]]; then "openim-rpc-friend --port $PORT -c $OPENIM_SERVER_CONFIG_NAME" --prometheus_port $PROMETHEUS_PORT; else "openim-rpc-friend --port $PORT -c $OPENIM_SERVER_CONFIG_NAME"; fi"] +ENTRYPOINT ["./bin/openim-rpc-friend"] diff --git a/build/images/openim-rpc-group/Dockerfile b/build/images/openim-rpc-group/Dockerfile index 627560075..85ba3b74d 100644 --- a/build/images/openim-rpc-group/Dockerfile +++ b/build/images/openim-rpc-group/Dockerfile @@ -31,22 +31,15 @@ RUN go mod download COPY . . -RUN make clean - RUN make build BINS=openim-rpc-group +RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-group /usr/bin/openim-rpc-group + +# FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:latest WORKDIR /openim/openim-server -COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms/ -COPY --from=builder /openim/openim-server/config /openim/openim-server/config - -ENV PORT 10150 \ - PROMETHEUS_PORT 20150 - -EXPOSE 10150 - -RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-rpc-group /usr/bin/openim-rpc-group +COPY --from=builder /usr/bin/openim-rpc-group ./bin/openim-rpc-group -ENTRYPOINT ["bash", "-c", "if [[ -n $PROMETHEUS_PORT ]]; then "openim-rpc-group --port $PORT -c $OPENIM_SERVER_CONFIG_NAME" --prometheus_port $PROMETHEUS_PORT; else "openim-rpc-group --port $PORT -c $OPENIM_SERVER_CONFIG_NAME"; fi"] \ No newline at end of file +ENTRYPOINT ["./bin/openim-rpc-group"] diff --git a/build/images/openim-rpc-msg/Dockerfile b/build/images/openim-rpc-msg/Dockerfile index e7426bcf0..7e1aaf50b 100644 --- a/build/images/openim-rpc-msg/Dockerfile +++ b/build/images/openim-rpc-msg/Dockerfile @@ -31,22 +31,15 @@ RUN go mod download COPY . . -RUN make clean - RUN make build BINS=openim-rpc-msg +RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-msg /usr/bin/openim-rpc-msg + +# FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:latest WORKDIR /openim/openim-server -COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms/ -COPY --from=builder /openim/openim-server/config /openim/openim-server/config - -ENV PORT 10130 \ - PROMETHEUS_PORT 20130 - -EXPOSE 10130 - -RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-rpc-msg /usr/bin/openim-rpc-msg +COPY --from=builder /usr/bin/openim-rpc-msg ./bin/openim-rpc-msg -ENTRYPOINT ["bash", "-c", "if [[ -n $PROMETHEUS_PORT ]]; then "openim-rpc-msg --port $PORT -c $OPENIM_SERVER_CONFIG_NAME" --prometheus_port $PROMETHEUS_PORT; else "openim-rpc-msg --port $PORT -c $OPENIM_SERVER_CONFIG_NAME"; fi"] \ No newline at end of file +ENTRYPOINT ["./bin/openim-rpc-msg"] diff --git a/build/images/openim-rpc-third/Dockerfile b/build/images/openim-rpc-third/Dockerfile index 700fd2918..ab3e6c949 100644 --- a/build/images/openim-rpc-third/Dockerfile +++ b/build/images/openim-rpc-third/Dockerfile @@ -31,23 +31,15 @@ RUN go mod download COPY . . -RUN make clean - RUN make build BINS=openim-rpc-third +RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-third /usr/bin/openim-rpc-third +# FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:latest WORKDIR /openim/openim-server -COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms/ -COPY --from=builder /openim/openim-server/config /openim/openim-server/config - -ENV PORT 10190 \ - PROMETHEUS_PORT 21301 - -EXPOSE 10190 - -RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-rpc-third /usr/bin/openim-rpc-third +COPY --from=builder /usr/bin/openim-rpc-third ./bin/openim-rpc-third -ENTRYPOINT ["bash", "-c", "if [[ -n $PROMETHEUS_PORT ]]; then "openim-rpc-third --port $PORT -c $OPENIM_SERVER_CONFIG_NAME" --prometheus_port $PROMETHEUS_PORT; else "openim-rpc-third --port $PORT -c $OPENIM_SERVER_CONFIG_NAME"; fi"] +ENTRYPOINT ["./bin/openim-rpc-third"] diff --git a/build/images/openim-rpc-user/Dockerfile b/build/images/openim-rpc-user/Dockerfile index 00804f2bf..cd0121b7d 100644 --- a/build/images/openim-rpc-user/Dockerfile +++ b/build/images/openim-rpc-user/Dockerfile @@ -31,22 +31,15 @@ RUN go mod download COPY . . -RUN make clean - RUN make build BINS=openim-rpc-user +RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-user /usr/bin/openim-rpc-user + +# FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:latest WORKDIR /openim/openim-server -COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms/ -COPY --from=builder /openim/openim-server/config /openim/openim-server/config - -ENV PORT 10110 \ - PROMETHEUS_PORT 20110 - -EXPOSE 10110 - -RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-rpc-user /usr/bin/openim-rpc-user +COPY --from=builder /usr/bin/openim-rpc-user ./bin/openim-rpc-user -ENTRYPOINT ["bash", "-c", "if [[ -n $PROMETHEUS_PORT ]]; then "openim-rpc-user --port $PORT -c $OPENIM_SERVER_CONFIG_NAME" --prometheus_port $PROMETHEUS_PORT; else "openim-rpc-user --port $PORT -c $OPENIM_SERVER_CONFIG_NAME"; fi"] +ENTRYPOINT ["./bin/openim-rpc-user"] diff --git a/cmd/openim-api/main.go b/cmd/openim-api/main.go index 3034d6645..f6db87353 100644 --- a/cmd/openim-api/main.go +++ b/cmd/openim-api/main.go @@ -17,72 +17,83 @@ package main import ( "context" "fmt" - "github.com/openimsdk/open-im-server/v3/pkg/common/discovery_register" "net" _ "net/http/pprof" "strconv" + "github.com/openimsdk/open-im-server/v3/pkg/common/discovery_register" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/log" - "github.com/openimsdk/open-im-server/v3/internal/api" "github.com/openimsdk/open-im-server/v3/pkg/common/cmd" "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/open-im-server/v3/pkg/common/db/cache" ) + func main() { apiCmd := cmd.NewApiCmd() apiCmd.AddPortFlag() apiCmd.AddApi(run) if err := apiCmd.Execute(); err != nil { + log.ZError(context.Background(), "API command execution failed", err) panic(err.Error()) } } func run(port int) error { - fmt.Println("*****openimapi port:", port) + log.ZInfo(context.Background(), "Openim api port:", "port", port) + if port == 0 { - return fmt.Errorf("port is empty") + err := "port is empty" + log.ZError(context.Background(), err, nil) + + return fmt.Errorf(err) } rdb, err := cache.NewRedis() if err != nil { + log.ZError(context.Background(), "Failed to initialize Redis", err) + return err } - fmt.Println("api start init discov client") + log.ZInfo(context.Background(), "api start init discov client") + var client discoveryregistry.SvcDiscoveryRegistry + + // Determine whether zk is passed according to whether it is a clustered deployment client, err = discovery_register.NewDiscoveryRegister(config.Config.Envs.Discovery) - /* - client, err = openkeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema, - openkeeper.WithFreq(time.Hour), openkeeper.WithUserNameAndPassword( - config.Config.Zookeeper.Username, - config.Config.Zookeeper.Password, - ), openkeeper.WithRoundRobin(), openkeeper.WithTimeout(10), openkeeper.WithLogger(log.NewZkLogger()))*/ if err != nil { + log.ZError(context.Background(), "Failed to initialize discovery register", err) + return err } if err = client.CreateRpcRootNodes(config.Config.GetServiceNames()); err != nil { + log.ZError(context.Background(), "Failed to create RPC root nodes", err) + return err } - fmt.Println("api register public config to discov") + log.ZInfo(context.Background(), "api register public config to discov") if err = client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.Config.EncodeConfig()); err != nil { + log.ZError(context.Background(), "Failed to register public config to discov", err) + return err } - fmt.Println("api register public config to discov success") + log.ZInfo(context.Background(), "api register public config to discov success") router := api.NewGinRouter(client, rdb) - fmt.Println("api init router success") + log.ZInfo(context.Background(), "api init router success") var address string if config.Config.Api.ListenIP != "" { address = net.JoinHostPort(config.Config.Api.ListenIP, strconv.Itoa(port)) } else { address = net.JoinHostPort("0.0.0.0", strconv.Itoa(port)) } - fmt.Println("start api server, address: ", address, ", OpenIM version: ", config.Version) - log.ZInfo(context.Background(), "start server success", "address", address, "version", config.Version) + log.ZInfo(context.Background(), "start api server", "address", address, "OpenIM version", config.Version) + err = router.Run(address) if err != nil { - log.ZError(context.Background(), "api run failed ", err, "address", address) + log.ZError(context.Background(), "api run failed", err, "address", address) return err } diff --git a/deployments/README.md b/deployments/README.md index 7065d45fa..e070d8e1f 100644 --- a/deployments/README.md +++ b/deployments/README.md @@ -80,6 +80,12 @@ $ sudo sealos run labring/kubernetes:v1.25.0 labring/helm:v3.8.2 labring/calico: -p "$CLUSTER_PASSWORD" ``` +> **Node** +> 卸载的方式:使用 `kubeadm` 卸载并不会清除 `etcd` 和 `cni` 相关,所以需要手动清除,或者使用 `sealos` 卸载。 +> ```bash +> sealos reset +> ``` + ### 安装 helm helm通过打包的方式,支持发布的版本管理和控制,很大程度上简化了Kubernetes应用的部署和管理。 @@ -97,11 +103,17 @@ $ curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bas $ helm repo add brigade https://openimsdk.github.io/openim-charts ``` +### OpenIM 的镜像策略 -### 容器化安装 +自动化提供的 aliyun, ghcr, docker hub: https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/images.md -具体安装步骤如下: +**本地化测试构建方法:** + +```bash +$ make image +``` +### 容器化安装 -### Helm安装 +具体安装步骤如下: diff --git a/deployments/openim-chat/.helmignore b/deployments/openim-chat/.helmignore deleted file mode 100644 index 0e8a0eb36..000000000 --- a/deployments/openim-chat/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/deployments/openim-chat/Chart.yaml b/deployments/openim-chat/Chart.yaml deleted file mode 100644 index 4466fc928..000000000 --- a/deployments/openim-chat/Chart.yaml +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright © 2023 OpenIM. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: v2 -name: openim-chat -description: A Helm chart for Kubernetes - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. Versions are not expected to -# follow Semantic Versioning. They should reflect the version the application is using. -# It is recommended to use it with quotes. -appVersion: "1.16.0" diff --git a/deployments/openim-chat/LICENSE b/deployments/openim-chat/LICENSE deleted file mode 100644 index 261eeb9e9..000000000 --- a/deployments/openim-chat/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/deployments/openim-chat/templates/NOTES.txt b/deployments/openim-chat/templates/NOTES.txt deleted file mode 100644 index 17cfb43fe..000000000 --- a/deployments/openim-chat/templates/NOTES.txt +++ /dev/null @@ -1,22 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range $host := .Values.ingress.hosts }} - {{- range .paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} - {{- end }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-chat.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-chat.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-chat.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-chat.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT -{{- end }} diff --git a/deployments/openim-chat/templates/_helpers.tpl b/deployments/openim-chat/templates/_helpers.tpl deleted file mode 100644 index 3177accfb..000000000 --- a/deployments/openim-chat/templates/_helpers.tpl +++ /dev/null @@ -1,62 +0,0 @@ -{{/* -Expand the name of the chart. -*/}} -{{- define "openim-chat.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "openim-chat.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} -{{- end }} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "openim-chat.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "openim-chat.labels" -}} -helm.sh/chart: {{ include "openim-chat.chart" . }} -{{ include "openim-chat.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "openim-chat.selectorLabels" -}} -app.kubernetes.io/name: {{ include "openim-chat.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} - -{{/* -Create the name of the service account to use -*/}} -{{- define "openim-chat.serviceAccountName" -}} -{{- if .Values.serviceAccount.create }} -{{- default (include "openim-chat.fullname" .) .Values.serviceAccount.name }} -{{- else }} -{{- default "default" .Values.serviceAccount.name }} -{{- end }} -{{- end }} diff --git a/deployments/openim-chat/templates/deployment.yaml b/deployments/openim-chat/templates/deployment.yaml deleted file mode 100644 index 47d88c590..000000000 --- a/deployments/openim-chat/templates/deployment.yaml +++ /dev/null @@ -1,75 +0,0 @@ -# Copyright © 2023 OpenIM. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "openim-chat.fullname" . }} - labels: - {{- include "openim-chat.labels" . | nindent 4 }} -spec: - {{- if not .Values.autoscaling.enabled }} - replicas: {{ .Values.replicaCount }} - {{- end }} - selector: - matchLabels: - {{- include "openim-chat.selectorLabels" . | nindent 6 }} - template: - metadata: - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "openim-chat.selectorLabels" . | nindent 8 }} - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "openim-chat.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - containers: - - name: {{ .Chart.Name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: 80 - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/deployments/openim-chat/templates/hpa.yaml b/deployments/openim-chat/templates/hpa.yaml deleted file mode 100644 index 5f28b13fe..000000000 --- a/deployments/openim-chat/templates/hpa.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright © 2023 OpenIM. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -{{- if .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2beta1 -kind: HorizontalPodAutoscaler -metadata: - name: {{ include "openim-chat.fullname" . }} - labels: - {{- include "openim-chat.labels" . | nindent 4 }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ include "openim-chat.fullname" . }} - minReplicas: {{ .Values.autoscaling.minReplicas }} - maxReplicas: {{ .Values.autoscaling.maxReplicas }} - metrics: - {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} - - type: Resource - resource: - name: cpu - targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- end }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} -{{- end }} diff --git a/deployments/openim-chat/templates/ingress.yaml b/deployments/openim-chat/templates/ingress.yaml deleted file mode 100644 index 3faa231d0..000000000 --- a/deployments/openim-chat/templates/ingress.yaml +++ /dev/null @@ -1,75 +0,0 @@ -# Copyright © 2023 OpenIM. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "openim-chat.fullname" . -}} -{{- $svcPort := .Values.service.port -}} -{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} - {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} - {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} - {{- end }} -{{- end }} -{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: networking.k8s.io/v1 -{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: networking.k8s.io/v1beta1 -{{- else -}} -apiVersion: extensions/v1beta1 -{{- end }} -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - {{- include "openim-chat.labels" . | nindent 4 }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} - ingressClassName: {{ .Values.ingress.className }} - {{- end }} - {{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} - {{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ .host | quote }} - http: - paths: - {{- range .paths }} - - path: {{ .path }} - {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} - pathType: {{ .pathType }} - {{- end }} - backend: - {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} - service: - name: {{ $fullName }} - port: - number: {{ $svcPort }} - {{- else }} - serviceName: {{ $fullName }} - servicePort: {{ $svcPort }} - {{- end }} - {{- end }} - {{- end }} -{{- end }} diff --git a/deployments/openim-chat/templates/service.yaml b/deployments/openim-chat/templates/service.yaml deleted file mode 100644 index c504be550..000000000 --- a/deployments/openim-chat/templates/service.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright © 2023 OpenIM. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: v1 -kind: Service -metadata: - name: {{ include "openim-chat.fullname" . }} - labels: - {{- include "openim-chat.labels" . | nindent 4 }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - {{- include "openim-chat.selectorLabels" . | nindent 4 }} diff --git a/deployments/openim-chat/templates/serviceaccount.yaml b/deployments/openim-chat/templates/serviceaccount.yaml deleted file mode 100644 index 8fd4f4e21..000000000 --- a/deployments/openim-chat/templates/serviceaccount.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright © 2023 OpenIM. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -{{- if .Values.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "openim-chat.serviceAccountName" . }} - labels: - {{- include "openim-chat.labels" . | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} diff --git a/deployments/openim-chat/values.yaml b/deployments/openim-chat/values.yaml deleted file mode 100644 index b1c083fee..000000000 --- a/deployments/openim-chat/values.yaml +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright © 2023 OpenIM. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Default values for openim-chat. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -replicaCount: 1 - -image: - repository: nginx - pullPolicy: IfNotPresent - # Overrides the image tag whose default is the chart appVersion. - tag: "" - -imagePullSecrets: [] -nameOverride: "" -fullnameOverride: "" - -serviceAccount: - # Specifies whether a service account should be created - create: true - # Annotations to add to the service account - annotations: {} - # The name of the service account to use. - # If not set and create is true, a name is generated using the fullname template - name: "" - -podAnnotations: {} - -podSecurityContext: {} - # fsGroup: 2000 - -securityContext: {} - # capabilities: - # drop: - # - ALL - # readOnlyRootFilesystem: true - # runAsNonRoot: true - # runAsUser: 1000 - -service: - type: ClusterIP - port: 80 - -ingress: - enabled: false - className: "" - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - hosts: - - host: chart-example.local - paths: - - path: / - pathType: ImplementationSpecific - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi - -autoscaling: - enabled: false - minReplicas: 1 - maxReplicas: 100 - targetCPUUtilizationPercentage: 80 - # targetMemoryUtilizationPercentage: 80 - -nodeSelector: {} - -tolerations: [] - -affinity: {} diff --git a/docs/contrib/environment.md b/docs/contrib/environment.md index 34959047a..6efddafd3 100644 --- a/docs/contrib/environment.md +++ b/docs/contrib/environment.md @@ -1,20 +1,19 @@ -# OpenIM enviroment +# OpenIM ENVIRONMENT CONFIGURATION - * 1. [OpenIM Deployment Guide](#OpenIMDeploymentGuide) * 1.1. [Deployment Strategies](#DeploymentStrategies) * 1.2. [Source Code Deployment](#SourceCodeDeployment) * 1.3. [Docker Compose Deployment](#DockerComposeDeployment) * 1.4. [Environment Variable Configuration](#EnvironmentVariableConfiguration) - * 1.4.1. [[1. Recommended using environment variables:](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#1-recommended-using-environment-variables)](#1.Recommendedusingenvironmentvariables:https:github.comopenimsdkopen-im-serverblobmaindocscontribenvironment.md1-recommended-using-environment-variables) - * 1.4.2. [[Additional Configuration](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#additional-configuration)](#AdditionalConfigurationhttps:github.comopenimsdkopen-im-serverblobmaindocscontribenvironment.mdadditional-configuration) - * 1.4.3. [[Security Considerations](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#security-considerations)](#SecurityConsiderationshttps:github.comopenimsdkopen-im-serverblobmaindocscontribenvironment.mdsecurity-considerations) - * 1.4.4. [[Data Management](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#data-management)](#DataManagementhttps:github.comopenimsdkopen-im-serverblobmaindocscontribenvironment.mddata-management) - * 1.4.5. [[Monitoring and Logging](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#monitoring-and-logging)](#MonitoringandLogginghttps:github.comopenimsdkopen-im-serverblobmaindocscontribenvironment.mdmonitoring-and-logging) - * 1.4.6. [[Troubleshooting](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#troubleshooting)](#Troubleshootinghttps:github.comopenimsdkopen-im-serverblobmaindocscontribenvironment.mdtroubleshooting) - * 1.4.7. [[Conclusion](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#conclusion)](#Conclusionhttps:github.comopenimsdkopen-im-serverblobmaindocscontribenvironment.mdconclusion) - * 1.4.8. [[Additional Resources](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#additional-resources)](#AdditionalResourceshttps:github.comopenimsdkopen-im-serverblobmaindocscontribenvironment.mdadditional-resources) + * 1.4.1. [Recommended using environment variables](#Recommendedusingenvironmentvariables) + * 1.4.2. [Additional Configuration](#AdditionalConfiguration) + * 1.4.3. [Security Considerations](#SecurityConsiderations) + * 1.4.4. [Data Management](#DataManagement) + * 1.4.5. [Monitoring and Logging](#MonitoringandLogging) + * 1.4.6. [Troubleshooting](#Troubleshooting) + * 1.4.7. [Conclusion](#Conclusion) + * 1.4.8. [Additional Resources](#AdditionalResources) * 2. [Further Configuration](#FurtherConfiguration) * 2.1. [Image Registry Configuration](#ImageRegistryConfiguration) * 2.2. [OpenIM Docker Network Configuration](#OpenIMDockerNetworkConfiguration) @@ -39,11 +38,38 @@ * 2.20.1. [General Configuration](#GeneralConfiguration) * 2.20.2. [Service-Specific Prometheus Ports](#Service-SpecificPrometheusPorts) - - +## 0. OpenIM Config File + +Ensuring that OpenIM operates smoothly requires clear direction on the configuration file's location. Here's a detailed step-by-step guide on how to provide this essential path to OpenIM: + +1. **Using the Command-line Argument**: + + + **For Configuration Path**: When initializing OpenIM, you can specify the path to the configuration file directly using the `-c` or `--config_folder_path` option. + + ```bash + ❯ _output/bin/platforms/linux/amd64/openim-api --config_folder_path="/your/config/folder/path" + ``` + + + **For Port Specification**: Similarly, if you wish to designate a particular port, utilize the `-p` option followed by the desired port number. + + ```bash + ❯ _output/bin/platforms/linux/amd64/openim-api -p 1234 + ``` + + Note: If the port is not specified here, OpenIM will fetch it from the configuration file. Setting the port via environment variables isn't supported. We recommend consolidating settings in the configuration file for a more consistent and streamlined setup. + +2. **Leveraging the Environment Variable**: + + You have the flexibility to determine OpenIM's configuration path by setting an `OPENIMCONFIG` environment variable. This method provides a seamless way to instruct OpenIM without command-line parameters every time. + + ```bash + export OPENIMCONFIG="/path/to/your/config" + ``` + +3. **Relying on the Default Path**: + + In scenarios where neither command-line arguments nor environment variables are provided, OpenIM will intuitively revert to the `config/` directory to locate its configuration. + ## 1. OpenIM Deployment Guide @@ -96,7 +122,7 @@ Setting a variable, e.g., `export CHAT_BRANCH="release-v1.3"`, will prioritize ` For convenience, configuration through modifying environment variables is recommended: -#### 1.4.1. [1. Recommended using environment variables:](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#1-recommended-using-environment-variables) +#### 1.4.1. Recommended using environment variables + PASSWORD @@ -137,9 +163,9 @@ For convenience, configuration through modifying environment variables is recomm export DATA_DIR="/data/openim" ``` -#### 1.4.2. [Additional Configuration](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#additional-configuration) +#### 1.4.2. Additional Configuration -##### [MinIO Access and Secret Key](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#minio-access-and-secret-key) +##### MinIO Access and Secret Key To secure your MinIO server, you should set up an access key and secret key. These credentials are used to authenticate requests to your MinIO server. @@ -148,7 +174,7 @@ export MINIO_ACCESS_KEY="YourAccessKey" export MINIO_SECRET_KEY="YourSecretKey" ``` -##### [MinIO Browser](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#minio-browser) +##### MinIO Browser MinIO comes with an embedded web-based object browser. You can control the availability of the MinIO browser by setting the `MINIO_BROWSER` environment variable. @@ -156,9 +182,9 @@ MinIO comes with an embedded web-based object browser. You can control the avail export MINIO_BROWSER="on" ``` -#### 1.4.3. [Security Considerations](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#security-considerations) +#### 1.4.3. Security Considerations -##### [TLS/SSL Configuration](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#tls-ssl-configuration) +##### TLS/SSL Configuration For secure communication, it's recommended to enable TLS/SSL for your MinIO server. You can do this by providing the path to the SSL certificate and key files. @@ -166,9 +192,9 @@ For secure communication, it's recommended to enable TLS/SSL for your MinIO serv export MINIO_CERTS_DIR="/path/to/certs/directory" ``` -#### 1.4.4. [Data Management](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#data-management) +#### 1.4.4. Data Management -##### [Data Retention Policy](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#data-retention-policy) +##### Data Retention Policy You may want to set up a data retention policy to automatically delete objects after a specified period. @@ -176,7 +202,7 @@ You may want to set up a data retention policy to automatically delete objects a export MINIO_RETENTION_DAYS="30" ``` -#### 1.4.5. [Monitoring and Logging](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#monitoring-and-logging) +#### 1.4.5. Monitoring and Logging ##### [Audit Logging](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#audit-logging) @@ -186,9 +212,9 @@ Enable audit logging to keep track of access and changes to your data. export MINIO_AUDIT="on" ``` -#### 1.4.6. [Troubleshooting](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#troubleshooting) +#### 1.4.6. Troubleshooting -##### [Debug Mode](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#debug-mode) +##### Debug Mode In case of issues, you may enable debug mode to get more detailed logs to assist in troubleshooting. @@ -196,11 +222,11 @@ In case of issues, you may enable debug mode to get more detailed logs to assist export MINIO_DEBUG="on" ``` -#### 1.4.7. [Conclusion](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#conclusion) +#### 1.4.7. Conclusion With the environment variables configured as per your requirements, your MinIO server should be ready to securely store and manage your object data. Ensure to verify the setup and monitor the logs for any unusual activities or errors. Regularly update the MinIO server and review your configuration to adapt to any changes or improvements in the MinIO system. -#### 1.4.8. [Additional Resources](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md#additional-resources) +#### 1.4.8. Additional Resources + [MinIO Client Quickstart Guide](https://docs.min.io/docs/minio-client-quickstart-guide) + [MinIO Admin Complete Guide](https://docs.min.io/docs/minio-admin-complete-guide) diff --git a/go.mod b/go.mod index 8510f780d..c26bcad59 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/openimsdk/open-im-server/v3 -go 1.18 +go 1.19 require ( firebase.google.com/go v3.13.0+incompatible diff --git a/go.sum b/go.sum index 0e19ebfbf..4bdc0b51b 100644 --- a/go.sum +++ b/go.sum @@ -44,14 +44,21 @@ github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583j github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/cilium/ebpf v0.11.0 h1:V8gS/bTCCjX9uUnkUFUpPsksM8n1lXBAvHcpiFk1X2Y= +github.com/cilium/ebpf v0.11.0/go.mod h1:WE7CZAnqOL2RouJ4f1uyNhqr2P4CCvXFIqdRDUgWsVs= github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I= github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cosiner/argv v0.1.0 h1:BVDiEL32lwHukgJKP87btEPenzrrHUjajs/8yzaqcXg= +github.com/cosiner/argv v0.1.0/go.mod h1:EusR6TucWKX+zFgtdUsKT2Cvg45K5rtpCcWz4hK06d8= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/derekparker/trie v0.0.0-20221213183930-4c74548207f4 h1:atN94qKNhLpy+9BwbE5nxvFj4rScJi6W3x/NfFmMDg4= +github.com/derekparker/trie v0.0.0-20221213183930-4c74548207f4/go.mod h1:C7Es+DLenIpPc9J6IYw4jrK0h7S9bKj4DNl8+KxGEXU= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= @@ -79,6 +86,10 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= +github.com/go-delve/delve v1.21.1 h1:oDpED8gvXPLS1VKSYzaMH/ihZtyk04H9jqQ9xpyFXl0= +github.com/go-delve/delve v1.21.1/go.mod h1:FgTAiRUe43RS5EexL06RPyMtP8AMZVL/t9Qqgy3qUe4= +github.com/go-delve/liner v1.2.3-0.20220127212407-d32d89dd2a5d h1:pxjSLshkZJGLVm0wv20f/H0oTWiq/egkoJQ2ja6LEvo= +github.com/go-delve/liner v1.2.3-0.20220127212407-d32d89dd2a5d/go.mod h1:biJCRbqp51wS+I92HMqn5H8/A0PAhxn2vyOT+JqhiGI= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= @@ -128,10 +139,13 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-dap v0.9.1 h1:d8dETjgHMR9/xs+Xza+NrZmB7jxIS5OtM2uRsyJVA/c= +github.com/google/go-dap v0.9.1/go.mod h1:HAeyoSd2WIfTfg+0GRXcFrb+RnojAtGNh+k+XTIxJDE= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= @@ -161,6 +175,8 @@ github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9 github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= @@ -207,8 +223,13 @@ github.com/lestrrat-go/strftime v1.0.6 h1:CFGsDEt1pOpFNU+TJB0nhz9jl+K0hZSLE205Ah github.com/lestrrat-go/strftime v1.0.6/go.mod h1:f7jQKgV5nnJpYgdEasS+/y7EsTb8ykN2z68n3TtcTaw= github.com/lithammer/shortuuid v3.0.0+incompatible h1:NcD0xWW/MZYXEHa6ITy6kaXN5nwm/V115vj2YXfhS0w= github.com/lithammer/shortuuid v3.0.0+incompatible/go.mod h1:FR74pbAuElzOUuenUHTK2Tciko1/vKuIKS9dSkDrA4w= +github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= +github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= @@ -267,11 +288,14 @@ github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5X github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/redis/go-redis/v9 v9.2.1 h1:WlYJg71ODF0dVspZZCpYmoF1+U1Jjk9Rwd7pq6QmlCg= github.com/redis/go-redis/v9 v9.2.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= @@ -316,6 +340,8 @@ go.mongodb.org/mongo-driver v1.12.1 h1:nLkghSU8fQNaK7oUmDhQFsnrtcoNy7Z6LVFKsEecq go.mongodb.org/mongo-driver v1.12.1/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.starlark.net v0.0.0-20220816155156-cfacd8902214 h1:MqijAN3S61c7KWasOk+zIqIjHQPN6WUra/X3+YAkQxQ= +go.starlark.net v0.0.0-20220816155156-cfacd8902214/go.mod h1:VZcBMdr3cT3PnBoWunTabuSEXwVAH+ZJ5zxfs3AdASk= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= @@ -335,6 +361,8 @@ golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58 golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 h1:Jvc7gsqn21cJHCmAWx0LiimpP18LZmUxkT5Mp7EZ1mI= +golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.13.0 h1:3cge/F/QTkNLauhf2QoE9zp+7sr+ZcL4HnoZmdwg9sg= golang.org/x/image v0.13.0/go.mod h1:6mmbMOeV28HuMTgA6OSRkdXKYw/t5W9Uwn2Yv1r3Yxk= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -390,10 +418,12 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= diff --git a/go.work b/go.work index 6800fa496..1c819212c 100644 --- a/go.work +++ b/go.work @@ -1,4 +1,4 @@ -go 1.18 +go 1.19 use ( . diff --git a/install.sh b/install.sh index d43767362..9809646fa 100755 --- a/install.sh +++ b/install.sh @@ -40,7 +40,7 @@ REPO="Open-IM-Server" # Version of Go you want to use, make sure it is compatible with your OpenIM-Server requirements. # Default is 1.18, if you want to use a different version, replace accordingly. -GO_VERSION="1.18" +GO_VERSION="1.20" # Default HTTP_PORT is 80. If you want to use a different port, uncomment and replace the value. # HTTP_PORT=80 @@ -168,7 +168,7 @@ function install_go() { command -v go >/dev/null 2>&1 # Determines if GO_VERSION is defined if [ -z "$GO_VERSION" ]; then - GO_VERSION="1.18" + GO_VERSION="1.20" fi if [[ $? -ne 0 ]]; then @@ -309,7 +309,7 @@ function cmd_help() { color_echo ${BLUE_PREFIX} "-t, --tag ${CYAN_PREFIX}specify the tag (default option, set to latest if not specified)${COLOR_SUFFIX}" color_echo ${BLUE_PREFIX} "-r, --release ${CYAN_PREFIX}specify the release branch (cannot be used with the tag option)${COLOR_SUFFIX}" color_echo ${BLUE_PREFIX} "-gt, --github-token ${CYAN_PREFIX}set the GITHUB_TOKEN (default: not set)${COLOR_SUFFIX}" - color_echo ${BLUE_PREFIX} "-g, --go-version ${CYAN_PREFIX}set the Go language version (default: GO_VERSION=\"1.18\")${COLOR_SUFFIX}" + color_echo ${BLUE_PREFIX} "-g, --go-version ${CYAN_PREFIX}set the Go language version (default: GO_VERSION=\"1.20\")${COLOR_SUFFIX}" color_echo ${BLUE_PREFIX} "--install-dir ${CYAN_PREFIX}set the OpenIM installation directory (default: /tmp)${COLOR_SUFFIX}" color_echo ${BLUE_PREFIX} "--cpu ${CYAN_PREFIX}set the number of concurrent processes${COLOR_SUFFIX}" echo @@ -329,7 +329,7 @@ function parseinput() { # CHINA=false # TAG=latest # RELEASE="" - # GO_VERSION=1.18 + # GO_VERSION=1.20 # INSTALL_DIR=/tmp # GITHUB_TOKEN="" # CPU=$(nproc) diff --git a/internal/push/offlinepush/fcm/push.go b/internal/push/offlinepush/fcm/push.go index 27e7dab18..8145d4c17 100644 --- a/internal/push/offlinepush/fcm/push.go +++ b/internal/push/offlinepush/fcm/push.go @@ -18,8 +18,6 @@ import ( "context" "path/filepath" - config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config" - firebase "firebase.google.com/go" "firebase.google.com/go/messaging" "github.com/redis/go-redis/v9" @@ -42,20 +40,17 @@ type Fcm struct { } func NewClient(cache cache.MsgModel) *Fcm { - opt := option.WithCredentialsFile(filepath.Join(config2.Root, "config", config.Config.Push.Fcm.ServiceAccount)) + projectRoot := config.GetProjectRoot() + credentialsFilePath := filepath.Join(projectRoot, "config", config.Config.Push.Fcm.ServiceAccount) + opt := option.WithCredentialsFile(credentialsFilePath) fcmApp, err := firebase.NewApp(context.Background(), nil, opt) if err != nil { return nil } - // auth - // fcmClient, err := fcmApp.Auth(context.Background()) - // if err != nil { - // return - // } + ctx := context.Background() fcmMsgClient, err := fcmApp.Messaging(ctx) if err != nil { - panic(err.Error()) return nil } return &Fcm{fcmMsgCli: fcmMsgClient, cache: cache} diff --git a/pkg/common/cmd/api.go b/pkg/common/cmd/api.go index 19b11d4b2..7ce872fac 100644 --- a/pkg/common/cmd/api.go +++ b/pkg/common/cmd/api.go @@ -28,6 +28,7 @@ type ApiCmd struct { func NewApiCmd() *ApiCmd { ret := &ApiCmd{NewRootCmd("api")} ret.SetRootCmdPt(ret) + return ret } @@ -36,11 +37,13 @@ func (a *ApiCmd) AddApi(f func(port int) error) { return f(a.getPortFlag(cmd)) } } + func (a *ApiCmd) GetPortFromConfig(portType string) int { fmt.Println("GetPortFromConfig:", portType) if portType == constant.FlagPort { return config2.Config.Api.OpenImApiPort[0] } else { + return 0 } } diff --git a/pkg/common/cmd/root.go b/pkg/common/cmd/root.go index 6973da9d6..f220ab7c1 100644 --- a/pkg/common/cmd/root.go +++ b/pkg/common/cmd/root.go @@ -53,38 +53,76 @@ func WithLogName(logName string) func(*CmdOpts) { } } -func NewRootCmd(name string, opts ...func(*CmdOpts)) (rootCmd *RootCmd) { - rootCmd = &RootCmd{Name: name} - c := cobra.Command{ - Use: "start openIM application", +func NewRootCmd(name string, opts ...func(*CmdOpts)) *RootCmd { + rootCmd := &RootCmd{Name: name} + cmd := cobra.Command{ + Use: "Start openIM application", Short: fmt.Sprintf(`Start %s `, name), Long: fmt.Sprintf(`Start %s `, name), PersistentPreRunE: func(cmd *cobra.Command, args []string) error { - if err := rootCmd.getConfFromCmdAndInit(cmd); err != nil { - panic(err) - } - cmdOpts := &CmdOpts{} - for _, opt := range opts { - opt(cmdOpts) - } - if cmdOpts.loggerPrefixName == "" { - cmdOpts.loggerPrefixName = "OpenIM.log.all" - } - if err := log.InitFromConfig(cmdOpts.loggerPrefixName, name, config.Config.Log.RemainLogLevel, config.Config.Log.IsStdout, config.Config.Log.IsJson, config.Config.Log.StorageLocation, config.Config.Log.RemainRotationCount, config.Config.Log.RotationTime); err != nil { - panic(err) - } - return nil + return rootCmd.persistentPreRun(cmd, opts...) }, } - rootCmd.Command = c + rootCmd.Command = cmd rootCmd.addConfFlag() return rootCmd } + +func (rc *RootCmd) persistentPreRun(cmd *cobra.Command, opts ...func(*CmdOpts)) error { + if err := rc.initializeConfiguration(cmd); err != nil { + return fmt.Errorf("failed to get configuration from command: %w", err) + } + + cmdOpts := rc.applyOptions(opts...) + + if err := rc.initializeLogger(cmdOpts); err != nil { + return fmt.Errorf("failed to initialize from config: %w", err) + } + + return nil +} + +func (rc *RootCmd) initializeConfiguration(cmd *cobra.Command) error { + return rc.getConfFromCmdAndInit(cmd) +} + +func (rc *RootCmd) applyOptions(opts ...func(*CmdOpts)) *CmdOpts { + cmdOpts := defaultCmdOpts() + for _, opt := range opts { + opt(cmdOpts) + } + + return cmdOpts +} + +func (rc *RootCmd) initializeLogger(cmdOpts *CmdOpts) error { + logConfig := config.Config.Log + + return log.InitFromConfig( + + cmdOpts.loggerPrefixName, + rc.Name, + logConfig.RemainLogLevel, + logConfig.IsStdout, + logConfig.IsJson, + logConfig.StorageLocation, + logConfig.RemainRotationCount, + logConfig.RotationTime, + ) +} + +func defaultCmdOpts() *CmdOpts { + return &CmdOpts{ + loggerPrefixName: "OpenIM.log.all", + } +} + func (r *RootCmd) SetRootCmdPt(cmdItf RootCmdPt) { r.cmdItf = cmdItf } + func (r *RootCmd) addConfFlag() { - r.Command.Flags().StringP(constant.FlagConf, "c", "", "Path to config file folder") + r.Command.Flags().StringP(constant.FlagConf, "c", "", "path to config file folder") } func (r *RootCmd) AddPortFlag() { diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go index 84cddf0da..e37514ecd 100644 --- a/pkg/common/config/parse.go +++ b/pkg/common/config/parse.go @@ -19,32 +19,31 @@ import ( "fmt" "os" "path/filepath" - "runtime" + "github.com/OpenIMSDK/protocol/constant" "github.com/openimsdk/open-im-server/v3/pkg/msgprocessor" - "gopkg.in/yaml.v3" - - "github.com/OpenIMSDK/protocol/constant" ) //go:embed version var Version string -var ( - _, b, _, _ = runtime.Caller(0) - // Root folder of this project. - Root = filepath.Join(filepath.Dir(b), "../../..") -) - const ( FileName = "config.yaml" NotificationFileName = "notification.yaml" DefaultFolderPath = "../config/" ) +// getProjectRoot returns the absolute path of the project root directory +func GetProjectRoot() string { + b, _ := filepath.Abs(os.Args[0]) + + return filepath.Join(filepath.Dir(b), "../../..") +} + func GetOptionsByNotification(cfg NotificationConf) msgprocessor.Options { opts := msgprocessor.NewOptions() + if cfg.UnreadCount { opts = msgprocessor.WithOptions(opts, msgprocessor.WithUnreadCount(true)) } @@ -61,40 +60,38 @@ func GetOptionsByNotification(cfg NotificationConf) msgprocessor.Options { } func initConfig(config interface{}, configName, configFolderPath string) error { - if configFolderPath == "" { - configFolderPath = DefaultFolderPath - } - configPath := filepath.Join(configFolderPath, configName) - defer func() { - fmt.Println("use config", configPath) - }() - _, err := os.Stat(configPath) + configFolderPath = filepath.Join(configFolderPath, configName) + _, err := os.Stat(configFolderPath) if err != nil { if !os.IsNotExist(err) { - return err + return fmt.Errorf("stat config path error: %w", err) } - configPath = filepath.Join(Root, "config", configName) - } else { - Root = filepath.Dir(configPath) + configFolderPath = filepath.Join(GetProjectRoot(), "config", configName) } - data, err := os.ReadFile(configPath) + data, err := os.ReadFile(configFolderPath) if err != nil { - return err + return fmt.Errorf("read file error: %w", err) } if err = yaml.Unmarshal(data, config); err != nil { - return err + return fmt.Errorf("unmarshal yaml error: %w", err) } + fmt.Println("use config", configFolderPath) return nil } func InitConfig(configFolderPath string) error { - err := initConfig(&Config, FileName, configFolderPath) - if err != nil { - return err + if configFolderPath == "" { + envConfigPath := os.Getenv("OPENIMCONFIG") + if envConfigPath != "" { + configFolderPath = envConfigPath + } else { + configFolderPath = DefaultFolderPath + } } - err = initConfig(&Config.Notification, NotificationFileName, configFolderPath) - if err != nil { + + if err := initConfig(&Config, FileName, configFolderPath); err != nil { return err } - return nil + + return initConfig(&Config.Notification, NotificationFileName, configFolderPath) } diff --git a/pkg/common/config/version b/pkg/common/config/version index aa6c89679..e682ea429 100644 --- a/pkg/common/config/version +++ b/pkg/common/config/version @@ -1 +1 @@ -v3.2.0 \ No newline at end of file +v3.3.0 \ No newline at end of file diff --git a/scripts/check-all.sh b/scripts/check-all.sh index f1d72c41c..0d849dd50 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -64,9 +64,9 @@ set +e # Later, after discarding Docker, the Docker keyword is unreliable, and Kubepods is used if grep -qE 'docker|kubepods' /proc/1/cgroup || [ -f /.dockerenv ]; then - openim::color::echo ${COLOR_BLUE} "Environment in the interior of the container" + openim::color::echo ${COLOR_CYAN} "Environment in the interior of the container" else - openim::color::echo ${COLOR_BLUE} "The environment is outside the container" + openim::color::echo ${COLOR_CYAN} "The environment is outside the container" openim::util::check_ports ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]} || return 0 fi diff --git a/scripts/demo.sh b/scripts/demo.sh index 329e04f0f..5f8a2023a 100755 --- a/scripts/demo.sh +++ b/scripts/demo.sh @@ -37,6 +37,8 @@ readonly ipv6regex='(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}: clear . $(dirname ${BASH_SOURCE})/lib/util.sh +openim::util::ensure-bash-version + trap 'openim::util::onCtrlC' INT function openim::util::onCtrlC() { diff --git a/scripts/docker-check-service.sh b/scripts/docker-check-service.sh index c1fb94748..adf383436 100755 --- a/scripts/docker-check-service.sh +++ b/scripts/docker-check-service.sh @@ -19,11 +19,7 @@ source "${OPENIM_ROOT}/scripts/install/common.sh" cd "$OPENIM_ROOT" -if command -v docker-compose &> /dev/null; then - docker-compose ps -else - docker compose ps -fi +openim::util::check_docker_and_compose_versions progress() { local _main_pid="$1" diff --git a/scripts/install-im-server.sh b/scripts/install-im-server.sh index 76d5120fe..26ab35b0d 100755 --- a/scripts/install-im-server.sh +++ b/scripts/install-im-server.sh @@ -30,6 +30,8 @@ openim::util::ensure_docker_daemon_connectivity DOCKER_COMPOSE_COMMAND= # Check if docker-compose command is available +openim::util::check_docker_and_compose_versions + if command -v docker compose &> /dev/null then openim::log::info "docker compose command is available" diff --git a/scripts/install_im_compose.sh b/scripts/install_im_compose.sh index 1f7dd7f52..06a573424 100755 --- a/scripts/install_im_compose.sh +++ b/scripts/install_im_compose.sh @@ -51,17 +51,7 @@ execute_scripts() { "${OPENIM_ROOT}"/scripts/env_check.sh } -# Start docker compose -start_docker_compose() { - openim::log::info "Checking if docker-compose command is available" - if command -v docker-compose &> /dev/null; then - docker-compose up -d - else - docker compose up -d - fi - - "${OPENIM_ROOT}"/scripts/docker-check-service.sh -} +openim::util::check_docker_and_compose_versions main() { load_env diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 0ad386e1a..d7c274c56 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -250,6 +250,39 @@ openim::util::host_arch() { echo "${host_arch}" } +# Define a bash function to check the versions of Docker and Docker Compose +openim::util::check_docker_and_compose_versions() { + # Define the required versions of Docker and Docker Compose + required_docker_version="20.10.0" + required_compose_version="2.0" + + # Get the currently installed Docker version + installed_docker_version=$(docker --version | awk '{print $3}' | sed 's/,//') + + # Check if the installed Docker version matches the required version + if [[ "$installed_docker_version" < "$required_docker_version" ]]; then + echo "Docker version mismatch. Installed: $installed_docker_version, Required: $required_docker_version" + return 1 + fi + + # Check if the docker compose sub-command is available + if ! docker compose version &> /dev/null; then + echo "Docker does not support the docker compose sub-command" + return 1 + fi + + # Get the currently installed Docker Compose version + installed_compose_version=$(docker compose version --short) + + # Check if the installed Docker Compose version matches the required version + if [[ "$installed_compose_version" < "$required_compose_version" ]]; then + echo "Docker Compose version mismatch. Installed: $installed_compose_version, Required: $required_compose_version" + return 1 + fi + +} + + # The `openim::util::check_ports` function analyzes the state of processes based on given ports. # It accepts multiple ports as arguments and prints: # 1. The state of the process (whether it's running or not). @@ -1321,3 +1354,7 @@ function openim::util::gen_os_arch() { exit 1 fi } + +if [[ "$*" =~ openim::util:: ]];then + eval $* +fi \ No newline at end of file diff --git a/scripts/make-rules/common.mk b/scripts/make-rules/common.mk index f72d22f73..99ceea7e0 100644 --- a/scripts/make-rules/common.mk +++ b/scripts/make-rules/common.mk @@ -167,6 +167,7 @@ define MAKEFILE_EXAMPLE # make install-deepcopy-gen Install deepcopy-gen tools if the license is missing. # make build BINS=openim-api V=1 DEBUG=1 Build debug binaries for only openim-api. # make multiarch -j PLATFORMS="linux_arm64 linux_amd64" V=1 Build binaries for both platforms. +# make image endef export MAKEFILE_EXAMPLE diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk index 742016cbd..cc2c98544 100644 --- a/scripts/make-rules/golang.mk +++ b/scripts/make-rules/golang.mk @@ -17,7 +17,7 @@ # GO := go -GO_SUPPORTED_VERSIONS ?= 1.18|1.19|1.20|1.21|1.22 +GO_SUPPORTED_VERSIONS ?= 1.19|1.20|1.21|1.22 GO_LDFLAGS += -X $(VERSION_PACKAGE).gitVersion=$(GIT_TAG) \ -X $(VERSION_PACKAGE).gitCommit=$(GIT_COMMIT) \ @@ -45,7 +45,7 @@ ifeq ($(origin GOBIN), undefined) endif # COMMANDS is Specify all files under ${ROOT_DIR}/cmd/ and ${ROOT_DIR}/tools/ except those ending in.md -COMMANDS ?= $(filter-out %.md, $(wildcard ${ROOT_DIR}/cmd/* ${ROOT_DIR}/tools/* ${ROOT_DIR}/cmd/openim-rpc/*)) +COMMANDS ?= $(filter-out %.md, $(wildcard ${ROOT_DIR}/cmd/* ${ROOT_DIR}/tools/* ${ROOT_DIR}/tools/data-conversion/chat/cmd/* ${ROOT_DIR}/tools/data-conversion/openim/cmd/* ${ROOT_DIR}/cmd/openim-rpc/*)) ifeq (${COMMANDS},) $(error Could not determine COMMANDS, set ROOT_DIR or run in source dir) endif @@ -136,6 +136,7 @@ ifneq ($(shell $(GO) version | grep -q -E '\bgo($(GO_SUPPORTED_VERSIONS))\b' && $(error unsupported go version. Please make install one of the following supported version: '$(GO_SUPPORTED_VERSIONS)') endif +## go.build.%: Build binaries for a specific platform .PHONY: go.build.% go.build.%: $(eval COMMAND := $(word 2,$(subst ., ,$*))) @@ -159,6 +160,14 @@ go.build.%: CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \ $(BIN_TOOLS_DIR)/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) $(ROOT_DIR)/tools/$(COMMAND)/$(COMMAND).go; \ chmod +x $(BIN_TOOLS_DIR)/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT); \ + elif [ -f $(ROOT_DIR)/tools/data-conversion/openim/cmd/$(COMMAND)/$(COMMAND).go ]; then \ + CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \ + $(BIN_TOOLS_DIR)/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) $(ROOT_DIR)/tools/data-conversion/openim/cmd/$(COMMAND)/$(COMMAND).go; \ + chmod +x $(BIN_TOOLS_DIR)/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT); \ + elif [ -f $(ROOT_DIR)/tools/data-conversion/chat/cmd/$(COMMAND)/$(COMMAND).go ]; then \ + CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \ + $(BIN_TOOLS_DIR)/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) $(ROOT_DIR)/tools/data-conversion/chat/cmd/$(COMMAND)/$(COMMAND).go; \ + chmod +x $(BIN_TOOLS_DIR)/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT); \ fi \ fi diff --git a/scripts/make-rules/image.mk b/scripts/make-rules/image.mk index eea651d88..09e92126b 100644 --- a/scripts/make-rules/image.mk +++ b/scripts/make-rules/image.mk @@ -21,7 +21,6 @@ # DOCKER := docker -DOCKER_SUPPORTED_API_VERSION ?= 1.32|1.40|1.41|1.42 # read: https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/images.md REGISTRY_PREFIX ?= ghcr.io/openimsdk @@ -43,8 +42,8 @@ endif # Determine image files by looking into build/images/*/Dockerfile IMAGES_DIR ?= $(wildcard ${ROOT_DIR}/build/images/*) -# Determine images names by stripping out the dir names -IMAGES ?= $(filter-out tools,$(foreach image,${IMAGES_DIR},$(notdir ${image}))) +# Determine images names by stripping out the dir names, and filter out the undesired directories +IMAGES ?= $(filter-out Dockerfile openim-tools openim-cmdutils,$(foreach image,${IMAGES_DIR},$(notdir ${image}))) ifeq (${IMAGES},) $(error Could not determine IMAGES, set ROOT_DIR or run in source dir) @@ -75,22 +74,13 @@ image.docker-buildx: ## image.verify: Verify docker version .PHONY: image.verify image.verify: - $(eval API_VERSION := $(shell $(DOCKER) version | grep -E 'API version: {1,6}[0-9]' | head -n1 | awk '{print $$3} END { if (NR==0) print 0}' )) - $(eval PASS := $(shell echo "$(API_VERSION) > $(DOCKER_SUPPORTED_API_VERSION)" | bc)) - @if [ $(PASS) -ne 1 ]; then \ - $(DOCKER) -v ;\ - echo "Unsupported docker version. Docker API version should be greater than $(DOCKER_SUPPORTED_API_VERSION)"; \ - exit 1; \ - fi + @$(ROOT_DIR)/scripts/lib/util.sh openim::util::check_docker_and_compose_versions ## image.daemon.verify: Verify docker daemon experimental features .PHONY: image.daemon.verify image.daemon.verify: - $(eval PASS := $(shell $(DOCKER) version | grep -q -E 'Experimental: {1,5}true' && echo 1 || echo 0)) - @if [ $(PASS) -ne 1 ]; then \ - echo "Experimental features of Docker daemon is not enabled. Please add \"experimental\": true in '/etc/docker/daemon.json' and then restart Docker daemon."; \ - exit 1; \ - fi + @$(ROOT_DIR)/scripts/lib/util.sh openim::util::ensure_docker_daemon_connectivity + @$(ROOT_DIR)/scripts/lib/util.sh openim::util::ensure-docker-buildx # If you wish built the manager image targeting other platforms you can use the --platform flag. # (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. @@ -110,10 +100,9 @@ image.build.%: go.build.% $(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM)))) @echo "===========> Building docker image $(IMAGE) $(VERSION) for $(IMAGE_PLAT)" @mkdir -p $(TMP_DIR)/$(IMAGE)/$(PLATFORM) - @awk '/FROM/ {c++; if (c==2) {print; next}} c>=2' $(ROOT_DIR)/build/images/$(IMAGE)/Dockerfile \ -| sed -e "s#BASE_IMAGE#$(BASE_IMAGE)#g" \ - -e 's/--from=builder //g' \ - -e 's#COPY /openim/openim-server/#COPY ./#g' > $(TMP_DIR)/$(IMAGE)/Dockerfile + @cat $(ROOT_DIR)/build/images/Dockerfile\ + | sed "s#BASE_IMAGE#$(BASE_IMAGE)#g" \ + | sed "s#BINARY_NAME#$(IMAGE)#g" >$(TMP_DIR)/$(IMAGE)/Dockerfile @cp $(BIN_DIR)/platforms/$(IMAGE_PLAT)/$(IMAGE) $(TMP_DIR)/$(IMAGE) $(eval BUILD_SUFFIX := $(_DOCKER_BUILD_EXTRA_ARGS) --pull -t $(REGISTRY_PREFIX)/$(IMAGE)-$(ARCH):$(VERSION) $(TMP_DIR)/$(IMAGE)) @if [ $(shell $(GO) env GOARCH) != $(ARCH) ] ; then \ @@ -124,7 +113,6 @@ image.build.%: go.build.% fi @rm -rf $(TMP_DIR)/$(IMAGE) - # https://docs.docker.com/build/building/multi-platform/ # busybox image supports amd64, arm32v5, arm32v6, arm32v7, arm64v8, i386, ppc64le, and s390x ## image.buildx.%: Build docker images with buildx diff --git a/test/typecheck/go.mod b/test/typecheck/go.mod index f644c5b25..9ef1b1da7 100644 --- a/test/typecheck/go.mod +++ b/test/typecheck/go.mod @@ -1,6 +1,6 @@ module github.com/openimsdk/open-im-server/test/typecheck -go 1.18 +go 1.19 require golang.org/x/tools v0.12.0 diff --git a/tests/group_test.go b/tests/group_test.go deleted file mode 100644 index 54878805e..000000000 --- a/tests/group_test.go +++ /dev/null @@ -1,22 +0,0 @@ -package tests - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/openimsdk/open-im-server/v3/pkg/common/db/controller" -) - -func TestDeleteGroupMemberHash(t *testing.T) { - mockGroupDB := new(controller.MockGroupDatabase) - - testGroupMemberHash := "testGroupMemberHash" - - err := mockGroupDB.DeleteGroupMemberHash(testGroupMemberHash) - assert.Nil(t, err) - - nonExistentGroupMemberHash := "nonExistentGroupMemberHash" - - err = mockGroupDB.DeleteGroupMemberHash(nonExistentGroupMemberHash) - assert.NotNil(t, err) -} diff --git a/tests/user_test.go b/tests/user_test.go deleted file mode 100644 index 5278f27f1..000000000 --- a/tests/user_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package cache_test - -import ( - "reflect" - "testing" - - "github.com/openimsdk/open-im-server/v3/pkg/common/db/cache" -) - -func TestRemoveRepeatedElementsInList(t *testing.T) { - testCases := []struct { - name string - input []string - expected []string - }{ - { - name: "No duplicates", - input: []string{"a", "b", "c"}, - expected: []string{"a", "b", "c"}, - }, - { - name: "All duplicates", - input: []string{"a", "a", "a"}, - expected: []string{"a"}, - }, - { - name: "Some duplicates", - input: []string{"a", "b", "a", "c", "b"}, - expected: []string{"a", "b", "c"}, - }, - { - name: "Empty list", - input: []string{}, - expected: []string{}, - }, - { - name: "Single element", - input: []string{"a"}, - expected: []string{"a"}, - }, - } - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - result := cache.RemoveRepeatedElementsInList(tc.input) - if !reflect.DeepEqual(result, tc.expected) { - t.Errorf("expected %v, got %v", tc.expected, result) - } - }) - } -} diff --git a/tools/changelog/go.mod b/tools/changelog/go.mod index 924f6709a..b5a2272a4 100644 --- a/tools/changelog/go.mod +++ b/tools/changelog/go.mod @@ -1,3 +1,3 @@ module github.com/openimsdk/open-im-server/v3/tools/changelog -go 1.18 +go 1.19 diff --git a/tools/component/go.mod b/tools/component/go.mod index 8d5548ee8..05a27bcad 100644 --- a/tools/component/go.mod +++ b/tools/component/go.mod @@ -1,3 +1,3 @@ module github.com/openimsdk/open-im-server/v3/tools/component -go 1.18 +go 1.19 diff --git a/tools/data-conversion/README.md b/tools/data-conversion/README.md new file mode 100644 index 000000000..282fbdc03 --- /dev/null +++ b/tools/data-conversion/README.md @@ -0,0 +1,103 @@ + +在更新你的数据迁移README文档时,考虑到清晰、准确和专业的表述是非常重要的。这不仅可以帮助读者更好地理解迁移过程,还可以确保在迁移过程中减少可能出现的错误。以下是对你提供的README文档的一些改进和完善建议: + +------ + +# OpenIM V2 至 V3 数据迁移指南 + +该指南提供了从 OpenIM V2 迁移至 V3 的详细步骤。请确保在开始迁移过程之前,熟悉所有步骤,并按照指南准确执行。 + ++ [OpenIM Chat](https://github.com/OpenIMSDK/chat) ++ [OpenIM Server](https://github.com/OpenIMSDK/Open-IM-Server) + + + +### 1. 数据备份 + +在开始数据迁移之前,强烈建议备份所有相关的数据以防止任何可能的数据丢失。 + +### 2. 迁移 OpenIM MySQL 数据 + ++ 位置: `open-im-server/v3/tools/data-conversion/openim/mysql.go` ++ 配置 `mysql.go` 文件中的数据库信息。 ++ 手动创建 V3 版本的数据库,并确保字符集为 `utf8mb4`。 + +```bash +// V2 数据库配置 +var ( + usernameV2 = "root" + passwordV2 = "openIM" + addrV2 = "127.0.0.1:13306" + databaseV2 = "openIM_v2" +) + +// V3 数据库配置 +var ( + usernameV3 = "root" + passwordV3 = "openIM123" + addrV3 = "127.0.0.1:13306" + databaseV3 = "openIM_v3" +) +``` + +**执行数据迁移命令:** + +```bash +make build BINS="conversion-mysql" +``` + +启动的二进制在 `_output/bin/tools` 中 + + +### 3. 转换聊天消息(可选) + ++ 只支持转换存储在 Kafka 中的消息。 ++ 位置: `open-im-server/v3/tools/data-conversion/openim/msg.go` ++ 配置 `msg.go` 文件中的消息和服务器信息。 + +```bash +var ( + topic = "ws2ms_chat" // V2 版本 Kafka 主题 + kafkaAddr = "127.0.0.1:9092" // V2 版本 Kafka 地址 + rpcAddr = "127.0.0.1:10130" // V3 版本 RPC 地址 + adminUserID = "openIM123456" // V3 版本管理员用户ID + concurrency = 4 // 并发数量 +) +``` + +**执行数据迁移命令:** + +```bash +make build BINS="conversion-msg" +``` + +### 4. 转换业务服务器数据 + ++ 只支持转换存储在 Kafka 中的消息。 ++ 位置: `open-im-server/v3/tools/data-conversion/chat/chat.go` ++ 需要手动创建 V3 版本的数据库,并确保字符集为 `utf8mb4`。 ++ 配置 `main.go` 文件中的数据库信息。 + +```bash +// V2 数据库配置 +var ( + usernameV2 = "root" + passwordV2 = "openIM" + addrV2 = "127.0.0.1:13306" + databaseV2 = "admin_chat" +) + +// V3 数据库配置 +var ( + usernameV3 = "root" + passwordV3 = "openIM123" + addrV3 = "127.0.0.1:13306" + databaseV3 = "openim_enterprise" +) +``` + +**执行数据迁移命令:** + +```bash +make build BINS="conversion-chat" +``` \ No newline at end of file diff --git a/tools/data-conversion/chat/chat.go b/tools/data-conversion/chat/cmd/conversion-chat/chat.go similarity index 100% rename from tools/data-conversion/chat/chat.go rename to tools/data-conversion/chat/cmd/conversion-chat/chat.go diff --git a/tools/data-conversion/go.mod b/tools/data-conversion/go.mod index 51cc32f2e..b0d7aea13 100644 --- a/tools/data-conversion/go.mod +++ b/tools/data-conversion/go.mod @@ -1,6 +1,6 @@ module github.com/openimsdk/open-im-server/v3/tools/data-conversion -go 1.18 +go 1.19 require ( github.com/IBM/sarama v1.41.2 diff --git a/tools/data-conversion/info.md b/tools/data-conversion/info.md deleted file mode 100644 index 600b1d09c..000000000 --- a/tools/data-conversion/info.md +++ /dev/null @@ -1,68 +0,0 @@ -# v2数据迁移工具 - -### 转换前请做好数据备份!!! - -### 转换OPENIM MYSQL数据 - - open-im-server/v3/tools/data-conversion/openim/mysql.go - - 配置mysql.go数据库信息 - - 需要手动创建v3版本数据库,字符集`utf8mb4` - -```go -var ( - usernameV2 = "root" // v2版本mysql用户名 - passwordV2 = "openIM" // v2版本mysql密码 - addrV2 = "127.0.0.1:13306" // v2版本mysql地址 - databaseV2 = "openIM_v2" // v2版本mysql数据库名字 -) - -var ( - usernameV3 = "root" // v3版本mysql用户名 - passwordV3 = "openIM123" // v3版本mysql密码 - addrV3 = "127.0.0.1:13306" // v3版本mysql地址 - databaseV3 = "openIM_v3" // v3版本mysql数据库名字 -) -``` -```shell -go run mysql.go -``` - -### 转换聊天消息(可选) -- 目前只支持转换kafka中的消息 -- open-im-server/v3/tools/data-conversion/openim/msg.go -- 配置msg.go数据库信息 -```go -var ( - topic = "ws2ms_chat" // v2版本配置文件kafka.topic.ws2ms_chat - kafkaAddr = "127.0.0.1:9092" // v2版本配置文件kafka.topic.addr - rpcAddr = "127.0.0.1:10130" // v3版本配置文件rpcPort.openImMessagePort - adminUserID = "openIM123456" // v3版本管理员userID - concurrency = 4 // 并发数量 -) -``` -```shell -go run msg.go -``` - -### 转换业务服务器数据(使用官方业务服务器需要转换) -- 目前只支持转换kafka中的消息 -- open-im-server/v3/tools/data-conversion/chat/chat.go -- 需要手动创建v3版本数据库,字符集`utf8mb4` -- main.go数据库信息 -```go -var ( - usernameV2 = "root" // v2版本mysql用户名 - passwordV2 = "openIM" // v2版本mysql密码 - addrV2 = "127.0.0.1:13306" // v2版本mysql地址 - databaseV2 = "admin_chat" // v2版本mysql数据库名字 -) - -var ( - usernameV3 = "root" // v3版本mysql用户名 - passwordV3 = "openIM123" // v3版本mysql密码 - addrV3 = "127.0.0.1:13306" // v3版本mysql地址 - databaseV3 = "openim_enterprise" // v3版本mysql数据库名字 -) -``` -```shell -go run chat.go -``` \ No newline at end of file diff --git a/tools/data-conversion/openim/msg.go b/tools/data-conversion/openim/cmd/conversion-msg/conversion-msg.go similarity index 100% rename from tools/data-conversion/openim/msg.go rename to tools/data-conversion/openim/cmd/conversion-msg/conversion-msg.go diff --git a/tools/data-conversion/openim/mysql.go b/tools/data-conversion/openim/cmd/conversion-mysql/conversion-mysql.go similarity index 100% rename from tools/data-conversion/openim/mysql.go rename to tools/data-conversion/openim/cmd/conversion-mysql/conversion-mysql.go diff --git a/tools/imctl/go.mod b/tools/imctl/go.mod index 60b06b45b..e3a720b27 100644 --- a/tools/imctl/go.mod +++ b/tools/imctl/go.mod @@ -1,6 +1,6 @@ module github.com/openimsdk/open-im-server/v3/tools/imctl -go 1.18 +go 1.19 require ( github.com/MakeNowJust/heredoc/v2 v2.0.1 diff --git a/tools/infra/go.mod b/tools/infra/go.mod index 6ee10304b..a6cf16c77 100644 --- a/tools/infra/go.mod +++ b/tools/infra/go.mod @@ -1,3 +1,3 @@ module github.com/openimsdk/open-im-server/v3/tools/infra -go 1.18 +go 1.19 diff --git a/tools/ncpu/go.mod b/tools/ncpu/go.mod index dfccea27a..66697e350 100644 --- a/tools/ncpu/go.mod +++ b/tools/ncpu/go.mod @@ -1,5 +1,5 @@ module github.com/openimsdk/open-im-server/v3/tools/ncpu -go 1.18 +go 1.19 require go.uber.org/automaxprocs v1.5.3 diff --git a/tools/openim-web/go.mod b/tools/openim-web/go.mod index 6f30c673c..deb24f4e5 100644 --- a/tools/openim-web/go.mod +++ b/tools/openim-web/go.mod @@ -1,6 +1,6 @@ module github.com/openimsdk/open-im-server/v3/tools/openim-web -go 1.18 +go 1.19 require gopkg.in/yaml.v2 v2.4.0 diff --git a/tools/versionchecker/go.mod b/tools/versionchecker/go.mod index 5858649e8..619bcdb5b 100644 --- a/tools/versionchecker/go.mod +++ b/tools/versionchecker/go.mod @@ -1,3 +1,3 @@ module github.com/openimsdk/open-im-server/v3/tools/versionchecker -go 1.18 +go 1.19 diff --git a/tools/yamlfmt/go.mod b/tools/yamlfmt/go.mod index 5b3581efc..7c496a530 100644 --- a/tools/yamlfmt/go.mod +++ b/tools/yamlfmt/go.mod @@ -1,6 +1,6 @@ module github.com/openimsdk/open-im-server/v3/tools/yamlfmt -go 1.18 +go 1.19 require ( github.com/likexian/gokit v0.25.13