feat: fix openim ci and deployment

Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
This commit is contained in:
Xinwei Xiong(cubxxw)
2023-10-20 00:56:50 +08:00
parent 7e63800dee
commit 035afff03e
21 changed files with 74 additions and 756 deletions
+2
View File
@@ -37,6 +37,8 @@ readonly ipv6regex='(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:
clear
. $(dirname ${BASH_SOURCE})/lib/util.sh
openim::util::ensure-bash-version
trap 'openim::util::onCtrlC' INT
function openim::util::onCtrlC() {
+1 -5
View File
@@ -19,11 +19,7 @@ source "${OPENIM_ROOT}/scripts/install/common.sh"
cd "$OPENIM_ROOT"
if command -v docker-compose &> /dev/null; then
docker-compose ps
else
docker compose ps
fi
openim::util::check_docker_and_compose_versions
progress() {
local _main_pid="$1"
+1 -7
View File
@@ -30,13 +30,7 @@ openim::util::ensure_docker_daemon_connectivity
DOCKER_COMPOSE_COMMAND=
# Check if docker-compose command is available
if command -v docker compose &> /dev/null
then
openim::log::info "docker compose command is available"
DOCKER_COMPOSE_COMMAND="docker compose"
else
DOCKER_COMPOSE_COMMAND="docker-compose"
fi
openim::util::check_docker_and_compose_versions
pushd "${OPENIM_ROOT}"
${DOCKER_COMPOSE_COMMAND} stop
+1 -11
View File
@@ -51,17 +51,7 @@ execute_scripts() {
"${OPENIM_ROOT}"/scripts/env_check.sh
}
# Start docker compose
start_docker_compose() {
openim::log::info "Checking if docker-compose command is available"
if command -v docker-compose &> /dev/null; then
docker-compose up -d
else
docker compose up -d
fi
"${OPENIM_ROOT}"/scripts/docker-check-service.sh
}
openim::util::check_docker_and_compose_versions
main() {
load_env
+37
View File
@@ -250,6 +250,39 @@ openim::util::host_arch() {
echo "${host_arch}"
}
# Define a bash function to check the versions of Docker and Docker Compose
openim::util::check_docker_and_compose_versions() {
# Define the required versions of Docker and Docker Compose
required_docker_version="20.10.0"
required_compose_version="2.0"
# Get the currently installed Docker version
installed_docker_version=$(docker --version | awk '{print $3}' | sed 's/,//')
# Check if the installed Docker version matches the required version
if [[ "$installed_docker_version" < "$required_docker_version" ]]; then
echo "Docker version mismatch. Installed: $installed_docker_version, Required: $required_docker_version"
return 1
fi
# Check if the docker compose sub-command is available
if ! docker compose version &> /dev/null; then
echo "Docker does not support the docker compose sub-command"
return 1
fi
# Get the currently installed Docker Compose version
installed_compose_version=$(docker compose version --short)
# Check if the installed Docker Compose version matches the required version
if [[ "$installed_compose_version" < "$required_compose_version" ]]; then
echo "Docker Compose version mismatch. Installed: $installed_compose_version, Required: $required_compose_version"
return 1
fi
}
# The `openim::util::check_ports` function analyzes the state of processes based on given ports.
# It accepts multiple ports as arguments and prints:
# 1. The state of the process (whether it's running or not).
@@ -1321,3 +1354,7 @@ function openim::util::gen_os_arch() {
exit 1
fi
}
if [[ "$*" =~ openim::util:: ]];then
eval $*
fi
+3 -14
View File
@@ -21,7 +21,6 @@
#
DOCKER := docker
DOCKER_SUPPORTED_API_VERSION ?= 1.32|1.40|1.41|1.42
# read: https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/images.md
REGISTRY_PREFIX ?= ghcr.io/openimsdk
@@ -75,22 +74,13 @@ image.docker-buildx:
## image.verify: Verify docker version
.PHONY: image.verify
image.verify:
$(eval API_VERSION := $(shell $(DOCKER) version | grep -E 'API version: {1,6}[0-9]' | head -n1 | awk '{print $$3} END { if (NR==0) print 0}' ))
$(eval PASS := $(shell echo "$(API_VERSION) > $(DOCKER_SUPPORTED_API_VERSION)" | bc))
@if [ $(PASS) -ne 1 ]; then \
$(DOCKER) -v ;\
echo "Unsupported docker version. Docker API version should be greater than $(DOCKER_SUPPORTED_API_VERSION)"; \
exit 1; \
fi
@$(ROOT_DIR)/scripts/lib/util.sh openim::util::check_docker_and_compose_versions
## image.daemon.verify: Verify docker daemon experimental features
.PHONY: image.daemon.verify
image.daemon.verify:
$(eval PASS := $(shell $(DOCKER) version | grep -q -E 'Experimental: {1,5}true' && echo 1 || echo 0))
@if [ $(PASS) -ne 1 ]; then \
echo "Experimental features of Docker daemon is not enabled. Please add \"experimental\": true in '/etc/docker/daemon.json' and then restart Docker daemon."; \
exit 1; \
fi
@$(ROOT_DIR)/scripts/lib/util.sh openim::util::ensure_docker_daemon_connectivity
@$(ROOT_DIR)/scripts/lib/util.sh openim::util::ensure-docker-buildx
# If you wish built the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
@@ -124,7 +114,6 @@ image.build.%: go.build.%
fi
@rm -rf $(TMP_DIR)/$(IMAGE)
# https://docs.docker.com/build/building/multi-platform/
# busybox image supports amd64, arm32v5, arm32v6, arm32v7, arm64v8, i386, ppc64le, and s390x
## image.buildx.%: Build docker images with buildx