forked from freeleaps/freeleaps-pub
Update for fixing local component startup command and configuration
This commit is contained in:
parent
4c3c0274cc
commit
b59c43e5fb
@ -153,7 +153,7 @@ devbox_init_usage() {
|
|||||||
echo
|
echo
|
||||||
|
|
||||||
# :flag.usage use local component
|
# :flag.usage use local component
|
||||||
printf " %s\n" "--use-local-component IS_USE_LOCAL_COMPONENT"
|
printf " %s\n" "--use-local-component USE_LOCAL_COMPONENT"
|
||||||
printf " Check if use local component or use online dev environment. (Default: false, use online service) (Optional)\n"
|
printf " Check if use local component or use online dev environment. (Default: false, use online service) (Optional)\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
@ -173,19 +173,19 @@ devbox_init_usage() {
|
|||||||
printf " %s\n" "Default: latest"
|
printf " %s\n" "Default: latest"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# :flag.usage notification image repo
|
# :flag.usage payment image repo
|
||||||
printf " %s\n" "--notification-image-repo NOTIFICATION_IMAGE_REPO"
|
printf " %s\n" "--payment-image-repo PAYMENT_IMAGE_REPO"
|
||||||
printf " Specifies the repository for notification component. (Optional)\n"
|
printf " Specifies the repository for payment component. (Optional)\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# :flag.usage notification image name
|
# :flag.usage payment image name
|
||||||
printf " %s\n" "--notification-image-name NOTIFICATION_IMAGE_NAME"
|
printf " %s\n" "--payment-image-name PAYMENT_IMAGE_NAME"
|
||||||
printf " Specifies the image name for notification component. (Optional)\n"
|
printf " Specifies the image name for payment component. (Optional)\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# :flag.usage notification image tag
|
# :flag.usage payment image tag
|
||||||
printf " %s\n" "--notification-image-tag NOTIFICATION_IMAGE_TAG"
|
printf " %s\n" "--payment-image-tag PAYMENT_IMAGE_TAG"
|
||||||
printf " Specifies the image tag for notification component. (Optional, default=latest)\n"
|
printf " Specifies the image tag for payment component. (Optional, default=latest)\n"
|
||||||
printf " %s\n" "Default: latest"
|
printf " %s\n" "Default: latest"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
@ -436,12 +436,6 @@ devbox_init_command() {
|
|||||||
|
|
||||||
# src/init_command.sh
|
# src/init_command.sh
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
|
||||||
# File: src/init_command.sh
|
|
||||||
# This file implements the `devbox init` command logic.
|
|
||||||
|
|
||||||
# Make sure the function name is `devbox_init_command`.
|
|
||||||
|
|
||||||
echo "==> [INIT] Starting DevBox environment initialization..."
|
echo "==> [INIT] Starting DevBox environment initialization..."
|
||||||
echo
|
echo
|
||||||
|
|
||||||
@ -468,9 +462,9 @@ devbox_init_command() {
|
|||||||
local DEVSVC_IMAGE="$args_devsvc_image_image" # --devsvc-image-image
|
local DEVSVC_IMAGE="$args_devsvc_image_image" # --devsvc-image-image
|
||||||
local DEVSVC_TAG="$args_devsvc_image_tag" # --devsvc-image-tag
|
local DEVSVC_TAG="$args_devsvc_image_tag" # --devsvc-image-tag
|
||||||
|
|
||||||
local NOTIFICATION_REPO="$args_notification_image_repo" # --notification-image-repo
|
local PAYMENT_REPO="$args_payment_image_repo" # --payment-image-repo
|
||||||
local NOTIFICATION_IMAGE="$args_notification_image_image" # --notification-image-image
|
local PAYMENT_IMAGE="$args_payment_image_image" # --payment-image-image
|
||||||
local NOTIFICATION_TAG="$args_notification_image_tag" # --notification-image-tag
|
local PAYMENT_TAG="$args_payment_image_tag" # --payment-image-tag
|
||||||
|
|
||||||
local CONTENT_REPO="$args_content_image_repo" # --content-image-repo
|
local CONTENT_REPO="$args_content_image_repo" # --content-image-repo
|
||||||
local CONTENT_IMAGE="$args_content_image_image" # --content-image-image
|
local CONTENT_IMAGE="$args_content_image_image" # --content-image-image
|
||||||
@ -498,13 +492,13 @@ devbox_init_command() {
|
|||||||
local WORKING_HOME="${args['--working-home']:-${WORKING_HOME:-${HOME}/.devbox}}"
|
local WORKING_HOME="${args['--working-home']:-${WORKING_HOME:-${HOME}/.devbox}}"
|
||||||
local FREELEAPS_USERNAME="${args['--freeleaps-username']}"
|
local FREELEAPS_USERNAME="${args['--freeleaps-username']}"
|
||||||
local FREELEAPS_PASSWORD="${args['--freeleaps-password']}"
|
local FREELEAPS_PASSWORD="${args['--freeleaps-password']}"
|
||||||
local USE_LOCAL_COMPONENT="${args['--use-local-component']:-false}"
|
local USE_LOCAL_COMPONENT="${args['--use-local-component']}"
|
||||||
local DEVSVC_REPO="${args['--devsvc-image-repo']}"
|
local DEVSVC_REPO="${args['--devsvc-image-repo']}"
|
||||||
local DEVSVC_IMAGE="${args['--devsvc-image-name']}"
|
local DEVSVC_IMAGE="${args['--devsvc-image-name']}"
|
||||||
local DEVSVC_TAG="${args['--devsvc-image-tag']}"
|
local DEVSVC_TAG="${args['--devsvc-image-tag']}"
|
||||||
local NOTIFICATION_REPO="${args['--notification-image-repo']}"
|
local PAYMENT_REPO="${args['--payment-image-repo']}"
|
||||||
local NOTIFICATION_IMAGE="${args['--notification-image-name']}"
|
local PAYMENT_IMAGE="${args['--payment-image-name']}"
|
||||||
local NOTIFICATION_TAG="${args['--notification-image-tag']}"
|
local PAYMENT_TAG="${args['--payment-image-tag']}"
|
||||||
local CONTENT_REPO="${args['--content-image-repo']}"
|
local CONTENT_REPO="${args['--content-image-repo']}"
|
||||||
local CONTENT_IMAGE="${args['--content-image-name']}"
|
local CONTENT_IMAGE="${args['--content-image-name']}"
|
||||||
local CONTENT_TAG="${args['--content-image-tag']}"
|
local CONTENT_TAG="${args['--content-image-tag']}"
|
||||||
@ -518,14 +512,20 @@ devbox_init_command() {
|
|||||||
local FORCE_INIT="${args['--force']}"
|
local FORCE_INIT="${args['--force']}"
|
||||||
|
|
||||||
local is_pull_all_components=true
|
local is_pull_all_components=true
|
||||||
|
local components=("devsvc" "payment" "content" "central_storage" "authentication")
|
||||||
|
|
||||||
|
echo "==> Checking parameters..."
|
||||||
for component in "${components[@]}"; do
|
for component in "${components[@]}"; do
|
||||||
if [[ -z "${args["${component}_image_repo"]}" ]]; then
|
echo "==> Checking ${component} image repo...value: ${args["${component}_image_repo"]}"
|
||||||
|
# if ${args["${component}_image_repo"]} is not empty, then set is_pull_all_components to false
|
||||||
|
if [[ -n "${args["${component}_image_repo"]}" ]]; then
|
||||||
is_pull_all_components=false
|
is_pull_all_components=false
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
echo "==> is_pull_all_components: $is_pull_all_components"
|
||||||
|
|
||||||
|
echo " ===================================================== "
|
||||||
|
|
||||||
echo "Parameters:"
|
echo "Parameters:"
|
||||||
echo " OS = $OS"
|
echo " OS = $OS"
|
||||||
@ -544,9 +544,9 @@ devbox_init_command() {
|
|||||||
echo " DEVSVC_REPO = $DEVSVC_REPO"
|
echo " DEVSVC_REPO = $DEVSVC_REPO"
|
||||||
echo " DEVSVC_IMAGE = $DEVSVC_IMAGE"
|
echo " DEVSVC_IMAGE = $DEVSVC_IMAGE"
|
||||||
echo " DEVSVC_TAG = $DEVSVC_TAG"
|
echo " DEVSVC_TAG = $DEVSVC_TAG"
|
||||||
echo " NOTIFICATION_REPO = $NOTIFICATION_REPO"
|
echo " PAYMENT_REPO = $PAYMENT_REPO"
|
||||||
echo " NOTIFICATION_IMAGE= $NOTIFICATION_IMAGE"
|
echo " PAYMENT_IMAGE= $PAYMENT_IMAGE"
|
||||||
echo " NOTIFICATION_TAG = $NOTIFICATION_TAG"
|
echo " PAYMENT_TAG = $PAYMENT_TAG"
|
||||||
echo " CONTENT_REPO = $CONTENT_REPO"
|
echo " CONTENT_REPO = $CONTENT_REPO"
|
||||||
echo " CONTENT_IMAGE = $CONTENT_IMAGE"
|
echo " CONTENT_IMAGE = $CONTENT_IMAGE"
|
||||||
echo " CONTENT_TAG = $CONTENT_TAG"
|
echo " CONTENT_TAG = $CONTENT_TAG"
|
||||||
@ -573,6 +573,24 @@ devbox_init_command() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check ARCH match current device
|
||||||
|
if [[ "$ARCH" == "auto" ]]; then
|
||||||
|
ARCH="$(uname -m)"
|
||||||
|
if [[ "$ARCH" == "x86_64" ]]; then
|
||||||
|
ARCH="amd64"
|
||||||
|
elif [[ "$ARCH" == "aarch64" ]]; then
|
||||||
|
ARCH="arm64"
|
||||||
|
else
|
||||||
|
echo "ERROR: Unsupported architecture: $ARCH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "==> Detected OS: $OS, ARCH: $ARCH"
|
||||||
|
|
||||||
|
# Default arch tag value if Arch is amd64 then latest-linux-amd64 else latest-linux-arm64
|
||||||
|
local arch_tag="latest-linux-${ARCH}"
|
||||||
|
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
# 3. Check environment requirements
|
# 3. Check environment requirements
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
@ -630,7 +648,7 @@ devbox_init_command() {
|
|||||||
# ...
|
# ...
|
||||||
|
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
# 5. pull and start DevBox container
|
# 5.1 pull and start DevBox container
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
local devbox_full_image="${DEVBOX_REPO}/${DEVBOX_IMAGE}:${DEVBOX_TAG}"
|
local devbox_full_image="${DEVBOX_REPO}/${DEVBOX_IMAGE}:${DEVBOX_TAG}"
|
||||||
echo "==> Pulling DevBox image: $devbox_full_image"
|
echo "==> Pulling DevBox image: $devbox_full_image"
|
||||||
@ -682,23 +700,47 @@ echo "==> [INIT] Starting Freeleaps services... $USE_LOCAL_COMPONENT"
|
|||||||
|
|
||||||
if [[ "${USE_LOCAL_COMPONENT,,}" == "true" ]]; then
|
if [[ "${USE_LOCAL_COMPONENT,,}" == "true" ]]; then
|
||||||
echo ' ===> Using local components for Freeleaps services.'
|
echo ' ===> Using local components for Freeleaps services.'
|
||||||
# Local components for Freeleaps services (devsvc, notification, content, central_storage, authentication)
|
|
||||||
|
|
||||||
|
# Define local components ports dictionary
|
||||||
|
declare -A local_components_ports
|
||||||
|
local_components_ports["devsvc"]="8007"
|
||||||
|
local_components_ports["payment"]="8006"
|
||||||
|
local_components_ports["content"]="8013"
|
||||||
|
local_components_ports["central_storage"]="8005"
|
||||||
|
local_components_ports["authentication"]="8004"
|
||||||
|
|
||||||
|
# Local components for Freeleaps services (devsvc, payment, content, central_storage, authentication)
|
||||||
for component in "${components[@]}"; do
|
for component in "${components[@]}"; do
|
||||||
local COMPONENT_REPO="${component^^}_REPO"
|
repo_var="${component^^}_REPO"
|
||||||
COMPONENT_REPO="${COMPONENT_REPO//-/_}"
|
image_var="${component^^}_IMAGE"
|
||||||
local COMPONENT_IMAGE="${component^^}_IMAGE"
|
tag_var="${component^^}_TAG"
|
||||||
COMPONENT_IMAGE="${COMPONENT_IMAGE//-/_}"
|
|
||||||
local COMPONENT_TAG="${component^^}_TAG"
|
# 使用间接展开获取变量的值
|
||||||
COMPONENT_TAG="${COMPONENT_TAG//-/_}"
|
COMPONENT_REPO="${!repo_var}"
|
||||||
|
COMPONENT_IMAGE="${!image_var}"
|
||||||
|
COMPONENT_TAG="${!tag_var}"
|
||||||
|
|
||||||
|
# 调试输出,检查变量是否正确
|
||||||
|
echo "Component: $component"
|
||||||
|
echo " Repo: $COMPONENT_REPO"
|
||||||
|
echo " Image: $COMPONENT_IMAGE"
|
||||||
|
echo " Tag: $COMPONENT_TAG"
|
||||||
|
|
||||||
# check if is_pull_all_components is false and component repo and component image parameter not empty
|
# check if is_pull_all_components is false and component repo and component image parameter not empty
|
||||||
if [[ "$is_pull_all_components" == false && -n "${!COMPONENT_REPO}" && -n "${!COMPONENT_IMAGE}" ]]; then
|
if [[ "$is_pull_all_components" == false && -n "${!COMPONENT_REPO}" && -n "${!COMPONENT_IMAGE}" ]]; then
|
||||||
|
echo "==> Using local components for Freeleaps services. For $component, COMPONENT_REPO - '$COMPONENT_REPO', COMPONENT_IMAGE - '$COMPONENT_IMAGE'"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Pull the component image
|
component_full_image=""
|
||||||
local component_full_image="${!COMPONENT_REPO}/${!COMPONENT_IMAGE}:${!COMPONENT_TAG}"
|
|
||||||
|
if [[ "$is_pull_all_components" == true ]]; then
|
||||||
|
component_full_image="docker.io/freeleaps/$component:$arch_tag"
|
||||||
|
else
|
||||||
|
component_full_image="${!COMPONENT_REPO}/${!COMPONENT_IMAGE}:${!COMPONENT_TAG}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo "==> Pulling ${component} image: $component_full_image"
|
echo "==> Pulling ${component} image: $component_full_image"
|
||||||
if ! docker pull "$component_full_image"; then
|
if ! docker pull "$component_full_image"; then
|
||||||
echo "WARNING: Failed to pull ${component} image: $component_full_image, please Check the image and specify it to initialize the component."
|
echo "WARNING: Failed to pull ${component} image: $component_full_image, please Check the image and specify it to initialize the component."
|
||||||
@ -715,19 +757,27 @@ if [[ "${USE_LOCAL_COMPONENT,,}" == "true" ]]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "==> Creating and starting ${component} container..."
|
|
||||||
|
|
||||||
|
echo "==> Creating and starting ${component} container... ${local_components_ports[$component]}"
|
||||||
local component_container_id
|
local component_container_id
|
||||||
component_container_id="$(
|
component_container_id="$(
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name "$component" \
|
--name "$component" \
|
||||||
--link "$DEVBOX_NAME" \
|
--link "$DEVBOX_NAME" \
|
||||||
|
-p "${local_components_ports[$component]}:${local_components_ports[$component]}" \
|
||||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
"$component_full_image" 2>/dev/null
|
-e SERVICE_API_ACCESS_PORT=${local_components_ports[$component]} \
|
||||||
|
-e SERVICE_API_ACCESS_HOST=0.0.0.0 \
|
||||||
|
"$component_full_image" \
|
||||||
|
uvicorn webapi.main:app --reload --port ${local_components_ports[$component]} --host 0.0.0.0 2>/dev/null
|
||||||
)"
|
)"
|
||||||
if [[ -z "$component_container_id" ]]; then
|
if [[ -z "$component_container_id" ]]; then
|
||||||
echo "WARNING: Failed to create ${component} container. please Check the image and specify it to initialize the component."
|
echo "WARNING: Failed to create ${component} container. please Check the image and specify it to initialize the component."
|
||||||
fi
|
fi
|
||||||
echo "$component_container_id" > "/home/.devbox/.${component}-instance"
|
|
||||||
|
echo "$component_container_id" > "$WORKING_HOME/.${component}-instance"
|
||||||
|
|
||||||
echo "${component} container created: $component_container_id"
|
echo "${component} container created: $component_container_id"
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -761,7 +811,6 @@ if [[ "${USE_LOCAL_COMPONENT,,}" == "true" ]]; then
|
|||||||
|
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|
||||||
|
|
||||||
echo '============================================'
|
echo '============================================'
|
||||||
|
|
||||||
MAX_ATTEMPTS=10
|
MAX_ATTEMPTS=10
|
||||||
@ -783,15 +832,10 @@ if [[ "${USE_LOCAL_COMPONENT,,}" == "true" ]]; then
|
|||||||
|
|
||||||
echo "Step 4. [INFO] Starting MongoDB container..."
|
echo "Step 4. [INFO] Starting MongoDB container..."
|
||||||
|
|
||||||
else
|
|
||||||
echo '============================================'
|
|
||||||
echo ' ===> Using online components for Freeleaps services.'
|
|
||||||
echo '============================================'
|
|
||||||
fi
|
|
||||||
# 4. Pull and start RabbitMQ container
|
# 4. Pull and start RabbitMQ container
|
||||||
echo "Step 4. [INFO] Starting RabbitMQ container..."
|
echo "Step 4. [INFO] Starting RabbitMQ container..."
|
||||||
|
|
||||||
RABBITMQ_CONTAINER_NAME="freeleaps2-rabbitmq"
|
RABBITMQ_CONTAINER_NAME="freeleaps2"
|
||||||
RABBITMQ_IMAGE="rabbitmq:latest"
|
RABBITMQ_IMAGE="rabbitmq:latest"
|
||||||
|
|
||||||
# If a container with the same name exists, remove it
|
# If a container with the same name exists, remove it
|
||||||
@ -829,93 +873,82 @@ fi
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "Step 5. [INFO] Starting RabbitMQ container..."
|
echo "Step 5. [INFO] Starting RabbitMQ container..."
|
||||||
|
else
|
||||||
|
echo '============================================'
|
||||||
|
echo ' ===> Using online components for Freeleaps services.'
|
||||||
|
echo '============================================'
|
||||||
|
fi
|
||||||
|
|
||||||
|
pushd $WORKING_HOME
|
||||||
|
|
||||||
|
# Check if freeleaps2-frontend exists, if not git clone it
|
||||||
|
if [ ! -d $WORKING_HOME/freeleaps ]; then
|
||||||
|
echo "Git cloning freeleaps.com:3443/products/freeleaps.git"
|
||||||
|
FRONTEND_GIT_URL="https://$FREELEAPS_USERNAME:$FREELEAPS_PASSWORD@freeleaps.com:3443/products/freeleaps.git"
|
||||||
|
git clone --depth 5 $FRONTEND_GIT_URL
|
||||||
|
else
|
||||||
|
pushd $WORKING_HOME/freeleaps
|
||||||
|
echo "Git pulling freeleaps.com:3443/products/freeleaps.git"
|
||||||
|
git pull
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run banckend service and frontend service in the container
|
||||||
docker exec -i "$DEVBOX_NAME" bash <<EOF
|
docker exec -i "$DEVBOX_NAME" bash <<EOF
|
||||||
|
|
||||||
# Set environment variables
|
# Set environment variables
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
|
||||||
export FREELEAPS_USERNAME="${FREELEAPS_USERNAME}"
|
export FREELEAPS_USERNAME="${FREELEAPS_USERNAME}"
|
||||||
export FREELEAPS_PASSWORD="${FREELEAPS_PASSWORD}"
|
export FREELEAPS_PASSWORD="${FREELEAPS_PASSWORD}"
|
||||||
export USE_LOCAL_COMPONENT="${USE_LOCAL_COMPONENT}"
|
export USE_LOCAL_COMPONENT="${USE_LOCAL_COMPONENT}"
|
||||||
export DEVBOX_BACKEND_PORT="${DEVBOX_BACKEND_PORT}"
|
export DEVBOX_BACKEND_PORT="${DEVBOX_BACKEND_PORT}"
|
||||||
export DEVBOX_FRONTEND_PORT="${DEVBOX_FRONTEND_PORT}"
|
export DEVBOX_FRONTEND_PORT="${DEVBOX_FRONTEND_PORT}"
|
||||||
export OSTYPE="${OSTYPE}"
|
|
||||||
|
|
||||||
|
|
||||||
# Ensure /home/.devbox/logs exists
|
# Check if useing local component and update /home/.devbox/freeleaps/.dev.env
|
||||||
mkdir -p "/home/.devbox/logs"
|
echo "step 2: Update /home/.devbox/freeleaps/apps/.env"
|
||||||
|
|
||||||
# Get default IP address
|
# Get default IP address
|
||||||
|
|
||||||
DEFAULT_IP=\$(ip route | grep default | sed -n 's/.*default via \([^ ]*\).*/\1/p')
|
DEFAULT_IP=\$(ip route | grep default | sed -n 's/.*default via \([^ ]*\).*/\1/p')
|
||||||
|
if [[ "\${USE_LOCAL_COMPONENT,,}" == "true" ]]; then
|
||||||
|
|
||||||
echo "Starting freeleaps services..."
|
|
||||||
|
|
||||||
mkdir -p ~/freeleaps_home/
|
|
||||||
pushd ~/freeleaps_home/
|
|
||||||
|
|
||||||
|
|
||||||
echo "Steps 1: Check if freeleaps repro exists, if not git clone it"
|
|
||||||
# Check if freeleaps2-frontend exists, if not git clone it
|
|
||||||
if [ ! -d ~/freeleaps_home/freeleaps ]; then
|
|
||||||
echo "Git cloning freeleaps2-frontend"
|
|
||||||
FRONTEND_GIT_URL="https://${FREELEAPS_USERNAME}:${FREELEAPS_PASSWORD}@freeleaps.com:3443/products/freeleaps.git"
|
|
||||||
git clone --depth 5 "\$FRONTEND_GIT_URL"
|
|
||||||
else
|
|
||||||
pushd ~/freeleaps_home/freeleaps
|
|
||||||
echo "Git pulling freeleaps.com:3443/products/freeleaps.git"
|
|
||||||
git pull
|
|
||||||
popd
|
|
||||||
fi
|
|
||||||
|
|
||||||
popd
|
|
||||||
|
|
||||||
pushd ~/freeleaps_home/
|
|
||||||
|
|
||||||
# Check if useing local component and update ~/freeleaps_home/freeleaps/.dev.env
|
|
||||||
echo "step 2: Update ~/freeleaps_home/freeleaps/.dev.env"
|
|
||||||
|
|
||||||
if [[ "${USE_LOCAL_COMPONENT,,}" == "true" ]]; then
|
|
||||||
echo "==> Using local components"
|
echo "==> Using local components"
|
||||||
|
# Local components for Freeleaps services (devsvc, payment, content, central_storage, authentication)
|
||||||
# Local components for Freeleaps services (devsvc, notification, content, central_storage, authentication)
|
cat << 'EOFinner' > /home/.devbox/freeleaps/apps/.env
|
||||||
cat << 'EOFinner' > ~/freeleaps_home/freeleaps/.dev.env
|
|
||||||
# Online endpoint info
|
# Online endpoint info
|
||||||
export MONGODB_NAME=freeleaps2
|
export MONGODB_NAME=freeleaps2
|
||||||
export MONGODB_URI=mongodb://\$DEFAULT_IP:27017/
|
export MONGODB_URI=mongodb://\$DEFAULT_IP:27017/
|
||||||
export SITE_ACCESS_PORT=80
|
|
||||||
export FREELEAPS_ENV=dev
|
|
||||||
export STRIPE_API_KEY=sk_test_51Ogsw5B0IyqaSJBrwczlr820jnmvA1qQQGoLZ2XxOsIzikpmXo4pRLjw4XVMTEBR8DdVTYySiAv1XX53Zv5xqynF00GfMqttFd
|
|
||||||
export STRIPE_WEBHOOK_SECRET=
|
|
||||||
export SITE_URL_ROOT=http://localhost/
|
|
||||||
export BLOB_STORE_CONNECTION_STR="DefaultEndpointsProtocol=https;AccountName=freeleaps1static;AccountKey=SIk7S3RviJxl1XhGiDZKA3cvzfxNrSbsBMfJ3EbKTsKPeMwhy8FTLpJliRLzQVE6uaSX8giDYw2h+ASt5MmHxQ==;EndpointSuffix=core.windows.net"
|
|
||||||
export RABBITMQ_HOST=\$DEFAULT_IP
|
|
||||||
export RABBITMQ_PORT=5672
|
|
||||||
export FREELEAPS_DEVSVC_ENDPOINT=http://localhost:8007/api/devsvc/
|
|
||||||
export FREELEAPS_CONTENT_ENDPOINT=http://localhost:8013/api/content/
|
|
||||||
export FREELEAPS_CENTRAL_STORAGE_ENDPOINT=http://localhost:8005/api/central_storage/
|
|
||||||
export JWT_SECRET_KEY=8f87ca8c3c9c3df09a9c78e0adb0927855568f6072d9efc892534aee35f5867b
|
|
||||||
export FREELEAPS_AUTHENTICATION_ENDPOINT=http://localhost:8004/api/auth/
|
|
||||||
export EMAIL_FROM=freeleaps@freeleaps.com
|
|
||||||
EOFinner
|
|
||||||
else
|
|
||||||
cat << 'EOFinner' > ~/freeleaps_home/freeleaps/.dev.env
|
|
||||||
# Online endpoint info
|
|
||||||
export MONGODB_NAME=freeleaps2
|
|
||||||
export MONGODB_PORT=27017
|
export MONGODB_PORT=27017
|
||||||
export MONGODB_URI='mongodb+srv://jetli:8IHKx6dZK8BfugGp@freeleaps2.hanbj.mongodb.net/'
|
export BLOB_STORE_CONNECTION_STR="DefaultEndpointsProtocol=https;AccountName=freeleaps1static;AccountKey=SIk7S3RviJxl1XhGiDZKA3cvzfxNrSbsBMfJ3EbKTsKPeMwhy8FTLpJliRLzQVE6uaSX8giDYw2h+ASt5MmHxQ==;EndpointSuffix=core.windows.net"
|
||||||
export RABBITMQ_HOSTNAME=\$DEFAULT_IP
|
export RABBITMQ_HOSTNAME=freeleaps2
|
||||||
export RABBITMQ_HOST=\$DEFAULT_IP
|
export RABBITMQ_HOST=\$DEFAULT_IP
|
||||||
export RABBITMQ_PORT=5672
|
export RABBITMQ_PORT=5672
|
||||||
export FREELEAPS_ENV=dev
|
export FREELEAPS_ENV=dev
|
||||||
export STRIPE_API_KEY=sk_test_51Ogsw5B0IyqaSJBrwczlr820jnmvA1qQQGoLZ2XxOsIzikpmXo4pRLjw4XVMTEBR8DdVTYySiAv1XX53Zv5xqynF00GfMqttFd
|
export STRIPE_API_KEY=sk_test_51Ogsw5B0IyqaSJBrwczlr820jnmvA1qQQGoLZ2XxOsIzikpmXo4pRLjw4XVMTEBR8DdVTYySiAv1XX53Zv5xqynF00GfMqttFd
|
||||||
export STRIPE_WEBHOOK_SECRET=whsec_S6ZWjSAdR5Cpsn2USH6ZRBqbdBIENjTC
|
export STRIPE_WEBHOOK_SECRET=whsec_S6ZWjSAdR5Cpsn2USH6ZRBqbdBIENjTC
|
||||||
export STRIPE_ACCOUNT_WEBHOOK_SECRET=whsec_PgPnkWGhEUiQfnV8aIb5Wmruz7XETJLm
|
export STRIPE_ACCOUNT_WEBHOOK_SECRET=whsec_PgPnkWGhEUiQfnV8aIb5Wmruz7XETJLm
|
||||||
|
export SITE_URL_ROOT=http://\$DEFAULT_IP/
|
||||||
|
export FREELEAPS_DEVSVC_ENDPOINT=http://\$DEFAULT_IP:8007/api/devsvc/
|
||||||
|
export FREELEAPS_CONTENT_ENDPOINT=http://\$DEFAULT_IP:8013/api/content/
|
||||||
|
export FREELEAPS_PAYMENT_ENDPOINT=http://\$DEFAULT_IP:8006/api/payment/
|
||||||
|
export FREELEAPS_CENTRAL_STORAGE_ENDPOINT=http://\$DEFAULT_IP:8005/api/central_storage/
|
||||||
|
export FREELEAPS_AUTHENTICATION_ENDPOINT=http://\$DEFAULT_IP:8004/api/auth/
|
||||||
|
export FREELEAPS_AILAB_ENDPOINT=https://as010-w2-re-vm.mathmast.com:8009/api/
|
||||||
|
export KAFKA_SERVER_URL=''
|
||||||
|
export EMAIL_FROM=freeleaps@freeleaps.com
|
||||||
|
EOFinner
|
||||||
|
else
|
||||||
|
cat << 'EOFinner' > /home/.devbox/freeleaps/apps/.env
|
||||||
|
# Online endpoint info
|
||||||
|
export MONGODB_NAME=freeleaps2
|
||||||
|
export MONGODB_PORT=27017
|
||||||
|
export MONGODB_URI='mongodb+srv://jetli:8IHKx6dZK8BfugGp@freeleaps2.hanbj.mongodb.net/'
|
||||||
|
export RABBITMQ_HOSTNAME=freeleaps2
|
||||||
|
export RABBITMQ_HOST=52.149.35.244
|
||||||
|
export RABBITMQ_PORT=5672
|
||||||
|
export FREELEAPS_ENV=dev
|
||||||
|
export STRIPE_API_KEY=sk_test_51Ogsw5B0IyqaSJBrwczlr820jnmvA1qQQGoLZ2XxOsIzikpmXo4pRLjw4XVMTEBR8DdVTYySiAv1XX53Zv5xqynF00GfMqttFd
|
||||||
|
export STRIPE_WEBHOOK_SECRET=whsec_S6ZWjSAdR5Cpsn2USH6ZRBqbdBIENjTC
|
||||||
|
export STRIPE_ACCOUNT_WEBHOOK_SECRET=whsec_PgPnkWGhEUiQfnV8aIb5Wmruz7XETJLm
|
||||||
export SITE_URL_ROOT=http://localhost/
|
export SITE_URL_ROOT=http://localhost/
|
||||||
export FREELEAPS_DEVSVC_ENDPOINT=http://ip: 52.149.3.85:8007/api/devsvc/
|
export FREELEAPS_DEVSVC_ENDPOINT=http://52.149.3.85:8007/api/devsvc/
|
||||||
export FREELEAPS_CONTENT_ENDPOINT=http://52.149.35.244:8013/api/content/
|
export FREELEAPS_CONTENT_ENDPOINT=http://52.149.35.244:8013/api/content/
|
||||||
export FREELEAPS_PAYMENT_ENDPOINT=http://52.149.35.244:8006/api/payment/
|
export FREELEAPS_PAYMENT_ENDPOINT=http://52.149.35.244:8006/api/payment/
|
||||||
export FREELEAPS_CENTRAL_STORAGE_ENDPOINT=http://52.149.35.244:8005/api/central_storage/
|
export FREELEAPS_CENTRAL_STORAGE_ENDPOINT=http://52.149.35.244:8005/api/central_storage/
|
||||||
@ -926,28 +959,31 @@ else
|
|||||||
EOFinner
|
EOFinner
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source ~/freeleaps_home/freeleaps/.dev.env
|
# Effect the environment variables in the current shell
|
||||||
cp ~/freeleaps_home/freeleaps/.dev.env ~/freeleaps_home/freeleaps/apps/.env
|
|
||||||
|
|
||||||
cp ~/freeleaps_home/freeleaps/.dev.env ~/freeleaps_home/freeleaps/.env
|
source /home/.devbox/freeleaps/apps/.env
|
||||||
source ~/freeleaps_home/freeleaps/.dev.env
|
|
||||||
source ~/freeleaps_home/freeleaps/apps/.env
|
|
||||||
|
|
||||||
# Run start_webapi.sh and check if success started
|
# Echo the environment variables
|
||||||
echo "Step 4: Run start_webapi.sh and check if success started"
|
echo "==================================================="
|
||||||
|
echo "Environment variables:"
|
||||||
|
echo " MONGODB_NAME=\$MONGODB_NAME"
|
||||||
|
echo " MONGODB_URI=\$MONGODB_URI"
|
||||||
|
echo " RABBITMQ_HOST=\$RABBITMQ_HOST"
|
||||||
|
echo " RABBITMQ_PORT=\$RABBITMQ_PORT"
|
||||||
|
echo " FREELEAPS_DEVSVC_ENDPOINT=\$FREELEAPS_DEVSVC_ENDPOINT"
|
||||||
|
echo "==================================================="
|
||||||
|
|
||||||
|
# Ensure /home/.devbox/logs exists
|
||||||
|
mkdir -p /home/.devbox/logs
|
||||||
|
|
||||||
# Start WebAPI service
|
# Start WebAPI service
|
||||||
echo "Starting WebAPI service..."
|
echo "Starting WebAPI service..."
|
||||||
# Make sure the logs directory exists
|
pushd /home/.devbox/freeleaps/apps
|
||||||
mkdir -p ~/freeleaps_home/logs
|
cp /home/.devbox/freeleaps/backend_env.sh /home/.devbox/freeleaps/apps/backend_env.sh
|
||||||
pushd ~/freeleaps_home/freeleaps/apps
|
|
||||||
cp ~/freeleaps_home/freeleaps/backend_env.sh ~/freeleaps_home/freeleaps/apps/backend_env.sh
|
|
||||||
|
|
||||||
|
|
||||||
# 5. Istall python3.10 and venv module
|
# 5. Istall python3.10 and venv module
|
||||||
echo "5. Istall python3.10 and venv module"
|
echo "5. Istall python3.10 and venv module"
|
||||||
sudo apt update
|
sudo apt update
|
||||||
|
|
||||||
sudo apt install python3.10 python3.10-venv -y
|
sudo apt install python3.10 python3.10-venv -y
|
||||||
|
|
||||||
# make sore python3.10 is installed
|
# make sore python3.10 is installed
|
||||||
@ -956,7 +992,6 @@ if ! command -v python3.10 &>/dev/null; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Upgrade pip and install virtualenv
|
# Upgrade pip and install virtualenv
|
||||||
echo "7. Upgrade pip and install virtualenv"
|
echo "7. Upgrade pip and install virtualenv"
|
||||||
python3.10 -m ensurepip --upgrade
|
python3.10 -m ensurepip --upgrade
|
||||||
@ -975,12 +1010,10 @@ if [ ! -f "venv_t/bin/activate" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo '============================================'
|
echo '============================================'
|
||||||
|
|
||||||
echo ' Start to activate virtual environment'
|
echo ' Start to activate virtual environment'
|
||||||
echo '============================================'
|
echo '============================================'
|
||||||
|
|
||||||
source venv_t/bin/activate
|
source venv_t/bin/activate
|
||||||
|
source /home/.devbox/freeleaps/apps/.env
|
||||||
|
|
||||||
# Verify the virtual environment is activated
|
# Verify the virtual environment is activated
|
||||||
if [[ "\$VIRTUAL_ENV" != "" ]]; then
|
if [[ "\$VIRTUAL_ENV" != "" ]]; then
|
||||||
@ -993,7 +1026,7 @@ fi
|
|||||||
echo '============================================'
|
echo '============================================'
|
||||||
echo ' Install requirements'
|
echo ' Install requirements'
|
||||||
echo '============================================'
|
echo '============================================'
|
||||||
pip install -r ~/freeleaps_home/freeleaps/apps/requirements.txt
|
pip install -r /home/.devbox/freeleaps/apps/requirements.txt
|
||||||
|
|
||||||
echo '============================================'
|
echo '============================================'
|
||||||
echo 'Start to run start_webapi.sh'
|
echo 'Start to run start_webapi.sh'
|
||||||
@ -1036,8 +1069,7 @@ fi
|
|||||||
echo '============================================'
|
echo '============================================'
|
||||||
echo ' Start frontend service locally'
|
echo ' Start frontend service locally'
|
||||||
echo '============================================'
|
echo '============================================'
|
||||||
pushd ~/freeleaps_home/freeleaps/frontend
|
pushd /home/.devbox/freeleaps/frontend
|
||||||
|
|
||||||
|
|
||||||
# start the frontend service
|
# start the frontend service
|
||||||
export VITE_API_URL='http://127.0.0.1:8002'
|
export VITE_API_URL='http://127.0.0.1:8002'
|
||||||
@ -1357,10 +1389,10 @@ devbox_init_parse_requirements() {
|
|||||||
# :flag.case
|
# :flag.case
|
||||||
--use-local-component)
|
--use-local-component)
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--devsvc-image-repo']="$2"
|
args['--use-local-component']="$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
printf "%s\n" "--use-local-component requires an argument: --use-local-component IS_USING_LOCAL_COMPONENT" >&2
|
printf "%s\n" "--use-local-component requires an argument: --use-local-component USING_LOCAL_COMPONENT" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@ -1408,34 +1440,34 @@ devbox_init_parse_requirements() {
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--notification-image-repo)
|
--payment-image-repo)
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--notification-image-repo']="$2"
|
args['--payment-image-repo']="$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
printf "%s\n" "--notification-image-repo requires an argument: --notification-image-repo FREELEAPS_NOTIFICATION_IMAGE_REPO" >&2
|
printf "%s\n" "--payment-image-repo requires an argument: --payment-image-repo FREELEAPS_PAYMENT_IMAGE_REPO" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--notification-image-name)
|
--payment-image-name)
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--notification-image-name']="$2"
|
args['--payment-image-name']="$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
printf "%s\n" "--notification-image-name requires an argument: --notification-image-name FREELEAPS_NOTIFICATION_IMAGE_NAME" >&2
|
printf "%s\n" "--payment-image-name requires an argument: --payment-image-name FREELEAPS_PAYMENT_IMAGE_NAME" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--notification-image-tag)
|
--payment-image-tag)
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--notification-image-tag']="$2"
|
args['--payment-image-tag']="$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
printf "%s\n" "--notification-image-tag requires an argument: --notification-image-tag FREELEAPS_NOTIFICATION_IMAGE_TAG" >&2
|
printf "%s\n" "--payment-image-tag requires an argument: --payment-image-tag FREELEAPS_PAYMENT_IMAGE_TAG" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@ -1584,12 +1616,12 @@ devbox_init_parse_requirements() {
|
|||||||
[[ -n ${args['--devbox-image-name']:-} ]] || args['--devbox-image-name']="devbox_v1"
|
[[ -n ${args['--devbox-image-name']:-} ]] || args['--devbox-image-name']="devbox_v1"
|
||||||
[[ -n ${args['--devbox-image-tag']:-} ]] || args['--devbox-image-tag']="devbox_local"
|
[[ -n ${args['--devbox-image-tag']:-} ]] || args['--devbox-image-tag']="devbox_local"
|
||||||
[[ -n ${args['--devsvc-image-tag']:-} ]] || args['--devsvc-image-tag']="latest-linux-amd64"
|
[[ -n ${args['--devsvc-image-tag']:-} ]] || args['--devsvc-image-tag']="latest-linux-amd64"
|
||||||
[[ -n ${args['--notification-image-tag']:-} ]] || args['--notification-image-tag']="latest-linux-amd64"
|
[[ -n ${args['--payment-image-tag']:-} ]] || args['--payment-image-tag']="latest-linux-amd64"
|
||||||
[[ -n ${args['--content-image-tag']:-} ]] || args['--content-image-tag']="latest-linux-amd64"
|
[[ -n ${args['--content-image-tag']:-} ]] || args['--content-image-tag']="latest-linux-amd64"
|
||||||
[[ -n ${args['--central_storage-image-tag']:-} ]] || args['--central_storage-image-tag']="latest-linux-amd64"
|
[[ -n ${args['--central_storage-image-tag']:-} ]] || args['--central_storage-image-tag']="latest-linux-amd64"
|
||||||
[[ -n ${args['--authentication-image-tag']:-} ]] || args['--authentication-image-tag']="latest-linux-amd64"
|
[[ -n ${args['--authentication-image-tag']:-} ]] || args['--authentication-image-tag']="latest-linux-amd64"
|
||||||
[[ -n ${args['--working-home']:-} ]] || args['--working-home']="${HOME}/.devbox"
|
[[ -n ${args['--working-home']:-} ]] || args['--working-home']="${HOME}/.devbox"
|
||||||
[[ -n ${args['--use-local-component']:-} ]] || args['--use-local-component']="false"
|
[[ -n ${args['--use-local-component']:-} ]] || args['--use-local-component']="true"
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user