Skip to content

Commit

Permalink
fix: dockerfile path (#120)
Browse files Browse the repository at this point in the history
* fix: dockerfile path

Signed-off-by: Xinwei Xiong(cubxxw-openim) <[email protected]>

* fix: gorelease quest

Signed-off-by: Xinwei Xiong(cubxxw-openim) <[email protected]>

* fix: gorelease quest

Signed-off-by: Xinwei Xiong(cubxxw-openim) <[email protected]>

* fix: docker images optimize

Signed-off-by: Xinwei Xiong(cubxxw-openim) <[email protected]>

* fix: docker images optimize

Signed-off-by: Xinwei Xiong(cubxxw-openim) <[email protected]>

* fix: scripts path

Signed-off-by: Xinwei Xiong(cubxxw-openim) <[email protected]>

* build: release images v1.1.1-beta.1

Signed-off-by: Xinwei Xiong(cubxxw-openim) <[email protected]>

* build: value docker compose file

Signed-off-by: Xinwei Xiong(cubxxw-openim) <[email protected]>

* build: value docker compose file

Signed-off-by: Xinwei Xiong(cubxxw-openim) <[email protected]>

* build: value docker compose file

Signed-off-by: Xinwei Xiong(cubxxw-openim) <[email protected]>

---------

Signed-off-by: Xinwei Xiong(cubxxw-openim) <[email protected]>
  • Loading branch information
cubxxw authored Aug 4, 2023
1 parent e2f9719 commit 27771c7
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 46 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ COPY --from=builder /openim/openim-chat/_output/bin/platforms /openim/openim-cha
COPY --from=builder ${OPENIM_CHAT_CMDDIR} /openim/openim-chat/scripts
COPY --from=builder ${OPENIM_CHAT_CONFIG_NAME} /openim/openim-chat/config/config.yaml

VOLUME ["/openim/openim-chat/logs","/openim/openim-chat/config","/openim/openim-chat/scripts"]
VOLUME ["/openim/openim-chat/_output","/openim/openim-chat/logs","/openim/openim-chat/config","/openim/openim-chat/scripts"]

CMD ${OPENIM_CHAT_CMDDIR}/start_all.sh
CMD ${OPENIM_CHAT_CMDDIR}/docker_start_all.sh
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,21 @@ make all

### Chat Start

```
./scripts/start_all.sh
```
```bash
./scripts/start_all.sh
```

### Chat Detection

```
cd scripts
./check_all.sh
```bash
./scripts/check_all.sh
```

### Chat Stop

```
cd scripts
./stop_all.sh
```
```bash
./scripts/stop_all.sh
```

## Contributing

Expand Down
3 changes: 2 additions & 1 deletion scripts/admin_rpc_start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
#!/bin/bash

# Copyright © 2023 OpenIM open source community. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
3 changes: 2 additions & 1 deletion scripts/build_all_service.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
#!/bin/bash

# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions scripts/build_docker.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

# Copyright © 2023 OpenIM open source community. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
3 changes: 2 additions & 1 deletion scripts/check_all.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
#!/bin/bash

# Copyright © 2023 OpenIM open source community. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
99 changes: 78 additions & 21 deletions scripts/docker_start_all.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/bash
# Copyright © 2023 OpenIM open source community. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -13,28 +13,85 @@
# See the License for the specific language governing permissions and
# limitations under the License.

#Include shell font styles and some basic information
# Include shell font styles and some basic information
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..

${SCRIPTS_ROOT}/start_all.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

sleep 10
time=`date +"%Y-%m-%d %H:%M:%S"`
echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
echo "==========server start time:${time}===========">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
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
$i
done
source "$SCRIPTS_ROOT/style_info.sh"
source "$SCRIPTS_ROOT/path_info.sh"
source "$SCRIPTS_ROOT/function.sh"

printf "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=%s${COLOR_SUFFIX}\n" "$SCRIPTS_ROOT"
printf "${YELLOW_PREFIX}=======>OPENIM_ROOT=%s${COLOR_SUFFIX}\n" "$OPENIM_ROOT"
printf "${YELLOW_PREFIX}=======>pwd=%s${COLOR_SUFFIX}\n" "$PWD"

bin_dir="$BIN_DIR"
logs_dir="$SCRIPTS_ROOT/../logs"

printf "${YELLOW_PREFIX}=======>bin_dir=%s${COLOR_SUFFIX}\n" "$bin_dir"
printf "${YELLOW_PREFIX}=======>logs_dir=%s${COLOR_SUFFIX}\n" "$logs_dir"
printf "${YELLOW_PREFIX}=======>sdk_db_dir=%s${COLOR_SUFFIX}\n" "$sdk_db_dir"

# Service filenames
service_filenames=(
chat-api
admin-api
#rpc
admin-rpc
chat-rpc
)

# Service config port names
service_port_names=(
openImChatApiPort
openImAdminApiPort
#api port name
openImAdminPort
openImChatPort
)

sleep 15
service_prometheus_port_names=()

cd "$SCRIPTS_ROOT"

# Function to kill a service
kill_service() {
local service_name=$1
local pid=$(pgrep -f "$service_name")
if [ -n "$pid" ]; then
echo "$service_name service has been started, pid: $pid"
echo "Killing the service $service_name, pid: $pid"
killall "$service_name"
sleep 0.5
fi
}

for ((i = 0; i < ${#service_filenames[*]}; i++)); do
service_name="${service_filenames[$i]}"
kill_service "$service_name"
cd "$SCRIPTS_ROOT"

# Get the rpc ports from the configuration file
readarray -t portList < "$config_path"
service_ports=()
for line in "${portList[@]}"; do
if [[ $line == *"${service_port_names[$i]}"* ]]; then
port=$(echo "$line" | awk -F ':' '{print $NF}')
service_ports+=("$port")
fi
done

# Start related rpc services based on the number of ports
for port in "${service_ports[@]}"; do
# Start the service in the background
cmd="$bin_dir/$service_name -port $port --config_folder_path $config_path"
if [[ $i -eq 0 || $i -eq 1 ]]; then
cmd="$bin_dir/$service_name -port $port --config_folder_path $config_path"
fi
echo "$cmd"
nohup "$cmd" >> "${logs_dir}/openIM.log" 2>&1 &
sleep 1
done
done

#fixme prevents the openIM service exit after execution in the docker container
tail -f /dev/null
sleep infinity
3 changes: 2 additions & 1 deletion scripts/function.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
#!/bin/bash

# Copyright © 2023 OpenIM open source community. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion scripts/githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/bash
# Copyright © 2023 OpenIMSDK.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion scripts/githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/bash
# Copyright © 2023 OpenIMSDK.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion scripts/githooks/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/bash
# Copyright © 2023 OpenIMSDK.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion scripts/path_info.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/bash

#Don't put the space between "="

Expand Down
2 changes: 1 addition & 1 deletion scripts/start_all.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/bash
# Copyright © 2023 OpenIM open source community. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion scripts/stop_all.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/bash
# Copyright © 2023 OpenIM open source community. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion scripts/style_info.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
3 changes: 1 addition & 2 deletions test/common.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -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.

0 comments on commit 27771c7

Please sign in to comment.