forked from freeleaps/freeleaps-pub
fix(devbox): fix the requirement import
This commit is contained in:
parent
273945981e
commit
ddc0afe59a
@ -52,7 +52,6 @@ exit_with_message() {
|
||||
exit $code
|
||||
}
|
||||
|
||||
|
||||
detect_os() {
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
echo "darwin"
|
||||
@ -65,7 +64,6 @@ detect_os() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Add a key-value pair to the args array
|
||||
add_arg() {
|
||||
local key="$1"
|
||||
@ -91,7 +89,6 @@ get_arg() {
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
devbox_init_guidance() {
|
||||
printf "Welcome to DevBox CLI!\n\n"
|
||||
# if $1 is empty, then ask user select a choice or match user input $1 action to be product_id
|
||||
@ -231,7 +228,6 @@ devbox_usage() {
|
||||
echo
|
||||
}
|
||||
|
||||
|
||||
# :command.usage
|
||||
devbox_init_usage() {
|
||||
if [[ -n $long_usage ]]; then
|
||||
@ -440,7 +436,7 @@ inspect_args() {
|
||||
for key in $sorted_keys; do
|
||||
value=""
|
||||
# Find the value based on the key
|
||||
for i in `seq 0 $((${#args_keys[@]} - 1))`; do
|
||||
for i in $(seq 0 $((${#args_keys[@]} - 1))); do
|
||||
if [ "${args_keys[$i]}" = "$key" ]; then
|
||||
value="${args_values[$i]}"
|
||||
break
|
||||
@ -459,7 +455,7 @@ inspect_args() {
|
||||
log_info "deps:"
|
||||
for key in $sorted_keys; do
|
||||
value=""
|
||||
for i in `seq 0 $((${#deps_keys[@]} - 1))`; do
|
||||
for i in $(seq 0 $((${#deps_keys[@]} - 1))); do
|
||||
if [ "${deps_keys[$i]}" = "$key" ]; then
|
||||
value="${deps_values[$i]}"
|
||||
break
|
||||
@ -481,7 +477,6 @@ inspect_args() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
install_docker() {
|
||||
log_info "Installing Docker..."
|
||||
|
||||
@ -633,14 +628,11 @@ build_local_image() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# used for repository username and password encoding
|
||||
url_encode() {
|
||||
echo "$1" | sed 's/@/%40/g'
|
||||
}
|
||||
|
||||
|
||||
|
||||
###############################################
|
||||
# Initialize the development environment
|
||||
###############################################
|
||||
@ -908,7 +900,6 @@ EOF
|
||||
|
||||
}
|
||||
|
||||
|
||||
###############################################
|
||||
# Backend compilation and startup logic
|
||||
###############################################
|
||||
@ -997,7 +988,7 @@ docker exec -i "$DEVBOX_NAME" bash <<EOF
|
||||
# Check if it's the first time by verifying if the backend dependencies have been installed
|
||||
if [ ! -f "/home/devbox/.backend_deps_installed" ]; then
|
||||
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') Install backend dependencies..."
|
||||
pip install -r /home/devbox/freeleaps/apps/requirements.txt
|
||||
pip install -r /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||
if ! pip show async_timeout; then
|
||||
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') async_timeout is missing. Installing..."
|
||||
pip install async_timeout
|
||||
@ -1007,10 +998,10 @@ docker exec -i "$DEVBOX_NAME" bash <<EOF
|
||||
mkdir -p /home/devbox/tmp
|
||||
|
||||
## Backup the requirements.txt file
|
||||
cp /home/devbox/freeleaps/apps/requirements.txt /home/devbox/tmp/requirements.txt.bak
|
||||
cp /home/devbox/freeleaps/apps/freeleaps/requirements.txt /home/devbox/tmp/requirements.txt.bak
|
||||
|
||||
|
||||
ORIGINAL_REQ="/home/devbox/freeleaps/apps/requirements.txt"
|
||||
ORIGINAL_REQ="/home/devbox/freeleaps/apps/freeleaps/requirements.txt"
|
||||
NEW_REQ="/home/devbox/tmp/requirements.txt"
|
||||
|
||||
# Check if /home/devbox/tmp/requirements.txt exists, if yes, remove it
|
||||
@ -1043,11 +1034,11 @@ docker exec -i "$DEVBOX_NAME" bash <<EOF
|
||||
|
||||
if [ \$IS_NEW_REQ_ADDED -eq 1 ]; then
|
||||
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') Reinstalling dependencies..."
|
||||
pip install -r /home/devbox/freeleaps/apps/requirements.txt
|
||||
pip install -r /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||
fi
|
||||
# Undo update for /home/devbox/freeleaps/apps/requirements.txt
|
||||
rm /home/devbox/freeleaps/apps/requirements.txt
|
||||
mv /home/devbox/tmp/requirements.txt.bak /home/devbox/freeleaps/apps/requirements.txt
|
||||
rm /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||
mv /home/devbox/tmp/requirements.txt.bak /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||
|
||||
touch /home/devbox/.backend_deps_installed
|
||||
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') Run backend service..."
|
||||
@ -1057,7 +1048,7 @@ docker exec -i "$DEVBOX_NAME" bash <<EOF
|
||||
# Check if all dependencies are installed, if not, install them
|
||||
if ! pip check; then
|
||||
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') Some dependencies are missing. Reinstalling..."
|
||||
pip install -r /home/devbox/freeleaps/apps/requirements.txt
|
||||
pip install -r /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||
fi
|
||||
|
||||
# pip install async_timeout if not installed
|
||||
@ -1071,7 +1062,7 @@ docker exec -i "$DEVBOX_NAME" bash <<EOF
|
||||
mkdir -p /home/devbox/tmp
|
||||
|
||||
## Backup the requirements.txt file
|
||||
cp /home/devbox/freeleaps/apps/requirements.txt /home/devbox/tmp/requirements.txt.bak
|
||||
cp /home/devbox/freeleaps/apps/freeleaps/requirements.txt /home/devbox/tmp/requirements.txt.bak
|
||||
|
||||
|
||||
ORIGINAL_REQ="/home/devbox/freeleaps/apps/requirements.txt"
|
||||
@ -1107,8 +1098,8 @@ docker exec -i "$DEVBOX_NAME" bash <<EOF
|
||||
fi
|
||||
|
||||
# Undo update for /home/devbox/freeleaps/apps/requirements.txt
|
||||
rm /home/devbox/freeleaps/apps/requirements.txt
|
||||
mv /home/devbox/tmp/requirements.txt.bak /home/devbox/freeleaps/apps/requirements.txt
|
||||
rm /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||
mv /home/devbox/tmp/requirements.txt.bak /home/devbox/freeleaps/apps/freeleaps/requirements.txt
|
||||
|
||||
# Check if the backend service is already running
|
||||
SERVICE_API_ACCESS_PORT=\$(cat /home/devbox/.devbox-backend-port)
|
||||
@ -1764,7 +1755,6 @@ devbox_init_command() {
|
||||
sudo apt-get install docker-compose -y
|
||||
fi
|
||||
|
||||
|
||||
# 3.2 Check disk space
|
||||
local free_space_kb
|
||||
free_space_kb="$(df -Pk "$HOME" | awk 'END{print $4}')"
|
||||
@ -1870,8 +1860,6 @@ devbox_init_command() {
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
local devbox_full_image="${DEVBOX_REPO}/${DEVBOX_IMAGE}:${DEVBOX_TAG}"
|
||||
|
||||
# Check local and remote version. User doesn't need to rebuild devbox if local version is consistent with remote version
|
||||
@ -2170,12 +2158,10 @@ export WORKING_HOME="$WORKING_HOME"
|
||||
# Save $USE_CUSTOM_REPOSITORY url to .custom-repository file
|
||||
echo "$USE_CUSTOM_REPOSITORY" >"$WORKING_HOME/.custom-repository"
|
||||
|
||||
|
||||
# If USE_CUSTOM_REPOSITORY is not empty, initialize the custom repository completed
|
||||
if [[ -n "$USE_CUSTOM_REPOSITORY" ]]; then
|
||||
# Remove the ':' and password from USE_CUSTOM_REPOSITORY
|
||||
|
||||
|
||||
echo
|
||||
echo "==========================================================="
|
||||
echo
|
||||
@ -2231,7 +2217,6 @@ if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then
|
||||
exit_with_message " Failed to extract gitea data backup, please check the backup file." 1
|
||||
fi
|
||||
|
||||
|
||||
# Copy gitea data to the gitea container
|
||||
GITEA_HOST_DIR="${WORKING_HOME}/freeleaps2-gitea"
|
||||
|
||||
@ -2256,7 +2241,6 @@ if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then
|
||||
exit_with_message " Failed to copy gitea data, please check the data directories." 1
|
||||
fi
|
||||
|
||||
|
||||
mkdir -p ${WORKING_HOME}/logs
|
||||
|
||||
# for each component create log directory
|
||||
@ -2267,7 +2251,6 @@ if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then
|
||||
done
|
||||
# Check if FORCE_INIT is set, if not just docker compose up or docker-compose up --force
|
||||
|
||||
|
||||
# Start Gitea, MongoDB, RabbitMQ and other components containers
|
||||
log_info "start Gitea, MongoDB, RabbitMQ and other components containers"
|
||||
|
||||
@ -2291,7 +2274,6 @@ if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then
|
||||
redis_container_id=$(docker ps --no-trunc -a --filter "name=^freeleaps2-redis$" --format "{{.ID}}")
|
||||
echo "$redis_container_id" >"$WORKING_HOME/.redis-instance"
|
||||
|
||||
|
||||
# Get all components container ids and save to .component-instance file
|
||||
for component in "${start_components[@]}"; do
|
||||
tmp_container_id=$(docker ps --no-trunc -a --filter "name=^$component$" --format "{{.ID}}")
|
||||
@ -2337,8 +2319,6 @@ pushd $WORKING_HOME
|
||||
|
||||
IS_START_FRONTEND=false
|
||||
|
||||
|
||||
|
||||
# Make a user input (Y/N) to continue pull freeleaps.com code and start if N then exit
|
||||
echo
|
||||
read -p "Do you want to continue to pull freeleaps.com code and start the services? (Y/N): " user_input
|
||||
@ -2364,7 +2344,6 @@ fi
|
||||
|
||||
IS_START_FRONTEND=true
|
||||
|
||||
|
||||
# Run banckend service and frontend service in the container
|
||||
compile_backend_service
|
||||
compile_frontend_service
|
||||
@ -2591,7 +2570,6 @@ devbox_deinit_command() {
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# Clear the DevBox container logs
|
||||
if [[ "$CLEAR_LOGS" == "true" ]]; then
|
||||
log_info "Clearing logs in $WORKING_HOME/logs..."
|
||||
@ -2787,8 +2765,6 @@ devbox_start_command() {
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
# Check if $FREELEAPS_ENDPOINT is not empty and start the frontend and backend services
|
||||
if [[ "$FREELEAPS_ENDPOINT" != "" ]]; then
|
||||
# Sleep for 10 seconds to allow the services to start and echo 10 seconds increase from 1 to 10 in each second
|
||||
@ -2892,7 +2868,6 @@ devbox_stop_command() {
|
||||
stoped_freeleaps_service_names+=("backend")
|
||||
fi
|
||||
|
||||
|
||||
# Combine the stoped_freeleaps_service_names array to a string with "and" if there are more than one service
|
||||
if [[ "${#stoped_freeleaps_service_names[@]}" -gt 1 ]]; then
|
||||
stoped_freeleaps_service_names="frontend and backend"
|
||||
@ -2900,12 +2875,10 @@ devbox_stop_command() {
|
||||
stoped_freeleaps_service_names="${stoped_freeleaps_service_names[0]}"
|
||||
fi
|
||||
|
||||
|
||||
exit_message="Stopped Freeleaps $stoped_freeleaps_service_names services successfully."
|
||||
exit_with_message "$exit_message" 0
|
||||
fi
|
||||
|
||||
|
||||
# If the DevBox container is not running, exit
|
||||
if [[ -z "$COMPONENT" ]]; then
|
||||
COMPONENTS=("mongodb" "rabbitmq" "gitea" "redis" "devbox")
|
||||
@ -2972,7 +2945,6 @@ devbox_stop_command() {
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
exit_with_message "Stopped Freeleaps services successfully. " 0
|
||||
|
||||
}
|
||||
@ -3204,7 +3176,6 @@ devbox_restart_command() {
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
exit_with_message " DevBox services restarted successfully." 0
|
||||
}
|
||||
|
||||
@ -3327,7 +3298,6 @@ parse_requirements() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
# :command.parse_requirements
|
||||
devbox_init_parse_requirements() {
|
||||
# :command.fixed_flags_filter
|
||||
@ -3574,7 +3544,6 @@ devbox_init_parse_requirements() {
|
||||
add_arg '--arch' "$current_arch"
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "$(get_arg '--devbox-container-name')" ]; then
|
||||
add_arg '--devbox-container-name' "devbox"
|
||||
fi
|
||||
@ -3623,7 +3592,6 @@ devbox_init_parse_requirements() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# :command.parse_requirements
|
||||
devbox_deinit_parse_requirements() {
|
||||
# :command.fixed_flags_filter
|
||||
@ -3748,7 +3716,6 @@ devbox_start_parse_requirements() {
|
||||
exit
|
||||
;;
|
||||
|
||||
|
||||
*)
|
||||
break
|
||||
;;
|
||||
@ -3924,7 +3891,6 @@ devbox_status_parse_requirements() {
|
||||
fi
|
||||
;;
|
||||
|
||||
|
||||
-?*)
|
||||
printf "invalid option: %s\n" "$key" >&2
|
||||
exit 1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user