From 5eb97766b64c04cec5e33d9a36a6cea0ee67f293 Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com> Date: Thu, 27 Jul 2023 20:44:36 +0800 Subject: [PATCH] feat: add go relase Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> --- .github/workflows/build-docker-image.yml | 22 ++++---- .github/workflows/deploy.yml | 68 ++++++++++++----------- docs/conversions/images.md | 69 ++++++++++++++++++++++++ docs/conversions/version.md | 6 ++- 4 files changed, 124 insertions(+), 41 deletions(-) create mode 100644 docs/conversions/images.md diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index ef2659724..4d1a61583 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -18,6 +18,7 @@ on: push: branches: - main + - release-* tags: - v* workflow_dispatch: @@ -29,6 +30,10 @@ jobs: - name: Check out the repo uses: actions/checkout@v3 + - name: Build OpenIM Server + run: | + sudo make build + # docker.io/openim/openim-server:latest - name: Log in to Docker Hub uses: docker/login-action@v2 @@ -41,13 +46,12 @@ jobs: uses: docker/metadata-action@v4.6.0 with: images: openim/openim-server - tags: latest - name: Build and push Docker image uses: docker/build-push-action@v4 with: context: . - push: true + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} @@ -64,15 +68,14 @@ jobs: uses: docker/metadata-action@v4.6.0 with: images: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server - tags: latest - name: Build and push Docker image uses: docker/build-push-action@v4 with: context: . - push: true - tags: ${{ steps.meta2.outputs.tags }} - labels: ${{ steps.meta2.outputs.labels }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} # ghcr.io/openim/openim-server:latest - name: Log in to GitHub Container Registry @@ -87,15 +90,14 @@ jobs: uses: docker/metadata-action@v4.6.0 with: images: openim/openim-server - tags: latest - name: Build and push Docker image uses: docker/build-push-action@v4 with: context: . - push: true - tags: ${{ steps.meta3.outputs.tags }} - labels: ${{ steps.meta3.outputs.labels }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} # name: OpenIM Build Docker Images # on: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6695d4092..ea28440e9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -18,6 +18,7 @@ on: push: branches: - 'devops' # Only for the dev branch + - 'main' paths: - '.github/workflows/*' # - '__test__/**' # dev No immediate testing is required @@ -30,36 +31,43 @@ jobs: deploy-dev: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: set ssh key # Temporarily set up ssh key - run: | - mkdir -p ~/.ssh/ - # secrets.WFP_ID_RSA set in GitHub - echo "${{secrets.WFP_ID_RSA}}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - ssh-keyscan "182.92.xxx.xxx" >> ~/.ssh/known_hosts + - uses: actions/checkout@v3 - name: executing remote ssh commands using password uses: appleboy/ssh-action@v1.0.0 + env: + OWNER: ${{ github.repository_owner }} + REPO: ${{ github.event.repository.name }} with: - host: ${{ secrets.HOST }} - username: ${{ secrets.USERNAME }} - password: ${{ secrets.PASSWORD }} - port: ${{ secrets.PORT }} - script: whoami - - name: deploy # Deployment - run: | - ssh work@182.92.xxx.xxx " - # 【Attention】Log in with the 'work' account, manually create /home/work/imooc-lego directory - # Then git clone https://username:password@github.com/imooc-lego/biz-editor-server.git -b dev (private repository, use GitHub username and password) - # Remember to delete origin to avoid exposing GitHub password - cd /home/work/imooc-lego/biz-editor-server; - git remote add origin https://openimbot:${{secrets.WFP_PASSWORD}}@github.com/OpenIMSDK/open-im-server.git; - git checkout dev; - git pull origin dev; # Download the latest code again - git remote remove origin; # Remove origin to avoid exposing GitHub password - # Start docker - docker-compose build editor-server; # Same as the service name in docker-compose.yml - docker-compose up -d; - " - - name: delete ssh key # Delete ssh key - run: rm -rf ~/.ssh/id_rsa \ No newline at end of file + host: "${{ secrets.SG_M1_HOST }}, ${{ secrets.SG_N1_HOST }}, ${{ secrets.SG_N2_HOST}}" + username: ${{ secrets.SG_USERNAME }} + password: ${{ secrets.SG_PASSWORD }} + port: ${{ secrets.SG_PORT }} + envs: OWNER,REPO + script_stop: true + script: | + mkdir -p /test/openim + cd /test/openim + pwd;ls -al + echo "OWNER: $OWNER" + echo "REPO: $REPO" + git clone -b develop https://github.com/${OWNER}/${REPO}.git; cd ${REPO} + docker compose up -d + + + # - name: deploy # Deployment + # run: | + # ssh work@182.92.xxx.xxx " + # # 【Attention】Log in with the 'work' account, manually create /home/work/imooc-lego directory + # # Then git clone https://username:password@github.com/imooc-lego/biz-editor-server.git -b dev (private repository, use GitHub username and password) + # # Remember to delete origin to avoid exposing GitHub password + # cd /home/work/imooc-lego/biz-editor-server; + # git remote add origin https://openimbot:${{secrets.WFP_PASSWORD}}@github.com/OpenIMSDK/open-im-server.git; + # git checkout dev; + # git pull origin dev; # Download the latest code again + # git remote remove origin; # Remove origin to avoid exposing GitHub password + # # Start docker + # docker-compose build editor-server; # Same as the service name in docker-compose.yml + # docker-compose up -d; + # " + # - name: delete ssh key # Delete ssh key + # run: rm -rf ~/.ssh/id_rsa \ No newline at end of file diff --git a/docs/conversions/images.md b/docs/conversions/images.md new file mode 100644 index 000000000..750956ec0 --- /dev/null +++ b/docs/conversions/images.md @@ -0,0 +1,69 @@ +# OpenIM Image Management Strategy and Pulling Guide + +OpenIM is an efficient, stable, and scalable instant messaging framework that provides convenient deployment methods through Docker images. OpenIM manages multiple image sources, hosted respectively on GitHub (ghcr), Alibaba Cloud, and Docker Hub. This document is aimed at detailing the image management strategy of OpenIM and providing the steps for pulling these images. + +## Image Management Strategy + +OpenIM's versions correspond to GitHub's tag versions. Each time we release a new version and tag it on GitHub, an automated process is triggered that pushes the new Docker image version to the following three platforms: + +1. **GitHub (ghcr.io):** We use GitHub Container Registry (ghcr.io) to host OpenIM's Docker images. This allows us to better integrate with the GitHub source code repository, providing better version control and continuous integration/deployment (CI/CD) features. You can view all GitHub images [here](https://github.com/orgs/OpenIMSDK/packages). +2. **Alibaba Cloud (registry.cn-hangzhou.aliyuncs.com):** For users in Mainland China, we also host OpenIM's Docker images on Alibaba Cloud to provide faster pull speeds. You can view all Alibaba Cloud images on this [page](https://cr.console.aliyun.com/cn-hangzhou/instances/repositories) of Alibaba Cloud Image Service (note that you need to log in to your Alibaba Cloud account first). +3. **Docker Hub (docker.io):** Docker Hub is the most commonly used Docker image hosting platform, and we also host OpenIM's images there to facilitate developers worldwide. You can view all Docker Hub images on the [OpenIM's Docker Hub page](https://hub.docker.com/r/openim). + +## Methods and Steps for Pulling Images + +When pulling OpenIM's Docker images, you can choose the most suitable source based on your geographic location and network conditions. Here are the steps to pull OpenIM images from each source: + +1. First, make sure Docker is installed on your machine. If not, you can refer to the [Docker official documentation](https://docs.docker.com/get-docker/) for installation. + +2. Open the terminal and run the following commands to pull the images: + + For OpenIM Server: + + - Pull from GitHub: + + ``` + bashCopy code + docker pull ghcr.io/openim/openim-server:latest + ``` + + - Pull from Alibaba Cloud: + + ``` + bashCopy code + docker pull registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server:latest + ``` + + - Pull from Docker Hub: + + ``` + bashCopy code + docker pull docker.io/openim/openim-server:latest + ``` + + For OpenIM Chat: + + - Pull from GitHub: + + ``` + bashCopy code + docker pull ghcr.io/openim/openim-chat:latest + ``` + + - Pull from Alibaba Cloud: + + ``` + bashCopy code + docker pull registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:latest + ``` + + - Pull from Docker Hub: + + ``` + bashCopy code + docker pull docker.io/openim/openim-chat:latest + ``` + +3. Run the `docker images` command to confirm that the image has been successfully pulled. + +This concludes OpenIM's image management strategy and the steps for pulling images. If you have any questions, please feel free to ask. \ No newline at end of file diff --git a/docs/conversions/version.md b/docs/conversions/version.md index a421dd549..bf1062b77 100644 --- a/docs/conversions/version.md +++ b/docs/conversions/version.md @@ -54,4 +54,8 @@ git merge release-v3.1 git push origin main ``` -Remember, communication with your team is key throughout this process, keeping everyone up-to-date with the changes being made. \ No newline at end of file +Remember, communication with your team is key throughout this process, keeping everyone up-to-date with the changes being made. + + +## Docker images version management +