Skip to content

Commit

Permalink
feat: support mac deployment and optimization make check (#1570)
Browse files Browse the repository at this point in the history
* feat: add openim server code

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* feat: add openim env

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* fix: add openim scripts check and mac support ss comment

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* fix: add mac os

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* fix: add mac os

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* fix: add mac os

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* fix: add mac os

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* fix: add mac os

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* fix: add mac os

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* fix: add mac os

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* fix: add mac os

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* fix: add mac os

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* fix: add mac os

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* fix: add mac os

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* fix: add mac os

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* fix: add mac os

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

---------

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>
  • Loading branch information
cubxxw committed Dec 16, 2023
1 parent 2cef0f6 commit c2dfc37
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 116 deletions.
53 changes: 48 additions & 5 deletions .github/workflows/openimci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ jobs:
sudo make install
execute-scripts:
name: Execute OpenIM script on ${{ matrix.os }}
name: Execute OpenIM Script On ${{ matrix.os }}
runs-on: ${{ matrix.os }}
environment:
name: openim
strategy:
matrix:
go_version: ["1.20"]
os: ["ubuntu-latest"]
os: ["ubuntu-latest", "macos-latest"]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -154,25 +154,68 @@ jobs:
version: '3.x' # If available, use the latest major version that's compatible
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Docker Operations
# - name: Install latest Bash (macOS only)
# if: runner.os == 'macOS'
# run: |
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# brew update

# brew install bash
# brew install gnu-sed

# echo "/usr/local/bin" >> $GITHUB_PATH
# echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH
# continue-on-error: true

- name: Set up Docker for Ubuntu
if: runner.os == 'Linux'
run: |
sudo make init
sudo docker compose up -d
sudo sleep 20
- name: Module Operations
# - name: Set up Docker for macOS
# if: runner.os == 'macOS'
# run: |
# brew install --cask docker
# open /Applications/Docker.app

# sleep 10
# docker-compose --version || brew install docker-compose

# docker-compose up -d
# sleep 20

- name: Module Operations for Ubuntu
if: runner.os == 'Linux'
run: |
sudo make tidy
sudo make tools.verify.go-gitlint
- name: Build, Start, Check Services and Print Logs
# - name: Module Operations for macOS
# if: runner.os == 'macOS'
# run: |
# make tidy
# make tools.verify.go-gitlint

- name: Build, Start, Check Services and Print Logs for Ubuntu
if: runner.os == 'Linux'
run: |
sudo make init && \
sudo make build && \
sudo make start && \
sudo make check || \
(echo "An error occurred, printing logs:" && sudo cat ./_output/logs/* 2>/dev/null)
# - name: Build, Start, Check Services and Print Logs for macOS
# if: runner.os == 'macOS'
# run: |
# make init && \
# make build && \
# make start && \
# make check || \
# (echo "An error occurred, printing logs:" && sudo cat ./_output/logs/* 2>/dev/null)

openim-test-build-image:
name: Build OpenIM Docker Image
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions config/templates/config.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ api:
# minio.signEndpoint is minio public network address
object:
enable: "minio"
apiURL: "http://172.28.0.1:10002"
apiURL: "http://14.155.64.202:10002"
minio:
bucket: "openim"
endpoint: "http://172.28.0.1:10005"
accessKeyID: "root"
secretAccessKey: "openIM123"
sessionToken: ''
signEndpoint: "http://172.28.0.1:10005"
signEndpoint: "http://14.155.64.202:10005"
publicRead: false
cos:
bucketURL: https://temp-1252357374.cos.ap-chengdu.myqcloud.com
Expand Down Expand Up @@ -186,7 +186,7 @@ rpcRegisterName:
# Whether to output in json format
# Whether to include stack trace in logs
log:
storageLocation: ../logs/
storageLocation: /data/workspaces/open-im-server/logs/
rotationTime: 24
remainRotationCount: 2
remainLogLevel: 6
Expand Down
13 changes: 7 additions & 6 deletions config/templates/env.template
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ MINIO_ENDPOINT=http://172.28.0.1:10005

# Base URL for the application programming interface (API).
# Default: API_URL=http://172.28.0.1:10002
API_URL=http://172.28.0.1:10002
API_URL=http://14.155.64.202:10002

# Directory path for storing data files or related information.
# Default: DATA_DIR=./
DATA_DIR=./
DATA_DIR=/data/workspaces/open-im-server

# Choose the appropriate image address, the default is GITHUB image,
# you can choose docker hub, for Chinese users can choose Ali Cloud
Expand Down Expand Up @@ -200,8 +200,9 @@ API_OPENIM_PORT=10002
# ======================================

# Branch name for OpenIM chat.
# Default: CHAT_BRANCH=main
CHAT_BRANCH=main
# Default: CHAT_IMAGE_VERSION=main
# https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/version.md
CHAT_IMAGE_VERSION=main

# Address or hostname for the OpenIM chat service.
# Default: OPENIM_CHAT_ADDRESS=172.28.0.1
Expand All @@ -221,8 +222,8 @@ OPENIM_CHAT_DATA_DIR=./openim-chat/main
# ======================================

# Branch name for OpenIM server.
# Default: SERVER_BRANCH=main
SERVER_BRANCH=main
# Default: SERVER_IMAGE_VERSION=main
SERVER_IMAGE_VERSION=main

# Port for the OpenIM admin API.
# Default: OPENIM_ADMIN_API_PORT=10009
Expand Down
8 changes: 4 additions & 4 deletions deployments/templates/env-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ API_OPENIM_PORT=${API_OPENIM_PORT}
# ======================================

# Branch name for OpenIM chat.
# Default: CHAT_BRANCH=main
CHAT_BRANCH=${CHAT_BRANCH}
# Default: CHAT_IMAGE_VERSION=main
CHAT_IMAGE_VERSION=${CHAT_IMAGE_VERSION}

# Address or hostname for the OpenIM chat service.
# Default: OPENIM_CHAT_ADDRESS=172.28.0.1
Expand All @@ -221,8 +221,8 @@ OPENIM_CHAT_DATA_DIR=${OPENIM_CHAT_DATA_DIR}
# ======================================

# Branch name for OpenIM server.
# Default: SERVER_BRANCH=main
SERVER_BRANCH=${SERVER_BRANCH}
# Default: SERVER_IMAGE_VERSION=main
SERVER_IMAGE_VERSION=${SERVER_IMAGE_VERSION}

# Port for the OpenIM admin API.
# Default: OPENIM_ADMIN_API_PORT=10009
Expand Down
5 changes: 0 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ services:
ipv4_address: ${MONGO_NETWORK_ADDRESS:-172.28.0.2}

redis:
# image: redis:7.0.0
image: redis:${REDIS_IMAGE_VERSION:-7.0.0}
container_name: redis
ports:
Expand All @@ -53,7 +52,6 @@ services:
ipv4_address: ${REDIS_NETWORK_ADDRESS:-172.28.0.3}

zookeeper:
# image: bitnami/zookeeper:3.8
image: bitnami/zookeeper:${ZOOKEEPER_IMAGE_VERSION:-3.8}
container_name: zookeeper
ports:
Expand All @@ -69,7 +67,6 @@ services:
ipv4_address: ${ZOOKEEPER_NETWORK_ADDRESS:-172.28.0.5}

kafka:
# image: 'bitnami/kafka:3.5.1'
image: 'bitnami/kafka:${KAFKA_IMAGE_VERSION:-3.5.1}'
container_name: kafka
restart: always
Expand All @@ -95,7 +92,6 @@ services:
ipv4_address: ${KAFKA_NETWORK_ADDRESS:-172.28.0.4}

minio:
# image: minio/minio
image: minio/minio:${MINIO_IMAGE_VERSION:-latest}
ports:
- "${MINIO_PORT:-10005}:9000"
Expand All @@ -114,7 +110,6 @@ services:
ipv4_address: ${MINIO_NETWORK_ADDRESS:-172.28.0.6}

openim-web:
# image: ${IMAGE_REGISTRY:-ghcr.io/openimsdk}/openim-web:latest
image: ${IMAGE_REGISTRY:-ghcr.io/openimsdk}/openim-web:${OPENIM_WEB_IMAGE_VERSION:-latest}
container_name: openim-web
environment:
Expand Down
10 changes: 5 additions & 5 deletions docs/contrib/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,18 @@ Docker deployment offers a slightly more intricate template. Within the [openim-
Configuration file modifications can be made by specifying corresponding environment variables, for instance:

```bash
export CHAT_BRANCH="main"
export SERVER_BRANCH="main"
export CHAT_IMAGE_VERSION="main"
export SERVER_IMAGE_VERSION="main"
```

These variables are stored within the [`environment.sh`](https://github.com/OpenIMSDK/openim-docker/blob/main/scripts/install/environment.sh) configuration:

```bash
readonly CHAT_BRANCH=${CHAT_BRANCH:-'main'}
readonly SERVER_BRANCH=${SERVER_BRANCH:-'main'}
readonly CHAT_IMAGE_VERSION=${CHAT_IMAGE_VERSION:-'main'}
readonly SERVER_IMAGE_VERSION=${SERVER_IMAGE_VERSION:-'main'}
```

Setting a variable, e.g., `export CHAT_BRANCH="release-v1.3"`, will prioritize `CHAT_BRANCH="release-v1.3"` as the variable value. Ultimately, the chosen image version is determined, and rendering is achieved through `make init` (or `./scripts/init-config.sh`).
Setting a variable, e.g., `export CHAT_IMAGE_VERSION="release-v1.3"`, will prioritize `CHAT_IMAGE_VERSION="release-v1.3"` as the variable value. Ultimately, the chosen image version is determined, and rendering is achieved through `make init` (or `./scripts/init-config.sh`).

> Note: Direct modifications to the `config.yaml` file are also permissible without utilizing `make init`.
Expand Down
6 changes: 2 additions & 4 deletions scripts/check-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ openim::log::info "\n# Begin to check all openim service"
# OpenIM status
# Elegant printing function
print_services_and_ports() {
# 获取数组
declare -g service_names=("${!1}")
declare -g service_ports=("${!2}")
local -n service_names=$1
local -n service_ports=$2

echo "+-------------------------+----------+"
echo "| Service Name | Port |"
Expand All @@ -48,7 +47,6 @@ print_services_and_ports() {
echo "+-------------------------+----------+"
}


# Print out services and their ports
print_services_and_ports OPENIM_SERVER_NAME_TARGETS OPENIM_SERVER_PORT_TARGETS

Expand Down
2 changes: 2 additions & 0 deletions scripts/docker-start-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ openim::log::info "\n# Use Docker to start all openim service"

trap 'openim::util::onCtrlC' INT

"${OPENIM_ROOT}"/scripts/init-config.sh --skip

"${OPENIM_ROOT}"/scripts/start-all.sh

sleep 5
Expand Down
Loading

0 comments on commit c2dfc37

Please sign in to comment.