Skip to content

Commit

Permalink
feat: add test file
Browse files Browse the repository at this point in the history
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
  • Loading branch information
cubxxw committed Sep 3, 2023
1 parent 6db9e2c commit 3f2d771
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.dockerignore

# Ignore build artifacts
_output/
# _output/
logs/

# Ignore non-essential documentation
Expand Down
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
USER=root
PASSWORD=openIM123
MINIO_ENDPOINT=http://127.0.0.1:10005
API_URL=http://14.153.17.42:10002
API_URL=http://\;\;\ communications\ error\ to\ 216.239.36.10#53:\ timed\ out14.153.17.42:10002
DATA_DIR=/root/workspaces/openim/openim-server
4 changes: 4 additions & 0 deletions build/images/openim-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@ ENV PORT 10002

EXPOSE ${PORT}

RUN cp ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-api /usr/bin/openim-api

ENTRYPOINT ["/usr/bin/openim-api","-c" ${SERVER_WORKDIR}/config"]
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-api --port ${PORT} -c ${SERVER_WORKDIR}/config"]
8 changes: 8 additions & 0 deletions build/images/openim-api/Dockerfile.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ghcr.io/openim-sigs/openim-bash-image:latest

COPY openim-api /usr/bin/

# nosemgrep: dockerfile.security.missing-user.missing-user
ENTRYPOINT ["/usr/bin/openim-api"]
# nosemgrep: dockerfile.security.missing-user.missing-user
CMD ["--help"]
8 changes: 5 additions & 3 deletions scripts/check-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ source "${OPENIM_ROOT}/scripts/install/common.sh"

OPENIM_VERBOSE=4

openim::log::info "\n# Begin to check all openim service"

# OpenIM status
# Elegant printing function
print_services_and_ports() {
Expand Down Expand Up @@ -55,7 +57,7 @@ print_services_and_ports OPENIM_DEPENDENCY_TARGETS OPENIM_DEPENDENCY_PORT_TARGET

# OpenIM check
echo "++ The port being checked: ${OPENIM_SERVER_PORT_LISTARIES[@]}"
echo "## Check all dependent service ports"
openim::log::info "\n## Check all dependent service ports"
echo "+++ The port being checked: ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]}"

set +e
Expand All @@ -69,10 +71,10 @@ else
fi
set -e

echo -e "\n## Check OpenIM service name"
openim::log::info "\n## Check OpenIM service name"
. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check

echo -e "\n## Check all OpenIM service ports"
openim::log::info "\n## Check all OpenIM service ports"
echo "+++ The port being checked: ${OPENIM_SERVER_PORT_LISTARIES[@]}"
openim::util::check_ports ${OPENIM_SERVER_PORT_LISTARIES[@]}
if [[ $? -ne 0 ]]; then
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 @@ -24,6 +24,8 @@ set -o pipefail
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/install/common.sh"

openim::log::info "\n# Use Docker to start all openim service"

trap 'openim::util::onCtrlC' INT

"${OPENIM_ROOT}"/scripts/start-all.sh
Expand Down
2 changes: 2 additions & 0 deletions scripts/init-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ set -o pipefail
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd -P)
source "${OPENIM_ROOT}/scripts/install/common.sh"

openim::log::info "\n# Begin Install OpenIM Config"

for file in "${OPENIM_SERVER_TARGETS[@]}"; do
VARNAME="$(echo $file | tr '[:lower:]' '[:upper:]' | tr '.' '_' | tr '-' '_')"
VARVALUE="$OPENIM_OUTPUT_HOSTBIN/$file"
Expand Down
1 change: 1 addition & 0 deletions scripts/install/openim-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ readonly OPENIM_TOOLS_PRE_START_NAME_LISTARIES=("${OPENIM_TOOLS_PRE_START_NAME_T
openim::tools::post_start_name() {
local targets=(
infra
versionchecker
)
echo "${targets[@]}"
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/lib/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,15 @@ openim::util::check_ports() {

# Print information about ports whose processes are not running.
if [[ ${#not_started[@]} -ne 0 ]]; then
openim::log::info "### Not started ports:"
openim::log::info "\n### Not started ports:"
for port in "${not_started[@]}"; do
openim::log::error "Port $port is not started."
done
fi

# Print information about ports whose processes are running.
if [[ ${#started[@]} -ne 0 ]]; then
openim::log::info "### Started ports:"
openim::log::info "\n### Started ports:"
for info in "${started[@]}"; do
openim::log::info "$info"
done
Expand Down
6 changes: 6 additions & 0 deletions scripts/start-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ set -o pipefail
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/install/common.sh"

openim::log::info "\n# Begin to start all openim service scripts"

set +o errexit
openim::golang::check_openim_binaries
if [[ $? -ne 0 ]]; then
Expand Down Expand Up @@ -68,10 +70,14 @@ function execute_scripts() {

# TODO Prelaunch tools, simple for now, can abstract functions later
TOOLS_START_SCRIPTS_PATH=${START_SCRIPTS_PATH}/openim-tools.sh

openim::log::info "\n## Pre Starting OpenIM services"
${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start

openim::log::info "\n## Starting OpenIM services"
execute_scripts

openim::log::info "\n## Post Starting OpenIM services"
${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start

openim::log::success "✨ All OpenIM services have been successfully started!"
2 changes: 2 additions & 0 deletions scripts/stop-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..

source "${OPENIM_ROOT}/scripts/install/common.sh"

openim::log::info "\n# Begin to stop all openim service"

echo "++ Ready to stop port: ${OPENIM_SERVER_PORT_LISTARIES[@]}"

openim::util::stop_services_on_ports ${OPENIM_SERVER_PORT_LISTARIES[@]}
Expand Down
17 changes: 17 additions & 0 deletions test.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# FROM ghcr.io/openim-sigs/openim-bash-image:latest
FROM ghcr.io/openim-sigs/openim-bash-image:latest

WORKDIR /openim/openim-server

COPY ./_output/bin/platforms /openim/openim-server/_output/bin/platforms
COPY ./config /openim/openim-server/config

ENV PORT 10002

EXPOSE 10002

RUN cp -r ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-api /usr/bin/openim-api

ENTRYPOINT ["/usr/bin/openim-api","-c","${SERVER_WORKDIR}/config"]

CMD ["--port 10002"]

0 comments on commit 3f2d771

Please sign in to comment.