From a8f5034012a23c1d692667d8a8e8e9a8287ecd02 Mon Sep 17 00:00:00 2001 From: Xinwei Xiong <3293172751NSS@gmail.com> Date: Fri, 4 Aug 2023 19:13:22 +0800 Subject: [PATCH] fix: part of the make rules optimization (#751) * fix: part of the make rules optimization Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: set github hub Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: set github hub Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: scripts path Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: scripts path Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: scripts path Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: dockerfile path Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: gorelease quest Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add openim deployment build sub image Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: docker images optimize Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: dockerfile fix Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * style: fix cicd actions openimci Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * style: fix cicd actions openimci Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add sub images actions build Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: set branch Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: set branch Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * refactor: remove makefile Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: docker release v3.1.1 images optimize Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: add scripts path set Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: fix env config Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts bash path Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: docker release v3.1.1 images optimize Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: super docker version Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> --------- Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> --- .github/dependabot.yml | 34 ++ .github/workflows/auto-gh-pr.yml | 28 +- .github/workflows/auto-tag.yml | 38 +++ .github/workflows/build-docker-image.yml | 51 ++- .github/workflows/docker-buildx.yml | 320 ++++++++++++++++++ .github/workflows/image.yml | 95 ------ .github/workflows/milestone.yml | 58 ++++ .github/workflows/openimci.yml | 8 - .github/workflows/project-progress.yml | 2 +- .golangci.yml | 2 +- .goreleaser.yaml | 22 +- Dockerfile | 28 +- build/docker/openim-api/Dockerfile | 36 +- build/docker/openim-cmdutils/Dockerfile | 31 ++ build/docker/openim-crontask/Dockerfile | 30 ++ build/docker/openim-msggateway/Dockerfile | 36 ++ build/docker/openim-msgtransfer/Dockerfile | 33 ++ build/docker/openim-push/Dockerfile | 35 ++ build/docker/openim-rpc-auth/Dockerfile | 38 +++ .../docker/openim-rpc-conversation/Dockerfile | 45 +++ build/docker/openim-rpc-friend/Dockerfile | 45 +++ build/docker/openim-rpc-group/Dockerfile | 45 +++ build/docker/openim-rpc-msg/Dockerfile | 45 +++ build/docker/openim-rpc-third/Dockerfile | 44 +++ build/docker/openim-rpc-user/Dockerfile | 44 +++ cmd/openim-api/Makefile | 34 -- cmd/openim-api/deploy.Dockerfile | 4 +- cmd/openim-cmdutils/Makefile | 34 -- cmd/openim-crontask/Makefile | 34 -- cmd/openim-crontask/deploy.Dockerfile | 4 +- cmd/openim-msggateway/Makefile | 34 -- cmd/openim-msggateway/deploy.Dockerfile | 4 +- cmd/openim-msgtransfer/Makefile | 34 -- cmd/openim-msgtransfer/deploy.Dockerfile | 4 +- cmd/openim-push/Makefile | 34 -- cmd/openim-push/deploy.Dockerfile | 4 +- cmd/openim-rpc/openim-rpc-auth/Makefile | 34 -- .../openim-rpc-auth/deploy.Dockerfile | 4 +- .../openim-rpc-conversation/Makefile | 34 -- .../openim-rpc-conversation/deploy.Dockerfile | 4 +- cmd/openim-rpc/openim-rpc-friend/Makefile | 34 -- .../openim-rpc-friend/deploy.Dockerfile | 4 +- cmd/openim-rpc/openim-rpc-group/Makefile | 34 -- .../openim-rpc-group/deploy.Dockerfile | 4 +- cmd/openim-rpc/openim-rpc-msg/Makefile | 34 -- .../openim-rpc-msg/deploy.Dockerfile | 4 +- cmd/openim-rpc/openim-rpc-third/Makefile | 34 -- .../openim-rpc-third/deploy.Dockerfile | 4 +- cmd/openim-rpc/openim-rpc-user/Makefile | 34 -- .../openim-rpc-user/deploy.Dockerfile | 4 +- docker-compose.yaml | 20 +- init_docker.sh | 44 --- install.sh | 10 +- install_guide.sh | 2 +- pkg/common/config/version | 2 +- scripts/advertise.sh | 2 +- scripts/build.cmd | 23 +- scripts/common.sh | 2 - scripts/docker_start_all.sh | 13 +- scripts/enterprise/function.sh | 12 +- scripts/enterprise/path_info.cfg | 20 +- scripts/init_pwd.sh | 2 +- scripts/lib/golang.sh | 1 - scripts/make-rules/golang.mk | 2 +- scripts/msg_transfer_start.sh | 8 +- scripts/push_start.sh | 8 +- scripts/start_all.sh | 8 +- scripts/start_cron.sh | 8 +- scripts/start_rpc_service.sh | 3 +- scripts/stop_all.sh | 2 +- scripts/style_info.sh | 83 ++--- test/common.sh | 1 - 72 files changed, 1167 insertions(+), 792 deletions(-) create mode 100644 .github/workflows/auto-tag.yml create mode 100644 .github/workflows/docker-buildx.yml delete mode 100644 .github/workflows/image.yml create mode 100644 .github/workflows/milestone.yml delete mode 100644 cmd/openim-api/Makefile delete mode 100644 cmd/openim-cmdutils/Makefile delete mode 100644 cmd/openim-crontask/Makefile delete mode 100644 cmd/openim-msggateway/Makefile delete mode 100644 cmd/openim-msgtransfer/Makefile delete mode 100644 cmd/openim-push/Makefile delete mode 100644 cmd/openim-rpc/openim-rpc-auth/Makefile delete mode 100644 cmd/openim-rpc/openim-rpc-conversation/Makefile delete mode 100644 cmd/openim-rpc/openim-rpc-friend/Makefile delete mode 100644 cmd/openim-rpc/openim-rpc-group/Makefile delete mode 100644 cmd/openim-rpc/openim-rpc-msg/Makefile delete mode 100644 cmd/openim-rpc/openim-rpc-third/Makefile delete mode 100644 cmd/openim-rpc/openim-rpc-user/Makefile delete mode 100755 init_docker.sh diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f6150ead7..f495b588f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,3 +9,37 @@ updates: directory: "/" schedule: interval: "daily" + time: "08:00" + labels: + - "dependencies" + commit-message: + prefix: "feat" + include: "scope" + groups: + gomod-deps: + patterns: + - "*" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + time: "08:00" + labels: + - "dependencies" + commit-message: + prefix: "chore" + include: "scope" + groups: + github-actions: + patterns: + - "*" + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "daily" + time: "08:00" + labels: + - "dependencies" + commit-message: + prefix: "feat" + include: "scope" \ No newline at end of file diff --git a/.github/workflows/auto-gh-pr.yml b/.github/workflows/auto-gh-pr.yml index 1d8c90d33..0913655ca 100644 --- a/.github/workflows/auto-gh-pr.yml +++ b/.github/workflows/auto-gh-pr.yml @@ -18,30 +18,21 @@ on: pull_request: # types: # - closed + issue_comment: + types: [created] + pull_request_review_comment: + types: [created] jobs: create-pr: runs-on: ubuntu-latest - if: github.event.pull_request.base.ref == 'main' + if: github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true steps: - name: Check out code uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Setup GitHub CLI - run: | - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0 - sudo apt-add-repository https://cli.github.com/packages - sudo apt-get update - sudo apt-get install gh - continue-on-error: true - - # - name: Configure GitHub CLI - # run: | - # git config --global user.email "3293172751ysy@gmail.com" - # git config --global user.name "kubbot" - # echo "${{ secrets.BOT_GITHUB_TOKEN }}" | gh auth login --with-token - name: Create PR to release branch run: | ISSUEID=$(gh pr view ${{ github.event.pull_request.number }} --repo $OWNER/$REPO | grep -oP 'Fixes #\K\d+') @@ -56,10 +47,9 @@ jobs: gh pr edit ${{ github.event.pull_request.number }} --repo $OWNER/$REPO --add-label "$LABELS" --add-assignee "$ASSIGNEES" --milestone "$MILESTONE" - git checkout -b bot/merge-to-release-$ISSUEID - git push origin bot/merge-to-release-$ISSUEID - gh pr create --base release --head bot/merge-to-release-$ISSUEID --title "Merge main to release" --body "" - + # git checkout -b bot/merge-to-release-$ISSUEID + # git push origin bot/merge-to-release-$ISSUEID + # gh pr create --base release --head bot/merge-to-release-$ISSUEID --title "Merge main to release" --body "" # gh pr create --base main --head feat/auto-release-pr-624 --title "The bug is fixed" --body "$x" --repo OpenIMSDK/Open-IM-Server --reviewer "cubxxw" continue-on-error: true env: @@ -67,4 +57,4 @@ jobs: GH_TOKEN: ${{ github.token }} ISSUE: ${{ github.event.issue.html_url }} OWNER: ${{ github.repository_owner }} - REPO: ${{ github.event.repository.name }} \ No newline at end of file + REPO: ${{ github.event.repository.name }} diff --git a/.github/workflows/auto-tag.yml b/.github/workflows/auto-tag.yml new file mode 100644 index 000000000..7e72e898d --- /dev/null +++ b/.github/workflows/auto-tag.yml @@ -0,0 +1,38 @@ +name: Create Tag + +on: + issue_comment: + types: [created] + pull_request_review_comment: + types: [created] + +jobs: + create_tag: + runs-on: ubuntu-latest + if: startsWith(github.event.comment.body, '/create tag') + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Validate version number and get comment + id: validate + run: | + COMMENT="${{ github.event.comment.body }}" + VERSION=$(echo $COMMENT | cut -d ' ' -f 3) + TAG_COMMENT=$(echo $COMMENT | cut -d '"' -f 2) + if [[ $VERSION =~ ^v([0-9]+\.){2}[0-9]+$ ]]; then + echo "version=$VERSION" >> $GITHUB_STATE + echo "tag_comment=$TAG_COMMENT" >> $GITHUB_STATE + else + echo "Invalid version number." + exit 1 + fi + + - name: Create a new tag + env: + GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} + run: | + source $GITHUB_STATE + git tag -a $VERSION -m "$tag_comment" + git push origin $VERSION + echo "tag_created=$VERSION" >> $GITHUB_OUTPUT diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 3dd64c930..f9fb42500 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -23,16 +23,20 @@ on: - v* workflow_dispatch: +env: + # Common versions + GO_VERSION: "1.20" + jobs: - build: + build-dockerhub: runs-on: ubuntu-latest steps: - - name: Check out the repo + - name: Checkout uses: actions/checkout@v3 - - - name: Build OpenIM Server - run: | - sudo make build + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 # docker.io/openim/openim-server:latest - name: Extract metadata (tags, labels) for Docker @@ -40,6 +44,15 @@ jobs: uses: docker/metadata-action@v4.6.0 with: images: openim/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 Docker Hub uses: docker/login-action@v2 @@ -51,10 +64,21 @@ jobs: uses: docker/build-push-action@v4 with: context: . + # linux/ppc64le,linux/s390x + platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-aliyun: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 # registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server:latest - name: Extract metadata (tags, labels) for Docker id: meta2 @@ -73,10 +97,21 @@ jobs: uses: docker/build-push-action@v4 with: context: . + # linux/ppc64le,linux/s390x + platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta2.outputs.tags }} labels: ${{ steps.meta2.outputs.labels }} + build-ghcr: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 # ghcr.io/openimsdk/openim-server:latest - name: Extract metadata (tags, labels) for Docker id: meta3 @@ -88,13 +123,15 @@ jobs: uses: docker/login-action@v2 with: registry: ghcr.io - username: ${{ github.actor }} + username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker image uses: docker/build-push-action@v4 with: context: . + # linux/ppc64le,linux/s390x + platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta3.outputs.tags }} labels: ${{ steps.meta3.outputs.labels }} diff --git a/.github/workflows/docker-buildx.yml b/.github/workflows/docker-buildx.yml new file mode 100644 index 000000000..3d1b3015f --- /dev/null +++ b/.github/workflows/docker-buildx.yml @@ -0,0 +1,320 @@ +# Copyright © 2023 OpenIM open source community. 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. + +name: Docker Buildx Images CI + +on: + schedule: + - cron: '30 1 * * *' + push: + branches: + - release-* + tags: + - v* + workflow_dispatch: + +jobs: + build-ghcr: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + 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- + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + +################################################ +# build/ +# └── docker +# ├── openim-api +# │ └── Dockerfile +# ├── openim-cmdutils +# │ └── Dockerfile +# ├── openim-crontask +# │ └── Dockerfile +# ├── openim-msggateway +# │ └── Dockerfile +# ├── openim-msgtransfer +# │ └── Dockerfile +# ├── openim-push +# │ └── Dockerfile +# ├── openim-rpc-auth +# │ └── Dockerfile +# ├── openim-rpc-conversation +# │ └── Dockerfile +# ├── openim-rpc-friend +# │ └── Dockerfile +# ├── openim-rpc-group +# │ └── Dockerfile +# ├── openim-rpc-msg +# │ └── Dockerfile +# ├── openim-rpc-third +# │ └── Dockerfile +# └── openim-rpc-user +# └── Dockerfile +############################################# + + - name: Extract metadata (tags, labels) for Docker openim-api + id: meta1 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/openim-api + + - name: Build and push Docker image for openim-api + uses: docker/build-push-action@v4 + with: + context: . + file: ./build/docker/openim-api/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-cmdutils + id: meta2 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/openim-cmdutils + + - name: Build and push Docker image for openim-cmdutils + uses: docker/build-push-action@v4 + with: + context: . + file: ./build/docker/openim-cmdutils/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 + + - name: Extract metadata (tags, labels) for Docker openim-crontask + id: meta3 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/openim-crontask + + - name: Build and push Docker image for openim-crontask + uses: docker/build-push-action@v4 + with: + context: . + file: ./build/docker/openim-crontask/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta3.outputs.tags }} + labels: ${{ steps.meta3.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-msggateway + id: meta4 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/openim-msggateway + + - name: Build and push Docker image for openim-msggateway + uses: docker/build-push-action@v4 + with: + context: . + file: ./build/docker/openim-msggateway/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta4.outputs.tags }} + labels: ${{ steps.meta4.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-msgtransfer + id: meta5 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/openim-msgtransfer + + - name: Build and push Docker image for openim-msgtransfer + uses: docker/build-push-action@v4 + with: + context: . + file: ./build/docker/openim-msgtransfer/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta5.outputs.tags }} + labels: ${{ steps.meta5.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-push + id: meta6 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/openim-push + + - name: Build and push Docker image for openim-push + uses: docker/build-push-action@v4 + with: + context: . + file: ./build/docker/openim-push/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta6.outputs.tags }} + labels: ${{ steps.meta6.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-rpc-auth + id: meta7 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/openim-rpc-auth + + - name: Build and push Docker image for openim-rpc-auth + uses: docker/build-push-action@v4 + with: + context: . + file: ./build/docker/openim-rpc-auth/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta7.outputs.tags }} + labels: ${{ steps.meta7.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-rpc-conversation + id: meta8 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/openim-rpc-conversation + + - name: Build and push Docker image for openim-rpc-conversation + uses: docker/build-push-action@v4 + with: + context: . + file: ./build/docker/openim-rpc-conversation/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta8.outputs.tags }} + labels: ${{ steps.meta8.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-rpc-friend + id: meta9 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/openim-rpc-friend + + - name: Build and push Docker image for openim-rpc-friend + uses: docker/build-push-action@v4 + with: + context: . + file: ./build/docker/openim-rpc-friend/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta9.outputs.tags }} + labels: ${{ steps.meta9.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-rpc-group + id: meta10 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/openim-rpc-group + + - name: Build and push Docker image for openim-rpc-group + uses: docker/build-push-action@v4 + with: + context: . + file: ./build/docker/openim-rpc-group/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta10.outputs.tags }} + labels: ${{ steps.meta10.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-rpc-msg + id: meta11 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/openim-rpc-msg + + - name: Build and push Docker image for openim-rpc-msg + uses: docker/build-push-action@v4 + with: + context: . + file: ./build/docker/openim-rpc-msg/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta11.outputs.tags }} + labels: ${{ steps.meta11.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-rpc-third + id: meta12 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/openim-rpc-third + + - name: Build and push Docker image for openim-rpc-third + uses: docker/build-push-action@v4 + with: + context: . + file: ./build/docker/openim-rpc-third/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta12.outputs.tags }} + labels: ${{ steps.meta12.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-rpc-user + id: meta13 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/openim-rpc-user + + - name: Build and push Docker image for openim-rpc-user + uses: docker/build-push-action@v4 + with: + context: . + file: ./build/docker/openim-rpc-user/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta13.outputs.tags }} + labels: ${{ steps.meta13.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml deleted file mode 100644 index 2ecfad6ea..000000000 --- a/.github/workflows/image.yml +++ /dev/null @@ -1,95 +0,0 @@ -# Copyright © 2023 OpenIM open source community. 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. - -name: Build Image - -on: - push: - branches: - - main - paths: - - "**.go" - - "!**_test.go" - - "build/**" - tags: - - v* - -jobs: - release: - strategy: - matrix: - components: [core, swagger] - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 20 - - uses: dorny/paths-filter@v2 - if: ${{ !startsWith(github.ref_name, 'v') }} - id: changes - with: - filters: | - go: - - '**.go' - - 'build/core/Dockerfile' - api: - - 'openapi/**' - - 'build/swagger/build.sh' - - 'build/swagger/Dockerfile' - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - flavor: | - latest=false - images: | - ${{ secrets.DOCKERHUB_USERNAME }}/openimsdk-${{ matrix.components }} - registry.cn-hangzhou.aliyuncs.com/${{ secrets.ALIREGISTRY_NAMESPACE }}/openimsdk-${{ matrix.components }} - tags: | - type=ref,event=branch - type=sha,prefix={{branch}}-,enable=${{ github.ref_type == 'branch' }} - type=ref,event=tag - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Login to Ali Container Registry - uses: docker/login-action@v2 - with: - registry: registry.cn-hangzhou.aliyuncs.com - username: ${{ secrets.ALIREGISTRY_USERNAME }} - password: ${{ secrets.ALIREGISTRY_TOKEN }} - - - name: Condition - id: condition - run: | - echo "run=${{ startsWith(github.ref_name, 'v') || ((steps.changes.outputs.go == 'true' && (matrix.components == 'core' || matrix.components == 'job')) || (steps.changes.outputs.api == 'true' && matrix.components == 'swagger')) }}" >> $GITHUB_OUTPUT - - - name: Set up QEMU - if: ${{ steps.condition.outputs.run == 'true' }} - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - if: ${{ steps.condition.outputs.run == 'true' }} - uses: docker/setup-buildx-action@v2 - - name: Build and push - if: ${{ steps.condition.outputs.run == 'true' }} - uses: docker/build-push-action@v3 - with: - context: . - file: ./build/${{ matrix.components }}/Dockerfile - platforms: linux/amd64 - push: true - tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/milestone.yml b/.github/workflows/milestone.yml new file mode 100644 index 000000000..db39943e6 --- /dev/null +++ b/.github/workflows/milestone.yml @@ -0,0 +1,58 @@ +# shamelessly copied from https://github.com/sigstore/cosign/blob/main/.github/workflows/milestone.yaml + +name: milestone + +on: + pull_request_target: + types: [closed] + branches: + - main + +jobs: + milestone: + runs-on: ubuntu-latest + + permissions: + actions: none + checks: none + contents: read + deployments: none + issues: write + packages: none + pull-requests: write + repository-projects: none + security-events: none + statuses: none + + steps: + - uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6 + with: + script: | + if (!context.payload.pull_request.merged) { + console.log('PR was not merged, skipping.'); + return; + } + + if (!!context.payload.pull_request.milestone) { + console.log('PR has existing milestone, skipping.'); + return; + } + + milestones = await github.rest.issues.listMilestones({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + sort: 'due_on', + direction: 'asc' + }) + if (milestones.data.length === 0) { + console.log('There are no milestones, skipping.'); + return; + } + + await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + milestone: milestones.data[0].number + }); diff --git a/.github/workflows/openimci.yml b/.github/workflows/openimci.yml index 07133126b..0e69089f9 100644 --- a/.github/workflows/openimci.yml +++ b/.github/workflows/openimci.yml @@ -90,19 +90,11 @@ jobs: echo "Run unit test and get test coverage successfully" continue-on-error: true - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: go - - name: Build source code for host platform run: | sudo make build echo "Build source code for host platform successfully" - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - - name: OpenIM verify copyright run: | sudo make verify-copyright diff --git a/.github/workflows/project-progress.yml b/.github/workflows/project-progress.yml index 247404aa0..d0cc10604 100644 --- a/.github/workflows/project-progress.yml +++ b/.github/workflows/project-progress.yml @@ -33,4 +33,4 @@ jobs: with: project: OpenIM-V3.1 column: In Progress - repo-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + repo-token: ${{ secrets.BOT_GITHUB_TOKEN }} \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index 296bd0dc0..8bafbbe5c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -114,7 +114,7 @@ linters-settings: max-blank-identifiers: 2 dupl: # tokens count to trigger issue, 150 by default - threshold: 100 + threshold: 200 errcheck: # report about not checking of errors in type assertions: `a := b.(MyStruct)`; # default is false: such cases aren't reported by default. diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 31cdbd085..184949283 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -447,8 +447,8 @@ milestones: # Repository for the milestone # Default is extracted from the origin remote URL repo: - owner: user - name: repo + owner: OpenIMSDK + name: Open-IM-Server # Whether to close the milestone close: true @@ -479,6 +479,9 @@ checksum: algorithm: sha256 release: + + prerelease: auto + footer: | ## Welcome to the {{ .Tag }} release of [chat](https://github.com/OpenIMSDK/chat)!🎉🎉! @@ -487,18 +490,14 @@ release: ## Helping out - We release logs are recorded on [✨ CHANGELOG](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/CHANGELOG/CHANGELOG.md)--config_folder_path + + We release logs are recorded on [✨CHANGELOG](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/CHANGELOG/CHANGELOG.md) - For information on versions of OpenIM and how to maintain branches, read [📚this article](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/version.md) + + For information on versions of OpenIM and how to maintain branches, read [📚this article](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/version.md) - This release is only possible thanks to **all** the support of some **awesome people**! - - https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/version.md + + If you wish to use mirroring, read OpenIM's [image management policy](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/images.md) **Want to be one of them 😘?** - Contributions to this project are welcome! Please see [CONTRIBUTING.md](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/CONTRIBUTING.md) for details. -
+ > **Note** + > @openimbot and @kubbot have made great contributions to the community as community 🤖robots(@openimsdk/bot), respectively. + > Thanks to the @openimsdk/openim team for all their hard work on this release. + > Thank you to all the [💕developers and contributors](https://github.com/OpenIMSDK/Open-IM-Server/graphs/contributors), people from all over the world, OpenIM brings us together + > Contributions to this project are welcome! Please see [CONTRIBUTING.md](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/CONTRIBUTING.md) for details. ## Get Involved with OpenIM! diff --git a/Dockerfile b/Dockerfile index 85afdf98b..4be4861f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,6 @@ # Build Stage FROM golang:1.20 AS builder -LABEL org.opencontainers.image.source=https://github.com/OpenIMSDK/Open-IM-Server -LABEL org.opencontainers.image.description="OpenIM Server image" -LABEL org.opencontainers.image.licenses="Apache 2.0" - # Set go mod installation source and proxy ARG GO111MODULE=on ARG GOPROXY=https://goproxy.cn,direct @@ -12,26 +8,26 @@ ENV GO111MODULE=$GO111MODULE ENV GOPROXY=$GOPROXY # Set up the working directory -WORKDIR /Open-IM-Server +WORKDIR /openim/openim-server + +COPY go.mod go.sum ./ +RUN go mod download # Copy all files to the container ADD . . +RUN /bin/sh -c "make clean" RUN /bin/sh -c "make build" -# Production Stage -FROM alpine +FROM ghcr.io/openim-sigs/openim-bash-image:latest -RUN echo "https://mirrors.aliyun.com/alpine/v3.4/main" > /etc/apk/repositories && \ - apk --no-cache add tzdata ca-certificates bash - -# Set directory to map logs, config files, scripts, and SDK -VOLUME ["/Open-IM-Server/logs", "/Open-IM-Server/config", "/Open-IM-Server/scripts", "/Open-IM-Server/db/sdk"] +WORKDIR ${SERVER_WORKDIR} # Copy scripts and binary files to the production image -COPY --from=builder /Open-IM-Server/scripts /Open-IM-Server/scripts -COPY --from=builder /Open-IM-Server/_output/bin/platforms/linux/amd64 /Open-IM-Server/_output/bin/platforms/linux/amd64 +COPY --from=builder ${OPENIM_SERVER_CMDDIR} /openim/openim-server/scripts +COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config +COPY --from=builder ${SERVER_WORKDIR}/_output/bin/platforms /openim/openim-server/_output/bin/platforms -WORKDIR /Open-IM-Server/scripts +VOLUME ["/openim/openim-server/logs","/openim/openim-server/config","/openim/openim-server/scripts"] -CMD ["./docker_start_all.sh"] \ No newline at end of file +CMD ["bash","-c","${OPENIM_SERVER_CMDDIR}/docker_start_all.sh"] \ No newline at end of file diff --git a/build/docker/openim-api/Dockerfile b/build/docker/openim-api/Dockerfile index 1bf965ea4..b0760a6d7 100644 --- a/build/docker/openim-api/Dockerfile +++ b/build/docker/openim-api/Dockerfile @@ -1,12 +1,32 @@ -FROM golang:1.20.0 as build +# OpenIM base image: https://github.com/openim-sigs/openim-base-image -WORKDIR /openim +# Set go mod installation source and proxy -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ - echo "Asia/Shanghai" > /etc/timezone && \ - mkdir -p /var/log/miniblog +FROM golang:1.20 AS builder -COPY miniblog /openim +ARG GO111MODULE=on +ARG GOPROXY=https://goproxy.cn,direct -EXPOSE 10002 -CMD ["./bin/openim-api","--port", "10002"] \ No newline at end of file +WORKDIR /openim/openim-server + +ENV GO111MODULE=$GO111MODULE +ENV GOPROXY=$GOPROXY + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +RUN make clean +RUN make build BINS=openim-api + +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 + +EXPOSE ${10002} + +CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-api --port 10002 -c ${SERVER_WORKDIR}/config"] diff --git a/build/docker/openim-cmdutils/Dockerfile b/build/docker/openim-cmdutils/Dockerfile index e69de29bb..91e97b76f 100644 --- a/build/docker/openim-cmdutils/Dockerfile +++ b/build/docker/openim-cmdutils/Dockerfile @@ -0,0 +1,31 @@ +# OpenIM base image: https://github.com/openim-sigs/openim-base-image + +# Set go mod installation source and proxy + +FROM golang:1.20 AS builder + +ARG GO111MODULE=on +ARG GOPROXY=https://goproxy.cn,direct + +WORKDIR /openim/openim-server + +ENV GO111MODULE=$GO111MODULE +ENV GOPROXY=$GOPROXY + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +RUN go mod download +RUN make clean +RUN make build BINS=openim-cmdutils + +FROM ghcr.io/openim-sigs/openim-bash-image:latest + +WORKDIR /openim/openim-server + +COPY --from=builder ${SERVER_WORKDIR}/_output/bin/platforms /openim/openim-server/_output/bin/platforms +COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config + +CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-cmdutils"] diff --git a/build/docker/openim-crontask/Dockerfile b/build/docker/openim-crontask/Dockerfile index e69de29bb..06847dc72 100644 --- a/build/docker/openim-crontask/Dockerfile +++ b/build/docker/openim-crontask/Dockerfile @@ -0,0 +1,30 @@ +# OpenIM base image: https://github.com/openim-sigs/openim-base-image + +# Set go mod installation source and proxy + +FROM golang:1.20 AS builder + +ARG GO111MODULE=on +ARG GOPROXY=https://goproxy.cn,direct + +WORKDIR /openim/openim-server + +ENV GO111MODULE=$GO111MODULE +ENV GOPROXY=$GOPROXY + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +RUN make clean +RUN make build BINS=openim-crontask + +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 + +CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-crontask"] diff --git a/build/docker/openim-msggateway/Dockerfile b/build/docker/openim-msggateway/Dockerfile index e69de29bb..5661d7f8b 100644 --- a/build/docker/openim-msggateway/Dockerfile +++ b/build/docker/openim-msggateway/Dockerfile @@ -0,0 +1,36 @@ +# OpenIM base image: https://github.com/openim-sigs/openim-base-image + +# Set go mod installation source and proxy + +FROM golang:1.20 AS builder + +ARG GO111MODULE=on +ARG GOPROXY=https://goproxy.cn,direct + +WORKDIR /openim/openim-server + +ENV GO111MODULE=$GO111MODULE +ENV GOPROXY=$GOPROXY + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +RUN make clean +RUN make build BINS=openim-msggateway + +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 OS ${OS} +ENV ARCH ${ARCH} + +EXPOSE 10140 +EXPOSE 10001 + +CMD ${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-msggateway --port 10140 --ws_port 10001 \ No newline at end of file diff --git a/build/docker/openim-msgtransfer/Dockerfile b/build/docker/openim-msgtransfer/Dockerfile index e69de29bb..2c63a3716 100644 --- a/build/docker/openim-msgtransfer/Dockerfile +++ b/build/docker/openim-msgtransfer/Dockerfile @@ -0,0 +1,33 @@ +# OpenIM base image: https://github.com/openim-sigs/openim-base-image + +# Set go mod installation source and proxy + +FROM golang:1.20 AS builder + +ARG GO111MODULE=on +ARG GOPROXY=https://goproxy.cn,direct + +WORKDIR /openim/openim-server + +ENV GO111MODULE=$GO111MODULE +ENV GOPROXY=$GOPROXY + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +RUN make clean +RUN make build BINS=openim-msgtransfer + +FROM ghcr.io/openim-sigs/openim-bash-image:latest + +ENV OS ${OS} +ENV ARCH ${ARCH} + +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 + +CMD ${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-msgtransfer \ No newline at end of file diff --git a/build/docker/openim-push/Dockerfile b/build/docker/openim-push/Dockerfile index e69de29bb..1da84525e 100644 --- a/build/docker/openim-push/Dockerfile +++ b/build/docker/openim-push/Dockerfile @@ -0,0 +1,35 @@ +# OpenIM base image: https://github.com/openim-sigs/openim-base-image + +# Set go mod installation source and proxy + +FROM golang:1.20 AS builder + +ARG GO111MODULE=on +ARG GOPROXY=https://goproxy.cn,direct + +WORKDIR /openim/openim-server + +ENV GO111MODULE=$GO111MODULE +ENV GOPROXY=$GOPROXY + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +RUN make clean +RUN make build BINS=openim-push + +FROM ghcr.io/openim-sigs/openim-bash-image:latest + +WORKDIR /openim/openim-server + +ENV OS ${OS} +ENV ARCH ${ARCH} + +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 + +EXPOSE 10170 + +CMD ${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-push --port 10170 \ No newline at end of file diff --git a/build/docker/openim-rpc-auth/Dockerfile b/build/docker/openim-rpc-auth/Dockerfile index e69de29bb..d7eddad5e 100644 --- a/build/docker/openim-rpc-auth/Dockerfile +++ b/build/docker/openim-rpc-auth/Dockerfile @@ -0,0 +1,38 @@ +# OpenIM base image: https://github.com/openim-sigs/openim-base-image + +# Set go mod installation source and proxy + +FROM golang:1.20 AS builder + +ARG GO111MODULE=on +ARG GOPROXY=https://goproxy.cn,direct + +WORKDIR /openim/openim-server + +ENV GO111MODULE=$GO111MODULE +ENV GOPROXY=$GOPROXY + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +RUN make clean + +# RUN make build BINS=openim-rpc + +RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth ./cmd/openim-rpc/openim-rpc-auth + +FROM ghcr.io/openim-sigs/openim-bash-image:latest + +WORKDIR /openim/openim-server + +ENV OS ${OS} +ENV ARCH ${ARCH} + +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 + +EXPOSE 10160 + +CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-auth --port 10160 -c ${SERVER_WORKDIR}/config"] \ No newline at end of file diff --git a/build/docker/openim-rpc-conversation/Dockerfile b/build/docker/openim-rpc-conversation/Dockerfile index e69de29bb..59eaaf179 100644 --- a/build/docker/openim-rpc-conversation/Dockerfile +++ b/build/docker/openim-rpc-conversation/Dockerfile @@ -0,0 +1,45 @@ +# OpenIM base image: https://github.com/openim-sigs/openim-base-image + +# Set go mod installation source and proxy + +FROM golang:1.20 AS builder + +ARG GO111MODULE=on +ARG GOPROXY=https://goproxy.cn,direct + +WORKDIR /openim/openim-server + +ENV GO111MODULE=$GO111MODULE +ENV GOPROXY=$GOPROXY + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +RUN make clean + +RUN make build BINS=openim-rpc +# RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation ./cmd/openim-rpc/openim-rpc-conversation + +RUN rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-friend && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-group && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-msg && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-third && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-user && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth + +FROM ghcr.io/openim-sigs/openim-bash-image:latest + +WORKDIR /openim/openim-server + +ENV OS ${OS} +ENV ARCH ${ARCH} + +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 + +EXPOSE 10230 +EXPOSE 20230 + +CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-conversation --port 10230 --prometheus_port 20230 -c ${SERVER_WORKDIR}/config"] \ No newline at end of file diff --git a/build/docker/openim-rpc-friend/Dockerfile b/build/docker/openim-rpc-friend/Dockerfile index e69de29bb..139ed49cb 100644 --- a/build/docker/openim-rpc-friend/Dockerfile +++ b/build/docker/openim-rpc-friend/Dockerfile @@ -0,0 +1,45 @@ +# OpenIM base image: https://github.com/openim-sigs/openim-base-image + +# Set go mod installation source and proxy + +FROM golang:1.20 AS builder + +ARG GO111MODULE=on +ARG GOPROXY=https://goproxy.cn,direct + +WORKDIR /openim/openim-server + +ENV GO111MODULE=$GO111MODULE +ENV GOPROXY=$GOPROXY + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +RUN make clean + +RUN make build BINS=openim-rpc +# RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-friend ./cmd/openim-rpc/openim-rpc-friend + +RUN rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-group && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-msg && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-third && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-user && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth + +FROM ghcr.io/openim-sigs/openim-bash-image:latest + +WORKDIR /openim/openim-server + +ENV OS ${OS} +ENV ARCH ${ARCH} + +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 + +EXPOSE 10120 +EXPOSE 20120 + +CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-friend --port 10120 --prometheus_port 20120 -c ${SERVER_WORKDIR}/config"] \ No newline at end of file diff --git a/build/docker/openim-rpc-group/Dockerfile b/build/docker/openim-rpc-group/Dockerfile index e69de29bb..9f18a083a 100644 --- a/build/docker/openim-rpc-group/Dockerfile +++ b/build/docker/openim-rpc-group/Dockerfile @@ -0,0 +1,45 @@ +# OpenIM base image: https://github.com/openim-sigs/openim-base-image + +# Set go mod installation source and proxy + +FROM golang:1.20 AS builder + +ARG GO111MODULE=on +ARG GOPROXY=https://goproxy.cn,direct + +WORKDIR /openim/openim-server + +ENV GO111MODULE=$GO111MODULE +ENV GOPROXY=$GOPROXY + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +RUN make clean + +RUN make build BINS=openim-rpc +# RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-group ./cmd/openim-rpc/openim-rpc-group + +RUN rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-friend && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-msg && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-third && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-user && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth + +FROM ghcr.io/openim-sigs/openim-bash-image:latest + +WORKDIR /openim/openim-server + +ENV OS ${OS} +ENV ARCH ${ARCH} + +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 + +EXPOSE 10150 +EXPOSE 20150 + +CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-group --port 10150 --prometheus_port 20150 -c ${SERVER_WORKDIR}/config"] \ No newline at end of file diff --git a/build/docker/openim-rpc-msg/Dockerfile b/build/docker/openim-rpc-msg/Dockerfile index e69de29bb..48af35c1f 100644 --- a/build/docker/openim-rpc-msg/Dockerfile +++ b/build/docker/openim-rpc-msg/Dockerfile @@ -0,0 +1,45 @@ +# OpenIM base image: https://github.com/openim-sigs/openim-base-image + +# Set go mod installation source and proxy + +FROM golang:1.20 AS builder + +ARG GO111MODULE=on +ARG GOPROXY=https://goproxy.cn,direct + +WORKDIR /openim/openim-server + +ENV GO111MODULE=$GO111MODULE +ENV GOPROXY=$GOPROXY + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +RUN make clean + +RUN make build BINS=openim-rpc +# RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-msg ./cmd/openim-rpc/openim-rpc-msg + +RUN rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-friend && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-group && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-third && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-user && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth + +FROM ghcr.io/openim-sigs/openim-bash-image:latest + +WORKDIR /openim/openim-server + +ENV OS ${OS} +ENV ARCH ${ARCH} + +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 + +EXPOSE 10130 +EXPOSE 20130 + +CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-msg --port 10130 --prometheus_port 20130 -c ${SERVER_WORKDIR}/config"] \ No newline at end of file diff --git a/build/docker/openim-rpc-third/Dockerfile b/build/docker/openim-rpc-third/Dockerfile index e69de29bb..5c4a17668 100644 --- a/build/docker/openim-rpc-third/Dockerfile +++ b/build/docker/openim-rpc-third/Dockerfile @@ -0,0 +1,44 @@ +# OpenIM base image: https://github.com/openim-sigs/openim-base-image + +# Set go mod installation source and proxy + +FROM golang:1.20 AS builder + +ARG GO111MODULE=on +ARG GOPROXY=https://goproxy.cn,direct + +WORKDIR /openim/openim-server + +ENV GO111MODULE=$GO111MODULE +ENV GOPROXY=$GOPROXY + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +RUN make clean + +RUN make build BINS=openim-rpc +# RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-third ./cmd/openim-rpc/openim-rpc-third + +RUN rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-friend && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-group && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-msg && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-user && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth + +FROM ghcr.io/openim-sigs/openim-bash-image:latest + +WORKDIR /openim/openim-server + +ENV OS ${OS} +ENV ARCH ${ARCH} + +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 + +EXPOSE 10200 + +CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-third --port 10200 -c ${SERVER_WORKDIR}/config"] \ No newline at end of file diff --git a/build/docker/openim-rpc-user/Dockerfile b/build/docker/openim-rpc-user/Dockerfile index e69de29bb..732368f89 100644 --- a/build/docker/openim-rpc-user/Dockerfile +++ b/build/docker/openim-rpc-user/Dockerfile @@ -0,0 +1,44 @@ +# OpenIM base image: https://github.com/openim-sigs/openim-base-image + +# Set go mod installation source and proxy + +FROM golang:1.20 AS builder + +ARG GO111MODULE=on +ARG GOPROXY=https://goproxy.cn,direct + +WORKDIR /openim/openim-server + +ENV GO111MODULE=$GO111MODULE +ENV GOPROXY=$GOPROXY + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +RUN make clean + +RUN make build BINS=openim-rpc +# RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-user ./cmd/openim-rpc/openim-rpc-user + +RUN rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-friend && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-group && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-msg && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-third && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation && \ + rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth + +FROM ghcr.io/openim-sigs/openim-bash-image:latest + +WORKDIR /openim/openim-server + +ENV OS ${OS} +ENV ARCH ${ARCH} + +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 + +EXPOSE 10110 + +CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-user --port 10110 -c ${SERVER_WORKDIR}/config"] \ No newline at end of file diff --git a/cmd/openim-api/Makefile b/cmd/openim-api/Makefile deleted file mode 100644 index b72c6c717..000000000 --- a/cmd/openim-api/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.PHONY: all build run gotool install clean help - -NAME=openim-api -BIN_DIR=../../bin/ - -OS:= $(or $(os),linux) -ARCH:=$(or $(arch),amd64) -all: gotool build - -ifeq ($(OS),windows) - -BINARY_NAME=${NAME}.exe - -else - -BINARY_NAME=${NAME} - -endif - -build: - CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME} - -run: - @go run ./ - -gotool: - go fmt ./ - go vet ./ - -install:build - mv ${BINARY_NAME} ${BIN_DIR} - -clean: - @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi diff --git a/cmd/openim-api/deploy.Dockerfile b/cmd/openim-api/deploy.Dockerfile index 3479e0cd3..56dd4a106 100644 --- a/cmd/openim-api/deploy.Dockerfile +++ b/cmd/openim-api/deploy.Dockerfile @@ -14,7 +14,7 @@ FROM ubuntu -WORKDIR /Open-IM-Server/bin +WORKDIR /openim/openim-server/bin RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\ &&apt-get install net-tools @@ -27,6 +27,6 @@ RUN apt-get -qq update \ && apt-get -qq install -y --no-install-recommends ca-certificates curl COPY ./openim-api ./ -VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"] +VOLUME ["/openim/openim-server/logs","/openim/openim-server/config"] CMD ["./openim-api","--port", "10002"] diff --git a/cmd/openim-cmdutils/Makefile b/cmd/openim-cmdutils/Makefile deleted file mode 100644 index e78ac33f6..000000000 --- a/cmd/openim-cmdutils/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.PHONY: all build run gotool install clean help - -NAME=openim-cmdutils -BIN_DIR=../../bin/ - -OS:= $(or $(os),linux) -ARCH:=$(or $(arch),amd64) -all: gotool build - -ifeq ($(OS),windows) - -BINARY_NAME=${NAME}.exe - -else - -BINARY_NAME=${NAME} - -endif - -build: - CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME} - -run: - @go run ./ - -gotool: - go fmt ./ - go vet ./ - -install:build - mv ${BINARY_NAME} ${BIN_DIR} - -clean: - @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi diff --git a/cmd/openim-crontask/Makefile b/cmd/openim-crontask/Makefile deleted file mode 100644 index 58528ccb5..000000000 --- a/cmd/openim-crontask/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.PHONY: all build run gotool install clean help - -NAME=openim-crontask -BIN_DIR=../../bin/ - -OS:= $(or $(os),linux) -ARCH:=$(or $(arch),amd64) -all: gotool build - -ifeq ($(OS),windows) - -BINARY_NAME=${NAME}.exe - -else - -BINARY_NAME=${NAME} - -endif - -build: - CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME} - -run: - @go run ./ - -gotool: - go fmt ./ - go vet ./ - -install:build - mv ${BINARY_NAME} ${BIN_DIR} - -clean: - @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi diff --git a/cmd/openim-crontask/deploy.Dockerfile b/cmd/openim-crontask/deploy.Dockerfile index ba5230c42..9ada56d26 100644 --- a/cmd/openim-crontask/deploy.Dockerfile +++ b/cmd/openim-crontask/deploy.Dockerfile @@ -14,7 +14,7 @@ FROM ubuntu -WORKDIR /Open-IM-Server/bin +WORKDIR /openim/openim-server/bin RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\ &&apt-get install net-tools @@ -27,6 +27,6 @@ RUN apt-get -qq update \ && apt-get -qq install -y --no-install-recommends ca-certificates curl COPY ./openim-crontask ./ -VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"] +VOLUME ["/openim/openim-server/logs","/openim/openim-server/config"] CMD ["./openim-crontask"] diff --git a/cmd/openim-msggateway/Makefile b/cmd/openim-msggateway/Makefile deleted file mode 100644 index d5238beae..000000000 --- a/cmd/openim-msggateway/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.PHONY: all build run gotool install clean help - -NAME=openim-rpc-msg_gateway -BIN_DIR=../../bin/ - -OS:= $(or $(os),linux) -ARCH:=$(or $(arch),amd64) -all: gotool build - -ifeq ($(OS),windows) - -BINARY_NAME=${NAME}.exe - -else - -BINARY_NAME=${NAME} - -endif - -build: - CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME} - -run: - @go run ./ - -gotool: - go fmt ./ - go vet ./ - -install:build - mv ${BINARY_NAME} ${BIN_DIR} - -clean: - @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi diff --git a/cmd/openim-msggateway/deploy.Dockerfile b/cmd/openim-msggateway/deploy.Dockerfile index 7ba0d2235..31a30ff4b 100644 --- a/cmd/openim-msggateway/deploy.Dockerfile +++ b/cmd/openim-msggateway/deploy.Dockerfile @@ -14,7 +14,7 @@ FROM ubuntu -WORKDIR /Open-IM-Server/bin +WORKDIR /openim/openim-server/bin RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\ &&apt-get install net-tools @@ -27,6 +27,6 @@ RUN apt-get -qq update \ && apt-get -qq install -y --no-install-recommends ca-certificates curl COPY ./openim-rpc-msg_gateway ./ -VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"] +VOLUME ["/openim/openim-server/logs","/openim/openim-server/config"] CMD ["./openim-rpc-msg_gateway","--port", "10140" "--ws_port", "10001", "--prometheus_port", "20240"] diff --git a/cmd/openim-msgtransfer/Makefile b/cmd/openim-msgtransfer/Makefile deleted file mode 100644 index e2d058f6d..000000000 --- a/cmd/openim-msgtransfer/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.PHONY: all build run gotool install clean help - -NAME=openim-msgtransfer -BIN_DIR=../../bin/ - -OS:= $(or $(os),linux) -ARCH:=$(or $(arch),amd64) -all: gotool build - -ifeq ($(OS),windows) - -BINARY_NAME=${NAME}.exe - -else - -BINARY_NAME=${NAME} - -endif - -build: - CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME} - -run: - @go run ./ - -gotool: - go fmt ./ - go vet ./ - -install:build - mv ${BINARY_NAME} ${BIN_DIR} - -clean: - @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi diff --git a/cmd/openim-msgtransfer/deploy.Dockerfile b/cmd/openim-msgtransfer/deploy.Dockerfile index 78f1f955c..7eedcbdbc 100644 --- a/cmd/openim-msgtransfer/deploy.Dockerfile +++ b/cmd/openim-msgtransfer/deploy.Dockerfile @@ -14,7 +14,7 @@ FROM ubuntu -WORKDIR /Open-IM-Server/bin +WORKDIR /openim/openim-server/bin RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\ &&apt-get install net-tools @@ -27,6 +27,6 @@ RUN apt-get -qq update \ && apt-get -qq install -y --no-install-recommends ca-certificates curl COPY ./openim-msgtransfer ./ -VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"] +VOLUME ["/openim/openim-server/logs","/openim/openim-server/config"] CMD ["./openim-msgtransfer","--prometheus_port", "21400"] diff --git a/cmd/openim-push/Makefile b/cmd/openim-push/Makefile deleted file mode 100644 index b417faecf..000000000 --- a/cmd/openim-push/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.PHONY: all build run gotool install clean help - -NAME=openim-push -BIN_DIR=../../bin/ - -OS:= $(or $(os),linux) -ARCH:=$(or $(arch),amd64) -all: gotool build - -ifeq ($(OS),windows) - -BINARY_NAME=${NAME}.exe - -else - -BINARY_NAME=${NAME} - -endif - -build: - CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME} - -run: - @go run ./ - -gotool: - go fmt ./ - go vet ./ - -install:build - mv ${BINARY_NAME} ${BIN_DIR} - -clean: - @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi diff --git a/cmd/openim-push/deploy.Dockerfile b/cmd/openim-push/deploy.Dockerfile index 67774a6f7..6e4e44525 100644 --- a/cmd/openim-push/deploy.Dockerfile +++ b/cmd/openim-push/deploy.Dockerfile @@ -14,7 +14,7 @@ FROM ubuntu -WORKDIR /Open-IM-Server/bin +WORKDIR /openim/openim-server/bin RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\ &&apt-get install net-tools @@ -27,6 +27,6 @@ RUN apt-get -qq update \ && apt-get -qq install -y --no-install-recommends ca-certificates curl COPY ./openim-push ./ -VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"] +VOLUME ["/openim/openim-server/logs","/openim/openim-server/config"] CMD ["./openim-push", "--port", "10170", "--prometheus_port", "20170"] diff --git a/cmd/openim-rpc/openim-rpc-auth/Makefile b/cmd/openim-rpc/openim-rpc-auth/Makefile deleted file mode 100644 index 068d50fd8..000000000 --- a/cmd/openim-rpc/openim-rpc-auth/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.PHONY: all build run gotool install clean help - -NAME=openim-rpc-auth -BIN_DIR=../../../bin/ - -OS:= $(or $(os),linux) -ARCH:=$(or $(arch),amd64) -all: gotool build - -ifeq ($(OS),windows) - -BINARY_NAME=${NAME}.exe - -else - -BINARY_NAME=${NAME} - -endif - -build: - CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME} - -run: - @go run ./ - -gotool: - go fmt ./ - go vet ./ - -install:build - mv ${BINARY_NAME} ${BIN_DIR} - -clean: - @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi diff --git a/cmd/openim-rpc/openim-rpc-auth/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-auth/deploy.Dockerfile index b529860f9..6d034303c 100644 --- a/cmd/openim-rpc/openim-rpc-auth/deploy.Dockerfile +++ b/cmd/openim-rpc/openim-rpc-auth/deploy.Dockerfile @@ -14,7 +14,7 @@ FROM ubuntu -WORKDIR /Open-IM-Server/bin +WORKDIR /openim/openim-server/bin RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\ &&apt-get install net-tools @@ -27,6 +27,6 @@ RUN apt-get -qq update \ && apt-get -qq install -y --no-install-recommends ca-certificates curl COPY ./openim-rpc-auth ./ -VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"] +VOLUME ["/openim/openim-server/logs","/openim/openim-server/config"] CMD ["./openim-rpc-auth", "--port", "10160"] diff --git a/cmd/openim-rpc/openim-rpc-conversation/Makefile b/cmd/openim-rpc/openim-rpc-conversation/Makefile deleted file mode 100644 index 4c9726011..000000000 --- a/cmd/openim-rpc/openim-rpc-conversation/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.PHONY: all build run gotool install clean help - -NAME=openim-rpc-conversation -BIN_DIR=../../../bin/ - -OS:= $(or $(os),linux) -ARCH:=$(or $(arch),amd64) -all: gotool build - -ifeq ($(OS),windows) - -BINARY_NAME=${NAME}.exe - -else - -BINARY_NAME=${NAME} - -endif - -build: - CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME} - -run: - @go run ./ - -gotool: - go fmt ./ - go vet ./ - -install:build - mv ${BINARY_NAME} ${BIN_DIR} - -clean: - @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi diff --git a/cmd/openim-rpc/openim-rpc-conversation/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-conversation/deploy.Dockerfile index 33e5c93c1..8245e3ca1 100644 --- a/cmd/openim-rpc/openim-rpc-conversation/deploy.Dockerfile +++ b/cmd/openim-rpc/openim-rpc-conversation/deploy.Dockerfile @@ -14,7 +14,7 @@ FROM ubuntu -WORKDIR /Open-IM-Server/bin +WORKDIR /openim/openim-server/bin RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\ &&apt-get install net-tools @@ -27,6 +27,6 @@ RUN apt-get -qq update \ && apt-get -qq install -y --no-install-recommends ca-certificates curl COPY ./openim-rpc-conversation ./ -VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"] +VOLUME ["/openim/openim-server/logs","/openim/openim-server/config"] CMD ["./openim-rpc-conversation", "--port", "10230", "--prometheus_port","20230"] diff --git a/cmd/openim-rpc/openim-rpc-friend/Makefile b/cmd/openim-rpc/openim-rpc-friend/Makefile deleted file mode 100644 index e0068e97d..000000000 --- a/cmd/openim-rpc/openim-rpc-friend/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.PHONY: all build run gotool install clean help - -NAME=openim-rpc-friend -BIN_DIR=../../../bin/ - -OS:= $(or $(os),linux) -ARCH:=$(or $(arch),amd64) -all: gotool build - -ifeq ($(OS),windows) - -BINARY_NAME=${NAME}.exe - -else - -BINARY_NAME=${NAME} - -endif - -build: - CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME} - -run: - @go run ./ - -gotool: - go fmt ./ - go vet ./ - -install:build - mv ${BINARY_NAME} ${BIN_DIR} - -clean: - @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi diff --git a/cmd/openim-rpc/openim-rpc-friend/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-friend/deploy.Dockerfile index f306a7938..5f842a631 100644 --- a/cmd/openim-rpc/openim-rpc-friend/deploy.Dockerfile +++ b/cmd/openim-rpc/openim-rpc-friend/deploy.Dockerfile @@ -14,7 +14,7 @@ FROM ubuntu -WORKDIR /Open-IM-Server/bin +WORKDIR /openim/openim-server/bin RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\ &&apt-get install net-tools @@ -27,6 +27,6 @@ RUN apt-get -qq update \ && apt-get -qq install -y --no-install-recommends ca-certificates curl COPY ./openim-rpc-friend ./ -VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"] +VOLUME ["/openim/openim-server/logs","/openim/openim-server/config"] CMD ["./openim-rpc-friend", "--port", "10120", "--prometheus_port","20120"] diff --git a/cmd/openim-rpc/openim-rpc-group/Makefile b/cmd/openim-rpc/openim-rpc-group/Makefile deleted file mode 100644 index 8ba79043d..000000000 --- a/cmd/openim-rpc/openim-rpc-group/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.PHONY: all build run gotool install clean help - -NAME=openim-rpc-group -BIN_DIR=../../../bin/ - -OS:= $(or $(os),linux) -ARCH:=$(or $(arch),amd64) -all: gotool build - -ifeq ($(OS),windows) - -BINARY_NAME=${NAME}.exe - -else - -BINARY_NAME=${NAME} - -endif - -build: - CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME} - -run: - @go run ./ - -gotool: - go fmt ./ - go vet ./ - -install:build - mv ${BINARY_NAME} ${BIN_DIR} - -clean: - @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi diff --git a/cmd/openim-rpc/openim-rpc-group/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-group/deploy.Dockerfile index ed46edcf7..42fe164df 100644 --- a/cmd/openim-rpc/openim-rpc-group/deploy.Dockerfile +++ b/cmd/openim-rpc/openim-rpc-group/deploy.Dockerfile @@ -14,7 +14,7 @@ FROM ubuntu -WORKDIR /Open-IM-Server/bin +WORKDIR /openim/openim-server/bin RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\ &&apt-get install net-tools @@ -27,6 +27,6 @@ RUN apt-get -qq update \ && apt-get -qq install -y --no-install-recommends ca-certificates curl COPY ./openim-rpc-group ./ -VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"] +VOLUME ["/openim/openim-server/logs","/openim/openim-server/config"] CMD ["./openim-rpc-group", "--port", "10150", "--prometheus_port","20150"] diff --git a/cmd/openim-rpc/openim-rpc-msg/Makefile b/cmd/openim-rpc/openim-rpc-msg/Makefile deleted file mode 100644 index 872fbfbba..000000000 --- a/cmd/openim-rpc/openim-rpc-msg/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.PHONY: all build run gotool install clean help - -NAME=openim-rpc-msg -BIN_DIR=../../../bin/ - -OS:= $(or $(os),linux) -ARCH:=$(or $(arch),amd64) -all: gotool build - -ifeq ($(OS),windows) - -BINARY_NAME=${NAME}.exe - -else - -BINARY_NAME=${NAME} - -endif - -build: - CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME} - -run: - @go run ./ - -gotool: - go fmt ./ - go vet ./ - -install:build - mv ${BINARY_NAME} ${BIN_DIR} - -clean: - @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi diff --git a/cmd/openim-rpc/openim-rpc-msg/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-msg/deploy.Dockerfile index 61737417e..754d782a0 100644 --- a/cmd/openim-rpc/openim-rpc-msg/deploy.Dockerfile +++ b/cmd/openim-rpc/openim-rpc-msg/deploy.Dockerfile @@ -14,7 +14,7 @@ FROM ubuntu -WORKDIR /Open-IM-Server/bin +WORKDIR /openim/openim-server/bin RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\ &&apt-get install net-tools @@ -27,6 +27,6 @@ RUN apt-get -qq update \ && apt-get -qq install -y --no-install-recommends ca-certificates curl COPY ./openim-rpc-msg ./ -VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"] +VOLUME ["/openim/openim-server/logs","/openim/openim-server/config"] CMD ["./openim-rpc-msg", "--port", "10130", "--prometheus_port","20130"] diff --git a/cmd/openim-rpc/openim-rpc-third/Makefile b/cmd/openim-rpc/openim-rpc-third/Makefile deleted file mode 100644 index 28059b2c4..000000000 --- a/cmd/openim-rpc/openim-rpc-third/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.PHONY: all build run gotool install clean help - -NAME=openim-rpc-third -BIN_DIR=../../../bin/ - -OS:= $(or $(os),linux) -ARCH:=$(or $(arch),amd64) -all: gotool build - -ifeq ($(OS),windows) - -BINARY_NAME=${NAME}.exe - -else - -BINARY_NAME=${NAME} - -endif - -build: - CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME} - -run: - @go run ./ - -gotool: - go fmt ./ - go vet ./ - -install:build - mv ${BINARY_NAME} ${BIN_DIR} - -clean: - @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi diff --git a/cmd/openim-rpc/openim-rpc-third/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-third/deploy.Dockerfile index 29bc2d068..664ad452c 100644 --- a/cmd/openim-rpc/openim-rpc-third/deploy.Dockerfile +++ b/cmd/openim-rpc/openim-rpc-third/deploy.Dockerfile @@ -14,7 +14,7 @@ FROM ubuntu -WORKDIR /Open-IM-Server/bin +WORKDIR /openim/openim-server/bin RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\ &&apt-get install net-tools @@ -27,6 +27,6 @@ RUN apt-get -qq update \ && apt-get -qq install -y --no-install-recommends ca-certificates curl COPY ./openim-rpc-third ./ -VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"] +VOLUME ["/openim/openim-server/logs","/openim/openim-server/config"] CMD ["./openim-rpc-third", "--port", "10200"] diff --git a/cmd/openim-rpc/openim-rpc-user/Makefile b/cmd/openim-rpc/openim-rpc-user/Makefile deleted file mode 100644 index 1a7eed913..000000000 --- a/cmd/openim-rpc/openim-rpc-user/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.PHONY: all build run gotool install clean help - -NAME=openim-rpc-user -BIN_DIR=../../../bin/ - -OS:= $(or $(os),linux) -ARCH:=$(or $(arch),amd64) -all: gotool build - -ifeq ($(OS),windows) - -BINARY_NAME=${NAME}.exe - -else - -BINARY_NAME=${NAME} - -endif - -build: - CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME} - -run: - @go run ./ - -gotool: - go fmt ./ - go vet ./ - -install:build - mv ${BINARY_NAME} ${BIN_DIR} - -clean: - @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi diff --git a/cmd/openim-rpc/openim-rpc-user/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-user/deploy.Dockerfile index 8ab7df1e7..f9663c9ba 100644 --- a/cmd/openim-rpc/openim-rpc-user/deploy.Dockerfile +++ b/cmd/openim-rpc/openim-rpc-user/deploy.Dockerfile @@ -14,7 +14,7 @@ FROM ubuntu -WORKDIR /Open-IM-Server/bin +WORKDIR /openim/openim-server/bin RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\ &&apt-get install net-tools @@ -27,6 +27,6 @@ RUN apt-get -qq update \ && apt-get -qq install -y --no-install-recommends ca-certificates curl COPY ./openim-rpc-user ./ -VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"] +VOLUME ["/openim/openim-server/logs","/openim/openim-server/config"] CMD ["./openim-rpc-user", "--port", "10110"] diff --git a/docker-compose.yaml b/docker-compose.yaml index c28c8bc96..74eafd66c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -100,14 +100,12 @@ services: openim_server: - image: ghcr.io/openimsdk/openim-server:main + image: ghcr.io/openim-sigs/openim-server:v1.0.0-debug.11 #ghcr.io/openimsdk/openim-server:main container_name: openim-server volumes: - - ./logs:/Open-IM-Server/logs - - ./config/config.yaml:/Open-IM-Server/config/config.yaml - - ./config/notification.yaml:/Open-IM-Server/config/notification.yaml - - ${DATA_DIR}/db/sdk:/Open-IM-Server/db/sdk - - ./scripts:/Open-IM-Server/scripts + - ./logs:/openim/openim-server/logs + - ./config:/openim/openim-server/config + - ./scripts:/openim/openim-server/scripts restart: always depends_on: - zookeeper @@ -123,9 +121,13 @@ services: max-size: "1g" max-file: "2" - openim_chat: - image: ghcr.io/openimsdk/openim-chat:main - container_name: openim_chat + openim-chat: + image: ghcr.io/openim-sigs/openim-chat:v1.0.0-debug.11 # ghcr.io/openimsdk/openim-chat:main + container_name: openim-chat + volumes: + - ./_output/openim/openim-chat/logs:/openim/openim-chat/logs + - ./_output/openim/openim-chat/config:/openim/openim-chat/config + - ./_output/openim/openim-chat/scripts:/openim/openim-chat/scripts restart: always depends_on: - mysql diff --git a/init_docker.sh b/init_docker.sh deleted file mode 100755 index b06eda469..000000000 --- a/init_docker.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -mark='' -for ((ratio=0;${ratio}<=100;ratio+=5)) -do - sleep 0.2 - printf "progress:[%-40s]%d%%\r" "${mark}" "${ratio}" - mark="##${mark}" -done -echo - -set -e - -# Change directory to the 'scripts' folder -cd scripts - -# Grant execute permissions to all shell scripts in the 'scripts' folder -chmod +x *.sh - -# Run the 'env_check.sh' script for environment checks -./env_check.sh - -# Move back to the parent directory -cd .. - -# Check if Docker is installed -if ! command -v docker >/dev/null 2>&1; then - echo "Error: Docker is not installed. Please install Docker before running this script." - exit 1 -fi - -# Start Docker services using docker-compose -if command -v docker-compose &> /dev/null -then - docker-compose up -d -else - docker compose up -d -fi - -# Move back to the 'scripts' folder -cd scripts - -# Run the 'docker_check_service.sh' script for Docker service checks -./docker_check_service.sh diff --git a/install.sh b/install.sh index f9b9b7ec4..59ac75a06 100755 --- a/install.sh +++ b/install.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright © 2023 OpenIM. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,7 +20,7 @@ set -e set -o pipefail -############### OpenIM Github ############### +############################## OpenIM Github ############################## # ... rest of the script ... # TODO @@ -78,7 +78,7 @@ GITHUB_TOKEN= # Default data directory. If you want to specify a different directory, uncomment and replace "./". # DATA_DIR=./ -############### OpenIM Functions ############### +############################## OpenIM Functions ############################## # Install horizon of the script # # Pre-requisites: @@ -290,7 +290,7 @@ function install_openim() { success "OpenIM installation completed successfully. Happy chatting!" } -############### OpenIM Help ############### +############################## OpenIM Help ############################## # Function to display help message function cmd_help() { @@ -406,7 +406,7 @@ function parseinput() { done } -############### OpenIM LOGO ############### +############################## OpenIM LOG ############################## # Set text color to cyan for header and URL print_with_delay() { text="$1" diff --git a/install_guide.sh b/install_guide.sh index 1c5f06fb9..a32bd24f4 100755 --- a/install_guide.sh +++ b/install_guide.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash echo "Welcome to the Open-IM-Server installation scripts." echo "Please select an deploy option:" diff --git a/pkg/common/config/version b/pkg/common/config/version index 1c5ae5820..3a285c2be 100644 --- a/pkg/common/config/version +++ b/pkg/common/config/version @@ -1 +1 @@ -v3.0.0 \ No newline at end of file +v3.1.0 \ No newline at end of file diff --git a/scripts/advertise.sh b/scripts/advertise.sh index c1cd63f56..9d47b5ac7 100755 --- a/scripts/advertise.sh +++ b/scripts/advertise.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e set -o pipefail diff --git a/scripts/build.cmd b/scripts/build.cmd index f3c086a32..d153e6d9e 100644 --- a/scripts/build.cmd +++ b/scripts/build.cmd @@ -1,12 +1,13 @@ +@echo off set output_dir=%~dp0..\_output\bin\platforms\windows -go build -o %output_dir%\api.exe ../cmd/openim-api/main.go -go build -o %output_dir%\auth.exe ../cmd/openim-rpc/openim-rpc-auth/main.go -go build -o %output_dir%\conversation.exe ../cmd/openim-rpc/openim-rpc-conversation/main.go -go build -o %output_dir%\friend.exe ../cmd/openim-rpc/openim-rpc-friend/main.go -go build -o %output_dir%\group.exe ../cmd/openim-rpc/openim-rpc-group/main.go -go build -o %output_dir%\msg.exe ../cmd/openim-rpc/openim-rpc-msg/main.go -go build -o %output_dir%\third.exe ../cmd/openim-rpc/openim-rpc-third/main.go -go build -o %output_dir%\user.exe ../cmd/openim-rpc/openim-rpc-user/main.go -go build -o %output_dir%\push.exe ../cmd/openim-push/main.go -go build -o %output_dir%\msgtransfer.exe ../cmd/openim-msgtransfer/main.go -go build -o %output_dir%\msggateway.exe ../cmd/openim-msggateway/main.go \ No newline at end of file + +set "rpc_apps=auth conversation friend group msg third user" +set "other_apps=api push msgtransfer msggateway" + +for %%a in (%rpc_apps%) do ( + go build -o %output_dir%\%%a.exe ../cmd/openim-rpc/openim-rpc-%%a/main.go +) + +for %%a in (%other_apps%) do ( + go build -o %output_dir%\%%a.exe ../cmd/openim-%%a/main.go +) diff --git a/scripts/common.sh b/scripts/common.sh index 8ae2abfa5..97d5968ba 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -104,9 +104,7 @@ openim::build::get_docker_wrapped_binaries() { "openim-rpc-msg,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}" "openim-rpc-third,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}" "openim-rpc-user,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}" - ) - echo "${targets[@]}" } diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh index 421900ef4..1033b5306 100755 --- a/scripts/docker_start_all.sh +++ b/scripts/docker_start_all.sh @@ -22,11 +22,11 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. #fixme Put the shell scripts name here need_to_start_server_shell=( - start_rpc_service.sh - msg_gateway_start.sh - push_start.sh - msg_transfer_start.sh - start_cron.sh + ${SCRIPTS_ROOT}/start_rpc_service.sh + ${SCRIPTS_ROOT}/msg_gateway_start.sh + ${SCRIPTS_ROOT}/push_start.sh + ${SCRIPTS_ROOT}/msg_transfer_start.sh + ${SCRIPTS_ROOT}/start_cron.sh ) #fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started @@ -41,8 +41,7 @@ echo "==========================================================">>$OPENIM_ROOT/ echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 & echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 & for i in ${need_to_start_server_shell[*]}; do - chmod +x $i - ./$i + $i done sleep 15 diff --git a/scripts/enterprise/function.sh b/scripts/enterprise/function.sh index e2dc96a25..8b5cb0b2b 100755 --- a/scripts/enterprise/function.sh +++ b/scripts/enterprise/function.sh @@ -16,12 +16,12 @@ #input:[10023,2323,3434] #output:10023 2323 3434 list_to_string(){ -ports_list=$* -sub_s1=`echo $ports_list | sed 's/ //g'` -sub_s2=${sub_s1//,/ } -sub_s3=${sub_s2#*[} -sub_s4=${sub_s3%]*} -ports_array=$sub_s4 + ports_list=$* + sub_s1=`echo $ports_list | sed 's/ //g'` + sub_s2=${sub_s1//,/ } + sub_s3=${sub_s2#*[} + sub_s4=${sub_s3%]*} + ports_array=$sub_s4 } remove_space(){ value=$* diff --git a/scripts/enterprise/path_info.cfg b/scripts/enterprise/path_info.cfg index 6ce712593..3b18bbf90 100644 --- a/scripts/enterprise/path_info.cfg +++ b/scripts/enterprise/path_info.cfg @@ -1,11 +1,8 @@ #Don't put the space between "=" - -demo_server_name="openim_chat_api" +demo_server_name="chat-api" demo_server_binary_root="$BIN_DIR/" - - #Global configuration file default dir config_path="../.docker-compose_cfg/config.yaml" @@ -15,15 +12,14 @@ service_source_root=( ../cmd/api/chat/ ../cmd/api/admin/ #rpc service file - ../cmd/openim-rpc/admin/ - ../cmd/openim-rpc/chat/ + ../cmd/rpc/admin/ + ../cmd/rpc/chat/ ) + #service filename service_names=( - #api service filename - openim_chat_api - openim_admin_api - #rpc service filename - openim_admin - openim_chat + chat-api + admin-api + admin-rpc + chat-rpc ) diff --git a/scripts/init_pwd.sh b/scripts/init_pwd.sh index f33c9b3dc..1e5fa3b34 100755 --- a/scripts/init_pwd.sh +++ b/scripts/init_pwd.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright © 2023 OpenIM. All rights reserved. # diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh index b442e1160..0d35e9198 100755 --- a/scripts/lib/golang.sh +++ b/scripts/lib/golang.sh @@ -35,7 +35,6 @@ openim::golang::server_targets() { local targets=( openim-api openim-cmdutils - openim-cmdutils openim-crontask openim-msggateway openim-msgtransfer diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk index dedcdc9fc..f4e278a8c 100644 --- a/scripts/make-rules/golang.mk +++ b/scripts/make-rules/golang.mk @@ -120,7 +120,7 @@ go.build.%: @echo "===========> Building binary $(COMMAND) $(VERSION) for $(OS)_$(ARCH)" @mkdir -p $(BIN_DIR)/platforms/$(OS)/$(ARCH) @if [ "$(COMMAND)" == "openim-sdk-core" ]; then \ - echo "===========> DEBUG: Compilation is not yet supported $(COMMAND)"; \ + echo "===========> DEBUG: OpenIM-SDK-Core It is no longer supported for openim-server $(COMMAND)"; \ elif [ "$(COMMAND)" == "openim-rpc" ]; then \ for d in $(wildcard $(ROOT_DIR)/cmd/openim-rpc/*); do \ cd $${d} && CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \ diff --git a/scripts/msg_transfer_start.sh b/scripts/msg_transfer_start.sh index b1e17769d..7221ffa49 100755 --- a/scripts/msg_transfer_start.sh +++ b/scripts/msg_transfer_start.sh @@ -38,10 +38,10 @@ prome_ports=($ports_array) #Check if the service exists #If it is exists,kill this process -check=`ps aux | grep -w ./${openim_msgtransfer} | grep -v grep| wc -l` +check=`ps | grep -w ./${openim_msgtransfer} | grep -v grep| wc -l` if [ $check -ge 1 ] then -oldPid=`ps aux | grep -w ./${openim_msgtransfer} | grep -v grep|awk '{print $2}'` +oldPid=`ps | grep -w ./${openim_msgtransfer} | grep -v grep|awk '{print $2}'` kill -9 $oldPid fi #Waiting port recycling @@ -59,10 +59,10 @@ for ((i = 0; i < ${msg_transfer_service_num}; i++)); do done #Check launched service process -check=`ps aux | grep -w ./${openim_msgtransfer} | grep -v grep| wc -l` +check=`ps | grep -w ./${openim_msgtransfer} | grep -v grep| wc -l` if [ $check -ge 1 ] then -newPid=`ps aux | grep -w ./${openim_msgtransfer} | grep -v grep|awk '{print $2}'` +newPid=`ps | grep -w ./${openim_msgtransfer} | grep -v grep|awk '{print $2}'` allPorts="" echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${openim_msgtransfer}${COLOR_SUFFIX} diff --git a/scripts/push_start.sh b/scripts/push_start.sh index 74b9aedc9..6b26c3022 100755 --- a/scripts/push_start.sh +++ b/scripts/push_start.sh @@ -45,9 +45,9 @@ prome_ports=($ports_array) #Check if the service exists #If it is exists,kill this process -check=$(ps aux | grep -w ./${push_name} | grep -v grep | wc -l) +check=$(ps | grep -w ./${push_name} | grep -v grep | wc -l) if [ $check -ge 1 ]; then - oldPid=$(ps aux | grep -w ./${push_name} | grep -v grep | awk '{print $2}') + oldPid=$(ps | grep -w ./${push_name} | grep -v grep | awk '{print $2}') kill -9 $oldPid fi #Waiting port recycling @@ -61,9 +61,9 @@ done sleep 3 #Check launched service process -check=$(ps aux | grep -w ./${push_name} | grep -v grep | wc -l) +check=$(ps | grep -w ./${push_name} | grep -v grep | wc -l) if [ $check -ge 1 ]; then - newPid=$(ps aux | grep -w ./${push_name} | grep -v grep | awk '{print $2}') + newPid=$(ps | grep -w ./${push_name} | grep -v grep | awk '{print $2}') ports=$(netstat -netulp | grep -w ${newPid} | awk '{print $4}' | awk -F '[:]' '{print $NF}') allPorts="" diff --git a/scripts/start_all.sh b/scripts/start_all.sh index 6470ae910..87363c547 100755 --- a/scripts/start_all.sh +++ b/scripts/start_all.sh @@ -27,15 +27,15 @@ source $SCRIPTS_ROOT/function.sh cd $SCRIPTS_ROOT +echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" +echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" +echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}" + if [ ! -d "${OPENIM_ROOT}/_output/bin/platforms" ]; then # exec build_all_service.sh "${SCRIPTS_ROOT}/build_all_service.sh" fi -echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" -echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" -echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}" - bin_dir="$OPENIM_ROOT/_output/bin" logs_dir="$OPENIM_ROOT/logs" sdk_db_dir="$OPENIM_ROOT/sdk/db/" diff --git a/scripts/start_cron.sh b/scripts/start_cron.sh index 79b5b9c31..2f27801be 100755 --- a/scripts/start_cron.sh +++ b/scripts/start_cron.sh @@ -34,10 +34,10 @@ sdk_db_dir="$OPENIM_ROOT/sdk/db/" #Check if the service exists #If it is exists,kill this process -check=`ps aux | grep -w ./${cron_task_name} | grep -v grep| wc -l` +check=`ps | grep -w ./${cron_task_name} | grep -v grep| wc -l` if [ $check -ge 1 ] then -oldPid=`ps aux | grep -w ./${cron_task_name} | grep -v grep|awk '{print $2}'` +oldPid=`ps | grep -w ./${cron_task_name} | grep -v grep|awk '{print $2}'` kill -9 $oldPid fi #Waiting port recycling @@ -50,10 +50,10 @@ nohup ./${cron_task_name} >>$OPENIM_ROOT/logs/openIM.log 2>&1 & #done #Check launched service process -check=`ps aux | grep -w ./${cron_task_name} | grep -v grep| wc -l` +check=`ps | grep -w ./${cron_task_name} | grep -v grep| wc -l` if [ $check -ge 1 ] then -newPid=`ps aux | grep -w ./${cron_task_name} | grep -v grep|awk '{print $2}'` +newPid=`ps | grep -w ./${cron_task_name} | grep -v grep|awk '{print $2}'` allPorts="" echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${cron_task_name}${COLOR_SUFFIX} diff --git a/scripts/start_rpc_service.sh b/scripts/start_rpc_service.sh index f1624c34e..f42f536c2 100755 --- a/scripts/start_rpc_service.sh +++ b/scripts/start_rpc_service.sh @@ -30,7 +30,6 @@ echo -e "${BACKGROUND_GREEN}${CYAN_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}" bin_dir="$BIN_DIR" logs_dir="$OPENIM_ROOT/logs" -sdk_db_dir="$OPENIM_ROOT/sdk/db/" #service filename service_filename=( @@ -75,7 +74,7 @@ service_prometheus_port_name=( for ((i = 0; i < ${#service_filename[*]}; i++)); do #Check whether the service exists - service_name="ps -aux |grep -w ${service_filename[$i]} |grep -v grep" + service_name="ps |grep -w ${service_filename[$i]} |grep -v grep" count="${service_name}| wc -l" if [ $(eval ${count}) -gt 0 ]; then diff --git a/scripts/stop_all.sh b/scripts/stop_all.sh index 8bd5aaf34..4fd327407 100755 --- a/scripts/stop_all.sh +++ b/scripts/stop_all.sh @@ -29,7 +29,7 @@ cd "$SCRIPTS_ROOT" for i in ${service_names[*]}; do #Check whether the service exists - name="ps -aux |grep -w $i |grep -v grep" + name="ps |grep -w $i |grep -v grep" count="${name}| wc -l" if [ $(eval ${count}) -gt 0 ]; then pid="${name}| awk '{print \$2}'" diff --git a/scripts/style_info.sh b/scripts/style_info.sh index b56eceeff..ff3a6330b 100755 --- a/scripts/style_info.sh +++ b/scripts/style_info.sh @@ -13,50 +13,53 @@ # See the License for the specific language governing permissions and # limitations under the License. +function style-info() { + COLOR_SUFFIX="\033[0m" # End all colors and special effects -COLOR_SUFFIX="\033[0m" # End all colors and special effects + BLACK_PREFIX="\033[30m" # Black prefix + RED_PREFIX="\033[31m" # Red prefix + GREEN_PREFIX="\033[32m" # Green prefix + YELLOW_PREFIX="\033[33m" # Yellow prefix + BLUE_PREFIX="\033[34m" # Blue prefix + PURPLE_PREFIX="\033[35m" # Purple prefix + SKY_BLUE_PREFIX="\033[36m" # Sky blue prefix + WHITE_PREFIX="\033[37m" # White prefix + BOLD_PREFIX="\033[1m" # Bold prefix + UNDERLINE_PREFIX="\033[4m" # Underline prefix + ITALIC_PREFIX="\033[3m" # Italic prefix -BLACK_PREFIX="\033[30m" # Black prefix -RED_PREFIX="\033[31m" # Red prefix -GREEN_PREFIX="\033[32m" # Green prefix -YELLOW_PREFIX="\033[33m" # Yellow prefix -BLUE_PREFIX="\033[34m" # Blue prefix -PURPLE_PREFIX="\033[35m" # Purple prefix -SKY_BLUE_PREFIX="\033[36m" # Sky blue prefix -WHITE_PREFIX="\033[37m" # White prefix -BOLD_PREFIX="\033[1m" # Bold prefix -UNDERLINE_PREFIX="\033[4m" # Underline prefix -ITALIC_PREFIX="\033[3m" # Italic prefix + CYAN_PREFIX="033[0;36m" # Cyan prefix -CYAN_PREFIX="033[0;36m" # Cyan prefix + BACKGROUND_BLACK="\033[40m" # Black background + BACKGROUND_RED="\033[41m" # Red background + BACKGROUND_GREEN="\033[42m" # Green background + BACKGROUND_YELLOW="\033[43m" # Yellow background + BACKGROUND_BLUE="\033[44m" # Blue background + BACKGROUND_PURPLE="\033[45m" # Purple background + BACKGROUND_SKY_BLUE="\033[46m" # Sky blue background + BACKGROUND_WHITE="\033[47m" # White background -BACKGROUND_BLACK="\033[40m" # Black background -BACKGROUND_RED="\033[41m" # Red background -BACKGROUND_GREEN="\033[42m" # Green background -BACKGROUND_YELLOW="\033[43m" # Yellow background -BACKGROUND_BLUE="\033[44m" # Blue background -BACKGROUND_PURPLE="\033[45m" # Purple background -BACKGROUND_SKY_BLUE="\033[46m" # Sky blue background -BACKGROUND_WHITE="\033[47m" # White background + BLINK="\033[5m" # Blinking effect + INVERT="\033[7m" # Invert color + HIDE="\033[8m" # Hide text -BLINK="\033[5m" # Blinking effect -INVERT="\033[7m" # Invert color -HIDE="\033[8m" # Hide text + GRAY_PREFIX="\033[90m" # Gray prefix + LIGHT_RED_PREFIX="\033[91m" # Light red prefix + LIGHT_GREEN_PREFIX="\033[92m" # Light green prefix + LIGHT_YELLOW_PREFIX="\033[93m" # Light yellow prefix + LIGHT_BLUE_PREFIX="\033[94m" # Light blue prefix + LIGHT_PURPLE_PREFIX="\033[95m" # Light purple prefix + LIGHT_SKY_BLUE_PREFIX="\033[96m" # Light sky blue prefix + LIGHT_WHITE_PREFIX="\033[97m" # Light white prefix -GRAY_PREFIX="\033[90m" # Gray prefix -LIGHT_RED_PREFIX="\033[91m" # Light red prefix -LIGHT_GREEN_PREFIX="\033[92m" # Light green prefix -LIGHT_YELLOW_PREFIX="\033[93m" # Light yellow prefix -LIGHT_BLUE_PREFIX="\033[94m" # Light blue prefix -LIGHT_PURPLE_PREFIX="\033[95m" # Light purple prefix -LIGHT_SKY_BLUE_PREFIX="\033[96m" # Light sky blue prefix -LIGHT_WHITE_PREFIX="\033[97m" # Light white prefix + BACKGROUND_GRAY="\033[100m" # Gray background + BACKGROUND_LIGHT_RED="\033[101m" # Light red background + BACKGROUND_LIGHT_GREEN="\033[102m" # Light green background + BACKGROUND_LIGHT_YELLOW="\033[103m" # Light yellow background + BACKGROUND_LIGHT_BLUE="\033[104m" # Light blue background + BACKGROUND_LIGHT_PURPLE="\033[105m" # Light purple background + BACKGROUND_LIGHT_SKY_BLUE="\033[106m" # Light sky blue background + BACKGROUND_LIGHT_WHITE="\033[107m" # Light white background +} -BACKGROUND_GRAY="\033[100m" # Gray background -BACKGROUND_LIGHT_RED="\033[101m" # Light red background -BACKGROUND_LIGHT_GREEN="\033[102m" # Light green background -BACKGROUND_LIGHT_YELLOW="\033[103m" # Light yellow background -BACKGROUND_LIGHT_BLUE="\033[104m" # Light blue background -BACKGROUND_LIGHT_PURPLE="\033[105m" # Light purple background -BACKGROUND_LIGHT_SKY_BLUE="\033[106m" # Light sky blue background -BACKGROUND_LIGHT_WHITE="\033[107m" # Light white background +style-info \ No newline at end of file diff --git a/test/common.sh b/test/common.sh index 904608894..e583fe8b3 100644 --- a/test/common.sh +++ b/test/common.sh @@ -12,4 +12,3 @@ # 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. -