From e182d5e7dffe1e3de8bbdb86bf0b411de5d00adf Mon Sep 17 00:00:00 2001 From: Xinwei Xiong <3293172751NSS@gmail.com> Date: Sun, 21 Jan 2024 12:13:31 +0800 Subject: [PATCH] feat: optimize mac deployment scripts (#1795) --- docker-compose.yml | 24 ++++++++++- .../contrib/mac-developer-deployment-guide.md | 43 ++++++++++++++++--- 2 files changed, 61 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 24735abe9..6d0f3c25a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -123,7 +123,7 @@ services: ipv4_address: ${OPENIM_WEB_NETWORK_ADDRESS:-172.28.0.7} ### TODO: Uncomment, or deploy using openim docker: https://github.com/openimsdk/openim-docker - # Uncomment and configure the following services as needed +### Uncomment and configure the following services as needed # openim-server: # image: ${IMAGE_REGISTRY:-ghcr.io/openimsdk}/openim-server:${SERVER_IMAGE_VERSION:-main} @@ -172,6 +172,23 @@ services: # server: # ipv4_address: ${OPENIM_SERVER_NETWORK_ADDRESS:-172.28.0.8} +### TODO: mysql is required to deploy the openim-chat component + # mysql: + # image: mysql:${MYSQL_IMAGE_VERSION:-5.7} + # platform: linux/amd64 + # ports: + # - "${MYSQL_PORT:-13306}:3306" + # container_name: mysql + # volumes: + # - "${DATA_DIR:-./}/components/mysql/data:/var/lib/mysql" + # - "/etc/localtime:/etc/localtime" + # environment: + # MYSQL_ROOT_PASSWORD: "${MYSQL_PASSWORD:-openIM123}" + # restart: always + # networks: + # server: + # ipv4_address: ${MYSQL_NETWORK_ADDRESS:-172.28.0.15} + # openim-chat: # image: ${IMAGE_REGISTRY:-ghcr.io/openimsdk}/openim-chat:${CHAT_IMAGE_VERSION:-main} # container_name: openim-chat @@ -199,6 +216,11 @@ services: # - "${DATA_DIR:-./}/components/openim-chat/config:/openim/openim-chat/config" # restart: always # # user: root:root + # depends_on: + # - mysql + # - kafka + # - redis + # - zookeeper # logging: # driver: json-file # options: diff --git a/docs/contrib/mac-developer-deployment-guide.md b/docs/contrib/mac-developer-deployment-guide.md index 40ef4b8be..69e4e7503 100644 --- a/docs/contrib/mac-developer-deployment-guide.md +++ b/docs/contrib/mac-developer-deployment-guide.md @@ -47,25 +47,58 @@ Homebrew is an essential package manager for macOS. Install it using: ### Forking and Cloning the Repository -1. Fork the OpenIM repository on GitHub to your account. -2. Clone your fork to your local machine: +To optimize and add logic to your instructions, particularly regarding deploying on a Mac, you can modify them as follows: + +1. **Fork the OpenIM Repository**: Fork the OpenIM repository on GitHub to your account. + +2. **Clone Your Fork to Your Local Machine**: + Open your terminal and execute the following commands: ```sh + # Clone the repository git clone https://github.com//open-im-server.git - # The Docker bridging network mode for Mac is slightly different and needs to be set: + + # Set Docker bridging network mode for Mac export DOCKER_BRIDGE_SUBNET=127.0.0.0/16 + # Set OpenIM IP export OPENIM_IP= - # Init Config + + # Initialize configuration make init - # Start Components + # Start components using Docker docker compose up -d # Start OpenIM Server make start ``` +3. **Additional Steps for Mac Deployment**: + If you are deploying on a Mac and wish to use the chat feature, you need to modify the `docker-compose` file. Specifically, you'll need to uncomment the sections related to `openim-chat` and `mysql`. + + Here's how to do it: + + - Open the `docker-compose.yml` file in a text editor. + - Find the sections for `openim-chat` and `mysql`. + - Remove the comment marks (`#`) at the beginning of the lines in these sections to enable them. + - Save the file after making these changes. + +4. **Update and Restart Services**: + After modifying the `docker-compose` file, you need to update and restart the services to apply these changes. Run the following command in your terminal: + + ```sh + # Update and restart services + docker compose up -d + + # Check openim-chat start + docker compose logs openim-chat + ``` + + This command will re-read the `docker-compose.yml` file, apply the new configuration, and restart the necessary containers. + +Remember, replacing `` and `` with your actual GitHub username and desired IP address for OpenIM is crucial. These steps should streamline the setup process, particularly for Mac users wishing to use the chat feature. + ### Setting Up the Devcontainer `Devcontainers` provide a Docker-based isolated development environment.