forked from freeleaps/freeleaps-pub
Update for change to use docker compose
This commit is contained in:
parent
30bfdf1fa2
commit
341b2a5042
@ -208,19 +208,19 @@ devbox_init_usage() {
|
||||
printf " %s\n" "Default: latest"
|
||||
echo
|
||||
|
||||
# :flag.usage payment image repo
|
||||
printf " %s\n" "--payment-image-repo PAYMENT_IMAGE_REPO"
|
||||
printf " Specifies the repository for payment component. (Optional)\n"
|
||||
# :flag.usage notification, image repo
|
||||
printf " %s\n" "--notification-image-repo NOTIFICATION_IMAGE_REPO"
|
||||
printf " Specifies the repository for notification component. (Optional)\n"
|
||||
echo
|
||||
|
||||
# :flag.usage payment image name
|
||||
printf " %s\n" "--payment-image-name PAYMENT_IMAGE_NAME"
|
||||
printf " Specifies the image name for payment component. (Optional)\n"
|
||||
# :flag.usage notification image name
|
||||
printf " %s\n" "--notification-image-name NOTIFICATION_IMAGE_NAME"
|
||||
printf " Specifies the image name for notification component. (Optional)\n"
|
||||
echo
|
||||
|
||||
# :flag.usage payment image tag
|
||||
printf " %s\n" "--payment-image-tag PAYMENT_IMAGE_TAG"
|
||||
printf " Specifies the image tag for payment component. (Optional, default=latest)\n"
|
||||
# :flag.usage notification image tag
|
||||
printf " %s\n" "--notification-image-tag NOTIFICATION_IMAGE_TAG"
|
||||
printf " Specifies the image tag for notification component. (Optional, default=latest)\n"
|
||||
printf " %s\n" "Default: latest"
|
||||
echo
|
||||
|
||||
@ -367,7 +367,7 @@ devbox_start_usage() {
|
||||
# :command.usage_flags
|
||||
# :flag.usage
|
||||
printf " %s\n" "--component COMPONENT"
|
||||
printf " Specifies the name of the component to start (e.g., mongodb, rabbitmq,\n backend, frontend, devsvc, payment, content, central_storage,\n authentication).\n"
|
||||
printf " Specifies the name of the component to start (e.g., mongodb, rabbitmq,\n backend, frontend, devsvc, content, central_storage,\n authentication).\n"
|
||||
echo
|
||||
|
||||
# :command.usage_fixed_flags
|
||||
@ -407,7 +407,7 @@ devbox_stop_usage() {
|
||||
# :command.usage_flags
|
||||
# :flag.usage
|
||||
printf " %s\n" "--component COMPONENT"
|
||||
printf " Specifies the name of the component to stop (e.g., mongodb, rabbitmq,\n backend, frontend, devsvc, payment, content, central_storage,\n authentication).\n"
|
||||
printf " Specifies the name of the component to stop (e.g., mongodb, rabbitmq,\n backend, frontend, devsvc, content, central_storage,\n authentication).\n"
|
||||
echo
|
||||
|
||||
# :command.usage_fixed_flags
|
||||
@ -687,6 +687,56 @@ check_docker_running() {
|
||||
return 1
|
||||
}
|
||||
|
||||
start_local_gitea(){
|
||||
echo "[INFO] Starting Gitea container..."
|
||||
|
||||
GITEA_CONTAINER_NAME="freeleaps2-gitea"
|
||||
GITEA_IMAGE="gitea/gitea:latest"
|
||||
|
||||
# If a container with the same name exists, remove it
|
||||
if docker ps -a --format '{{.Names}}' | grep -q "^${GITEA_CONTAINER_NAME}\$"; then
|
||||
echo "==> Removing existing Gitea container..."
|
||||
docker stop "${GITEA_CONTAINER_NAME}" &>/dev/null || true
|
||||
docker rm "${GITEA_CONTAINER_NAME}" &>/dev/null || true
|
||||
fi
|
||||
|
||||
# Pull the Gitea image
|
||||
echo "==> Pulling Gitea image: ${GITEA_IMAGE}"
|
||||
if ! docker pull "${GITEA_IMAGE}"; then
|
||||
echo "ERROR: Failed to pull Gitea image: ${GITEA_IMAGE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run the Gitea container mapping port 3000
|
||||
gitea_container_id=$(docker run -d --name "${GITEA_CONTAINER_NAME}" \
|
||||
-v "${WORKING_HOME}/gitea:/data" \
|
||||
-e "DISABLE_REGISTRATION=true" \
|
||||
-e "REQUIRE_SIGNIN_VIEW=true" \
|
||||
-p 3000:3000 "${GITEA_IMAGE}" )
|
||||
|
||||
if [[ -z "${gitea_container_id}" ]]; then
|
||||
echo "ERROR: Failed to start Gitea container."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Gitea container started successfully: ${gitea_container_id}"
|
||||
|
||||
# Allow Gitea some time to initialize
|
||||
sleep 20
|
||||
|
||||
# Check Gitea health via curl
|
||||
if curl -s -o /dev/null -w "%{http_code}" http://localhost:3000 &>/dev/null; then
|
||||
echo "Gitea health check passed."
|
||||
else
|
||||
echo "ERROR: Gitea health check failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$gitea_container_id" > "$WORKING_HOME/.gitea-instance"
|
||||
|
||||
echo "[INFO] Completed Gitea container..."
|
||||
}
|
||||
|
||||
start_local_mongodb() {
|
||||
echo "==> Starting MongoDB service..."
|
||||
|
||||
@ -784,11 +834,11 @@ start_local_rabbitMQ(){
|
||||
echo "[INFO] Completed RabbitMQ container..."
|
||||
}
|
||||
|
||||
# 定义键和值数组
|
||||
local_components_ports_keys=("devsvc" "payment" "content" "central_storage" "authentication")
|
||||
local_components_ports_values=("8007" "8006" "8013" "8005" "8004")
|
||||
# Define the local components and their corresponding ports
|
||||
local_components_ports_keys=("devsvc" "notification" "content" "central_storage" "authentication")
|
||||
local_components_ports_values=("8007" "8003" "8013" "8005" "8004")
|
||||
|
||||
# 根据组件名查找对应的端口
|
||||
# Get the port number for a local component
|
||||
get_port() {
|
||||
local comp="$1"
|
||||
local port=""
|
||||
@ -822,6 +872,7 @@ devbox_init_command() {
|
||||
local DEVBOX_IMAGE="$args_devbox_image_name" # --devbox-image-name
|
||||
local DEVBOX_TAG="$args_devbox_image_tag" # --devbox-image-tag
|
||||
local WORKING_HOME="${args_working_home:-${WORKING_HOME:-${HOME}/.devbox}}"
|
||||
|
||||
local FREELEAPS_USERNAME="$args_freeleaps_username" # --freeleaps-username
|
||||
local FREELEAPS_PASSWORD="$args_freeleaps_password" # --freeleaps-password
|
||||
|
||||
@ -832,9 +883,6 @@ devbox_init_command() {
|
||||
local DEVSVC_IMAGE="$args_devsvc_image_image" # --devsvc-image-image
|
||||
local DEVSVC_TAG="$args_devsvc_image_tag" # --devsvc-image-tag
|
||||
|
||||
local PAYMENT_REPO="$args_payment_image_repo" # --payment-image-repo
|
||||
local PAYMENT_IMAGE="$args_payment_image_image" # --payment-image-image
|
||||
local PAYMENT_TAG="$args_payment_image_tag" # --payment-image-tag
|
||||
|
||||
local CONTENT_REPO="$args_content_image_repo" # --content-image-repo
|
||||
local CONTENT_IMAGE="$args_content_image_image" # --content-image-image
|
||||
@ -848,6 +896,10 @@ devbox_init_command() {
|
||||
local AUTHENTICATION_IMAGE="$args_authentication_image_image" # --authentication-image-image
|
||||
local AUTHENTICATION_TAG="$args_authentication_image_tag" # --authentication-image-tag
|
||||
|
||||
local NOTIFICATION_REPO="$args_notification_image_repo" # --notification-image-repo
|
||||
local NOTIFICATION_IMAGE="$args_notification_image_image" # --notification-image-image
|
||||
local NOTIFICATION_TAG="$args_notification_image_tag" # --notification-image-tag
|
||||
|
||||
# --force flag to overwrite existing resources
|
||||
local FORCE_INIT="${args_force}"
|
||||
|
||||
@ -867,9 +919,6 @@ devbox_init_command() {
|
||||
local DEVSVC_REPO="$(get_arg '--devsvc-image-repo')"
|
||||
local DEVSVC_IMAGE="$(get_arg '--devsvc-image-name')"
|
||||
local DEVSVC_TAG="$(get_arg '--devsvc-image-tag')"
|
||||
local PAYMENT_REPO="$(get_arg '--payment-image-repo')"
|
||||
local PAYMENT_IMAGE="$(get_arg '--payment-image-name')"
|
||||
local PAYMENT_TAG="$(get_arg '--payment-image-tag')"
|
||||
local CONTENT_REPO="$(get_arg '--content-image-repo')"
|
||||
local CONTENT_IMAGE="$(get_arg '--content-image-name')"
|
||||
local CONTENT_TAG="$(get_arg '--content-image-tag')"
|
||||
@ -879,21 +928,58 @@ devbox_init_command() {
|
||||
local AUTHENTICATION_REPO="$(get_arg '--authentication-image-repo')"
|
||||
local AUTHENTICATION_IMAGE="$(get_arg '--authentication-image-name')"
|
||||
local AUTHENTICATION_TAG="$(get_arg '--authentication-image-tag')"
|
||||
local NOTIFICATION_REPO="$(get_arg '--notification-image-repo')"
|
||||
local NOTIFICATION_IMAGE="$(get_arg '--notification-image-name')"
|
||||
local NOTIFICATION_TAG="$(get_arg '--notification-image-tag')"
|
||||
|
||||
local FORCE_INIT="$(get_arg '--force')"
|
||||
|
||||
local is_pull_all_components=true
|
||||
local components=("devsvc" "payment" "content" "central_storage" "authentication")
|
||||
local components=("devsvc" "notification" "content" "central_storage" "authentication")
|
||||
local start_components=()
|
||||
|
||||
echo "==> Checking parameters..."
|
||||
for component in "${components[@]}"; do
|
||||
echo "==> Checking ${component} image repo...value: $(get_arg "--${component}-image-repo")"
|
||||
# if any component image repo is provided, then don't pull all components
|
||||
|
||||
if [[ -n "$(get_arg "--${component}-image-repo")" ]]; then
|
||||
is_pull_all_components=false
|
||||
break
|
||||
|
||||
else
|
||||
start_components+=("${component}")
|
||||
fi
|
||||
|
||||
# Check ARCH match default component tag value and justify the default Image tag value
|
||||
if [[ "$ARCH" == "amd64" && "$component" == "devsvc" ]]; then
|
||||
DEVSVC_TAG="latest-linux-amd64"
|
||||
elif [[ "$ARCH" == "arm64" && "$component" == "devsvc" ]]; then
|
||||
DEVSVC_TAG="latest-linux-arm64"
|
||||
fi
|
||||
|
||||
if [[ "$ARCH" == "amd64" && "$component" == "content" ]]; then
|
||||
CONTENT_TAG="latest-linux-amd64"
|
||||
elif [[ "$ARCH" == "arm64" && "$component" == "content" ]]; then
|
||||
CONTENT_TAG="latest-linux-arm64"
|
||||
fi
|
||||
|
||||
if [[ "$ARCH" == "amd64" && "$component" == "central_storage" ]]; then
|
||||
CENTRAL_STORAGE_TAG="latest-linux-amd64"
|
||||
elif [[ "$ARCH" == "arm64" && "$component" == "central_storage" ]]; then
|
||||
CENTRAL_STORAGE_TAG="latest-linux-arm64"
|
||||
fi
|
||||
|
||||
if [[ "$ARCH" == "amd64" && "$component" == "authentication" ]]; then
|
||||
AUTHENTICATION_TAG="latest-linux-amd64"
|
||||
elif [[ "$ARCH" == "arm64" && "$component" == "authentication" ]]; then
|
||||
AUTHENTICATION_TAG="latest-linux-arm64"
|
||||
fi
|
||||
|
||||
if [[ "$ARCH" == "amd64" && "$component" == "notification" ]]; then
|
||||
NOTIFICATION_TAG="latest-linux-amd64"
|
||||
elif [[ "$ARCH" == "arm64" && "$component" == "notification" ]]; then
|
||||
NOTIFICATION_TAG="latest-linux-arm64"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "==> is_pull_all_components: $is_pull_all_components"
|
||||
|
||||
echo " ===================================================== "
|
||||
@ -915,9 +1001,6 @@ devbox_init_command() {
|
||||
echo " DEVSVC_REPO = $DEVSVC_REPO"
|
||||
echo " DEVSVC_IMAGE = $DEVSVC_IMAGE"
|
||||
echo " DEVSVC_TAG = $DEVSVC_TAG"
|
||||
echo " PAYMENT_REPO = $PAYMENT_REPO"
|
||||
echo " PAYMENT_IMAGE= $PAYMENT_IMAGE"
|
||||
echo " PAYMENT_TAG = $PAYMENT_TAG"
|
||||
echo " CONTENT_REPO = $CONTENT_REPO"
|
||||
echo " CONTENT_IMAGE = $CONTENT_IMAGE"
|
||||
echo " CONTENT_TAG = $CONTENT_TAG"
|
||||
@ -927,6 +1010,9 @@ devbox_init_command() {
|
||||
echo " AUTHENTICATION_REPO = $AUTHENTICATION_REPO"
|
||||
echo " AUTHENTICATION_IMAGE= $AUTHENTICATION_IMAGE"
|
||||
echo " AUTHENTICATION_TAG = $AUTHENTICATION_TAG"
|
||||
echo " NOTIFICATION_REPO = $NOTIFICATION_REPO"
|
||||
echo " NOTIFICATION_IMAGE= $NOTIFICATION_IMAGE"
|
||||
echo " NOTIFICATION_TAG = $NOTIFICATION_TAG"
|
||||
echo " FORCE_INIT = $FORCE_INIT"
|
||||
echo
|
||||
|
||||
@ -1014,10 +1100,6 @@ devbox_init_command() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# 如有 --force 且存在旧容器,则可在此删除旧容器/文件(也可在下面先检查容器再删)
|
||||
# ...
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# 5.1 pull and start DevBox container
|
||||
# -------------------------------------------------------------------
|
||||
@ -1041,6 +1123,20 @@ devbox_init_command() {
|
||||
fi
|
||||
|
||||
|
||||
DEVBOX_FREELEAPS2_NETWORK="devbox_freeleaps2-network"
|
||||
|
||||
echo '==> [INIT] Starting DevBox environment initialization...'
|
||||
# Check if docker network create devbox_freeleaps2-network
|
||||
if ! docker network ls | grep -q "$DEVBOX_FREELEAPS2_NETWORK"; then
|
||||
echo "==> Creating Docker network: $DEVBOX_FREELEAPS2_NETWORK"
|
||||
docker network create "$DEVBOX_FREELEAPS2_NETWORK"
|
||||
|
||||
else
|
||||
echo "==> Docker network devbox_freeleaps2-network already exists."
|
||||
fi
|
||||
|
||||
echo '==> [INIT] Starting DevBox container...'
|
||||
|
||||
# Create and start DevBox container
|
||||
local container_id
|
||||
container_id="$(
|
||||
@ -1051,6 +1147,7 @@ devbox_init_command() {
|
||||
-p "${DEVBOX_BACKEND_PORT}:8002" \
|
||||
-v "$WORKING_HOME:/home/.devbox" \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
--network "$DEVBOX_FREELEAPS2_NETWORK" \
|
||||
"$devbox_full_image" 2>/dev/null
|
||||
)"
|
||||
|
||||
@ -1070,98 +1167,67 @@ devbox_init_command() {
|
||||
|
||||
echo "==> [INIT] Starting Freeleaps services... Use Local component $USE_LOCAL_COMPONENT"
|
||||
|
||||
|
||||
if [[ "$(lower "$USE_LOCAL_COMPONENT")" == "true" ]]; then
|
||||
# 3.Create and start MongoDB container
|
||||
echo "Step 3. [INFO] Starting MongoDB container..."
|
||||
|
||||
start_local_mongodb
|
||||
|
||||
# 4. Pull and start RabbitMQ container
|
||||
start_local_rabbitMQ
|
||||
|
||||
echo ' ===> Using local components for Freeleaps services.'
|
||||
export ARCH="$ARCH"
|
||||
export DEVSVC_IMAGE_TAG="$DEVSVC_TAG"
|
||||
export CONTENT_IMAGE_TAG="$CONTENT_TAG"
|
||||
export CENTRAL_STORAGE_IMAGE_TAG="$CENTRAL_STORAGE_TAG"
|
||||
export AUTHENTICATION_IMAGE_TAG="$AUTHENTICATION_TAG"
|
||||
export NOTIFICATION_IMAGE_TAG="$NOTIFICATION_TAG"
|
||||
|
||||
# Local components for Freeleaps services (devsvc, payment, content, central_storage, authentication)
|
||||
for component in "${components[@]}"; do
|
||||
repo_var="$(upper "$component")_REPO"
|
||||
image_var="$(upper "$component")_IMAGE"
|
||||
tag_var="$(upper "$component")_TAG"
|
||||
# Start local components by docker compose file and start up specified services. docker compose file is in the same directory as the script (docker-compose.dev.arm64.new.yaml)
|
||||
# start component service from start_components array
|
||||
docker-compose -f docker-compose.dev.arm64.new.yaml up -d mongodb rabbitmq gitea "${start_components[@]}"
|
||||
echo "==> Starting Gitea, MongoDB, RabbitMQ containers..."
|
||||
|
||||
gitea_container_id=$(docker ps --no-trunc -a --filter "name=^freeleaps2-gitea$" --format "{{.ID}}")
|
||||
echo "$gitea_container_id" > "$WORKING_HOME/.gitea-instance"
|
||||
|
||||
# Get the component's repo, image, and tag
|
||||
COMPONENT_REPO="${!repo_var}"
|
||||
COMPONENT_IMAGE="${!image_var}"
|
||||
COMPONENT_TAG="${!tag_var}"
|
||||
mongo_container_id=$(docker ps --no-trunc -a --filter "name=^freeleaps2-mongodb$" --format "{{.ID}}")
|
||||
echo "$mongo_container_id" > "$WORKING_HOME/.mongodb-instance"
|
||||
|
||||
echo "Component: $component"
|
||||
echo " Repo: $COMPONENT_REPO"
|
||||
echo " Image: $COMPONENT_IMAGE"
|
||||
echo " Tag: $COMPONENT_TAG"
|
||||
rabbitmq_container_id=$(docker ps --no-trunc -a --filter "name=^freeleaps2-rabbitmq$" --format "{{.ID}}")
|
||||
echo "$rabbitmq_container_id" > "$WORKING_HOME/.rabbitmq-instance"
|
||||
|
||||
# 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
|
||||
echo "==> Using local components for Freeleaps services. For $component, COMPONENT_REPO - '$COMPONENT_REPO', COMPONENT_IMAGE - '$COMPONENT_IMAGE'"
|
||||
continue
|
||||
fi
|
||||
|
||||
component_full_image=""
|
||||
|
||||
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"
|
||||
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."
|
||||
fi
|
||||
|
||||
# if container with same name exists, remove it
|
||||
if docker ps -a --format '{{.Names}}' | grep -q "^${component}\$"; then
|
||||
if [[ -n "$FORCE_INIT" ]]; then
|
||||
echo "==> Removing existing container named $component ..."
|
||||
docker stop "$component" &>/dev/null || true
|
||||
docker rm "$component" &>/dev/null || true
|
||||
else
|
||||
echo "WARNING: Container named $component already exists. Use --force to remove it."
|
||||
fi
|
||||
fi
|
||||
|
||||
DEFAULT_IP=$(docker network inspect bridge | grep -m1 '"Gateway":' | sed -E 's/.*"Gateway": "([^"]+)".*/\1/')
|
||||
echo "Default gateway IP: $DEFAULT_IP"
|
||||
|
||||
port=$(get_port $component)
|
||||
echo "==> Creating and starting ${component} container... ${port}"
|
||||
local component_container_id
|
||||
component_container_id="$(
|
||||
docker run -d \
|
||||
--name "$component" \
|
||||
--link "$DEVBOX_NAME" \
|
||||
-p "${port}:${port}" \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-e SERVICE_API_ACCESS_PORT=${port} \
|
||||
-e SERVICE_API_ACCESS_HOST=0.0.0.0 \
|
||||
-e MONGODB_URI="mongodb://$DEFAULT_IP:27017" \
|
||||
"$component_full_image" \
|
||||
uvicorn webapi.main:app --reload --port ${port} --host 0.0.0.0 2>/dev/null
|
||||
)"
|
||||
if [[ -z "$component_container_id" ]]; then
|
||||
echo "WARNING: Failed to create ${component} container. please Check the image and specify it to initialize the component."
|
||||
fi
|
||||
|
||||
echo "$component_container_id" > "$WORKING_HOME/.${component}-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}}")
|
||||
echo "$tmp_container_id" > "$WORKING_HOME/.${component}-instance"
|
||||
done
|
||||
|
||||
echo "${component} container created: $component_container_id"
|
||||
done
|
||||
else
|
||||
echo '============================================'
|
||||
echo ' ===> Using online components for Freeleaps services.'
|
||||
echo '============================================'
|
||||
# Start Gitea, MongoDB, RabbitMQ containers
|
||||
local_components_docker_compose_output=$(docker-compose -f docker-compose.dev.arm64.new.yaml up -d mongodb rabbitmq)
|
||||
if [[ -z "$local_components_docker_compose_output" ]]; then
|
||||
echo "ERROR: Failed to start MongoDB, RabbitMQ containers."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Save MongoDB and RabbitMQ container ids to .mongodb-instance and .rabbitmq-instance
|
||||
|
||||
mongo_container_id=$(docker ps -a --format '{{.Names}}' | grep "^freeleaps2-mongodb\$")
|
||||
echo "$mongo_container_id" > "$WORKING_HOME/.mongodb-instance"
|
||||
|
||||
rabbitmq_container_id=$(docker ps -a --format '{{.Names}}' | grep "^freeleaps2-rabbitmq\$")
|
||||
echo "$rabbitmq_container_id" > "$WORKING_HOME/.rabbitmq-instance"
|
||||
fi
|
||||
|
||||
pushd $WORKING_HOME
|
||||
|
||||
# Make a user input (Y/N) to continue pull freeleaps.com code and start if N then exit
|
||||
read -p "Do you want to continue to pull freeleaps.com code and start the services? (Y/N): " user_input
|
||||
if [[ "$user_input" == "N" || "$user_input" == "n" ]]; then
|
||||
# Echo as init job completed and exit
|
||||
echo "==> [INIT] DevBox environment initialization completed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 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"
|
||||
@ -1169,8 +1235,6 @@ if [ ! -d $WORKING_HOME/freeleaps ]; then
|
||||
git clone --depth 5 $FRONTEND_GIT_URL
|
||||
else
|
||||
pushd $WORKING_HOME/freeleaps
|
||||
pwd
|
||||
ls -la
|
||||
echo "Git pulling freeleaps.com:3443/products/freeleaps.git"
|
||||
git pull
|
||||
fi
|
||||
@ -1193,7 +1257,7 @@ echo "step 2: Update /home/.devbox/freeleaps/apps/.env"
|
||||
DEFAULT_IP=\$(ip route | grep default | sed -n 's/.*default via \([^ ]*\).*/\1/p')
|
||||
if [[ "\$(lower "\$USE_LOCAL_COMPONENT")" == "true" ]]; then
|
||||
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
|
||||
# Online endpoint info
|
||||
export MONGODB_NAME=freeleaps2
|
||||
@ -1210,7 +1274,7 @@ if [[ "\$(lower "\$USE_LOCAL_COMPONENT")" == "true" ]]; then
|
||||
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_NOTIFICATION_ENDPOINT=http://\$DEFAULT_IP:8003/api/notification/
|
||||
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/
|
||||
@ -1233,7 +1297,7 @@ else
|
||||
export SITE_URL_ROOT=http://localhost/
|
||||
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_PAYMENT_ENDPOINT=http://52.149.35.244:8006/api/payment/
|
||||
export FREELEAPS_NOTIFICATION_ENDPOINT=http://52.149.35.244:8003/api/notification/
|
||||
export FREELEAPS_CENTRAL_STORAGE_ENDPOINT=http://52.149.35.244:8005/api/central_storage/
|
||||
export FREELEAPS_AUTHENTICATION_ENDPOINT=http://52.149.35.244:8004/api/auth/
|
||||
export FREELEAPS_AILAB_ENDPOINT=https://as010-w2-re-vm.mathmast.com:8009/api/
|
||||
@ -1405,8 +1469,7 @@ EOF
|
||||
echo
|
||||
echo "==========================================================="
|
||||
echo "DevBox init completed successfully!"
|
||||
echo " DevBox container ID: $container_id"
|
||||
[[ -f "${WORKING_HOME}/.devbox-instance" ]] && echo " devbox container ID: $(cat "${WORKING_HOME}/.devbox-instance")"
|
||||
echo " DevBox container ID: $WORKING_HOME/.devbox-instance"
|
||||
echo " Repository cloned to: $WORKING_HOME/freeleaps"
|
||||
echo " Backend logs: $WORKING_HOME/logs/backend.logs"
|
||||
echo " Frontend logs: $WORKING_HOME/logs/frontend.logs"
|
||||
@ -1472,6 +1535,15 @@ devbox_deinit_command() {
|
||||
rm -f "$WORKING_HOME/.frontend.pid"
|
||||
fi
|
||||
|
||||
if [[ -f "$WORKING_HOME/.gitea-instance" ]]; then
|
||||
local gitea_container_id
|
||||
gitea_container_id=$(cat "$WORKING_HOME/.gitea-instance")
|
||||
echo "==> Stopping and removing Gitea container: $gitea_container_id"
|
||||
docker stop "$gitea_container_id" &>/dev/null || true
|
||||
docker rm "$gitea_container_id" &>/dev/null || true
|
||||
rm -f "$WORKING_HOME/.gitea-instance"
|
||||
fi
|
||||
|
||||
# Stop and remove MongoDB container
|
||||
if [[ -f "$WORKING_HOME/.mongodb-instance" ]]; then
|
||||
local mongodb_container_id
|
||||
@ -1493,7 +1565,7 @@ devbox_deinit_command() {
|
||||
fi
|
||||
|
||||
# Stop and remove other components
|
||||
local components=("devsvc" "payment" "content" "central_storage" "authentication")
|
||||
local components=("devsvc" "notification" "content" "central_storage" "authentication")
|
||||
for component in "${components[@]}"; do
|
||||
if [[ -f "$WORKING_HOME/.${component}-instance" ]]; then
|
||||
local component_container_id
|
||||
@ -1540,7 +1612,7 @@ devbox_start_command() {
|
||||
|
||||
# If no component is specified, start all components
|
||||
if [[ -z "$COMPONENT" ]]; then
|
||||
COMPONENTS=("mongodb" "rabbitmq" "backend" "frontend" "devsvc" "payment" "content" "central_storage" "authentication")
|
||||
COMPONENTS=("mongodb" "rabbitmq" "backend" "frontend" "devsvc" "content" "central_storage" "authentication")
|
||||
else
|
||||
COMPONENTS=("$COMPONENT")
|
||||
fi
|
||||
@ -1757,7 +1829,7 @@ EOF
|
||||
fi
|
||||
EOF
|
||||
;;
|
||||
"devsvc" | "payment" | "content" | "central_storage" | "authentication")
|
||||
"devsvc" | "content" | "central_storage" | "authentication")
|
||||
echo "==> Starting $comp service..."
|
||||
# Check if the component container file exists
|
||||
local component_container_id_file_path="${WORKING_HOME}/.${comp}-instance"
|
||||
@ -1801,7 +1873,7 @@ devbox_stop_command() {
|
||||
|
||||
# If the DevBox container is not running, exit
|
||||
if [[ -z "$COMPONENT" ]]; then
|
||||
COMPONENTS=("mongodb" "rabbitmq" "backend" "frontend" "devsvc" "payment" "content" "central_storage" "authentication")
|
||||
COMPONENTS=("mongodb" "rabbitmq" "backend" "frontend" "devsvc" "content" "central_storage" "authentication")
|
||||
else
|
||||
COMPONENTS=("$COMPONENT")
|
||||
fi
|
||||
@ -1849,7 +1921,7 @@ devbox_stop_command() {
|
||||
echo "==> Frontend service is not running."
|
||||
fi
|
||||
;;
|
||||
"devsvc" | "payment" | "content" | "central_storage" | "authentication")
|
||||
"devsvc" | "content" | "central_storage" | "authentication")
|
||||
echo "==> Stopping $comp service..."
|
||||
if [[ -f "${WORKING_HOME}/.${comp}-instance" ]]; then
|
||||
local container_id
|
||||
@ -1893,7 +1965,7 @@ devbox_status_command() {
|
||||
|
||||
# If no component is specified, check all components
|
||||
if [[ -z "$COMPONENT" ]]; then
|
||||
COMPONENTS=("mongodb" "rabbitmq" "backend" "frontend" "devsvc" "payment" "content" "central_storage" "authentication")
|
||||
COMPONENTS=("mongodb" "rabbitmq" "backend" "frontend" "devsvc" "content" "central_storage" "authentication")
|
||||
else
|
||||
COMPONENTS=("$COMPONENT")
|
||||
fi
|
||||
@ -1990,20 +2062,6 @@ devbox_status_command() {
|
||||
echo "[RESULT]: devsvc container is not running."
|
||||
fi
|
||||
;;
|
||||
"payment")
|
||||
echo "==> Checking payment service status..."
|
||||
if [[ -f "${WORKING_HOME}/.payment-instance" ]]; then
|
||||
local container_id
|
||||
container_id=$(cat "${WORKING_HOME}/.payment-instance")
|
||||
if docker ps --no-trunc --format '{{.ID}}' | grep -q "^${container_id}\$"; then
|
||||
echo "[RESULT]: payment container is running."
|
||||
else
|
||||
echo "[RESULT]: payment container is not running."
|
||||
fi
|
||||
else
|
||||
echo "[RESULT]: payment container is not running."
|
||||
fi
|
||||
;;
|
||||
"content")
|
||||
echo "==> Checking content service status..."
|
||||
if [[ -f "${WORKING_HOME}/.content-instance" ]]; then
|
||||
@ -2084,7 +2142,7 @@ devbox_restart_command() {
|
||||
fi
|
||||
|
||||
if [[ -z "$COMPONENT" ]]; then
|
||||
COMPONENTS=("mongodb" "rabbitmq" "backend" "frontend" "devsvc" "payment" "content" "central_storage" "authentication")
|
||||
COMPONENTS=("mongodb" "rabbitmq" "backend" "frontend" "devsvc" "content" "central_storage" "authentication")
|
||||
else
|
||||
COMPONENTS=("$COMPONENT")
|
||||
fi
|
||||
@ -2132,7 +2190,7 @@ devbox_restart_command() {
|
||||
echo "==> Frontend service is not running."
|
||||
fi
|
||||
;;
|
||||
"devsvc" | "payment" | "content" | "central_storage" | "authentication")
|
||||
"devsvc" | "content" | "central_storage" | "authentication")
|
||||
echo "==> Stopping $comp service..."
|
||||
if [[ -f "${WORKING_HOME}/.${comp}-instance" ]]; then
|
||||
local container_id
|
||||
@ -2329,7 +2387,7 @@ EOF
|
||||
echo "==> Frontend service is not running."
|
||||
fi
|
||||
;;
|
||||
"devsvc" | "payment" | "content" | "central_storage" | "authentication")
|
||||
"devsvc" | "content" | "central_storage" | "authentication")
|
||||
echo "==> Restarting $comp service..."
|
||||
if [[ -f "${WORKING_HOME}/.${comp}-instance" ]]; then
|
||||
local container_id
|
||||
@ -2683,39 +2741,6 @@ devbox_init_parse_requirements() {
|
||||
fi
|
||||
;;
|
||||
|
||||
# :flag.case
|
||||
--payment-image-repo)
|
||||
if [[ -n ${2+x} ]]; then
|
||||
add_arg '--payment-image-repo' "$2"
|
||||
shift 2
|
||||
else
|
||||
printf "%s\n" "--payment-image-repo requires an argument: --payment-image-repo FREELEAPS_PAYMENT_IMAGE_REPO" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
# :flag.case
|
||||
--payment-image-name)
|
||||
if [[ -n ${2+x} ]]; then
|
||||
add_arg '--payment-image-name' "$2"
|
||||
shift 2
|
||||
else
|
||||
printf "%s\n" "--payment-image-name requires an argument: --payment-image-name FREELEAPS_PAYMENT_IMAGE_NAME" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
# :flag.case
|
||||
--payment-image-tag)
|
||||
if [[ -n ${2+x} ]]; then
|
||||
add_arg '--payment-image-tag' "$2"
|
||||
shift 2
|
||||
else
|
||||
printf "%s\n" "--payment-image-tag requires an argument: --payment-image-tag FREELEAPS_PAYMENT_IMAGE_TAG" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
# :flag.case
|
||||
--content-image-repo)
|
||||
if [[ -n ${2+x} ]]; then
|
||||
@ -2892,10 +2917,6 @@ devbox_init_parse_requirements() {
|
||||
add_arg '--devsvc-image-tag' "latest-linux-arm64"
|
||||
fi
|
||||
|
||||
if [ -z "$(get_arg '--payment-image-tag')" ]; then
|
||||
add_arg '--payment-image-tag' "latest-linux-arm64"
|
||||
fi
|
||||
|
||||
if [ -z "$(get_arg '--content-image-tag')" ]; then
|
||||
add_arg '--content-image-tag' "latest-linux-arm64"
|
||||
fi
|
||||
|
||||
@ -2,7 +2,7 @@ services:
|
||||
gitea:
|
||||
# For apple chip, add: platform: linux/amd64
|
||||
container_name: freeleaps2-gitea
|
||||
platform: linux/arm64
|
||||
platform: linux/${ARCH:-arm64}
|
||||
image: gitea/gitea:latest
|
||||
restart: always
|
||||
ports:
|
||||
@ -19,8 +19,8 @@ services:
|
||||
# For apple chip, add: platform: linux/amd64
|
||||
# For apple chip, you may want to downgrade to public mongo:4.4 for log support
|
||||
container_name: freeleaps2-mongodb
|
||||
platform: linux/arm64
|
||||
image: freeleaps.azurecr.io/mongo:latest-linux-arm64
|
||||
platform: linux/${ARCH:-arm64}
|
||||
image: mongo:latest
|
||||
restart: always
|
||||
ports:
|
||||
- "27017:27017"
|
||||
@ -31,7 +31,7 @@ services:
|
||||
|
||||
rabbitmq:
|
||||
# For apple chip, add: platform: linux/amd64
|
||||
platform: linux/arm64
|
||||
platform: linux/${ARCH:-arm64}
|
||||
container_name: freeleaps2-rabbitmq
|
||||
image: rabbitmq:latest
|
||||
restart: always
|
||||
@ -45,7 +45,7 @@ services:
|
||||
|
||||
devsvc:
|
||||
container_name: devsvc
|
||||
image: freeleaps.azurecr.io/devsvc:1.0.0
|
||||
image: freeleaps/devsvc:${DEVSVC_IMAGE_TAG:-latest-linux-arm64}
|
||||
restart: always
|
||||
environment:
|
||||
- APP_NAME=devsvc
|
||||
@ -79,9 +79,9 @@ services:
|
||||
|
||||
central_storage:
|
||||
container_name: central_storage
|
||||
image: freeleaps.azurecr.io/central_storage:latest-linux-arm64
|
||||
image: freeleaps/central_storage:${CENTRAL_STORAGE_IMAGE_TAG:-latest-linux-arm64}
|
||||
# profiles: [ prod, alpha, dev ]
|
||||
platform: linux/arm64
|
||||
platform: linux/${ARCH:-arm64}
|
||||
restart: always
|
||||
environment:
|
||||
- APP_NAME=central_storage
|
||||
@ -111,9 +111,9 @@ services:
|
||||
|
||||
authentication:
|
||||
container_name: authentication
|
||||
image: freeleaps.azurecr.io/authentication:latest-linux-arm64
|
||||
image: freeleaps/authentication:${AUTHENTICATION_IMAGE_TAG:-latest-linux-arm64}
|
||||
# profiles: [ prod, alpha, dev ]
|
||||
platform: linux/arm64
|
||||
platform: linux/${ARCH:-arm64}
|
||||
restart: always
|
||||
environment:
|
||||
- APP_NAME=authentication
|
||||
@ -145,9 +145,9 @@ services:
|
||||
|
||||
content:
|
||||
container_name: content
|
||||
image: freeleaps.azurecr.io/content:latest-linux-arm64
|
||||
image: freeleaps/content:${CONTENT_IMAGE_TAG:-latest-linux-arm64}
|
||||
# profiles: [ prod, alpha, dev ]
|
||||
platform: linux/arm64
|
||||
platform: linux/${ARCH:-arm64}
|
||||
restart: always
|
||||
environment:
|
||||
- APP_NAME=content
|
||||
@ -176,9 +176,9 @@ services:
|
||||
|
||||
notification:
|
||||
container_name: notification
|
||||
image: freeleaps.azurecr.io/notification:latest-linux-arm64
|
||||
image: freeleaps/notification:${NOTIFICATION_IMAGE_TAG:-latest-linux-arm64}
|
||||
# profiles: [ prod, alpha, dev ]
|
||||
platform: linux/arm64
|
||||
platform: linux/${ARCH:-arm64}
|
||||
restart: always
|
||||
environment:
|
||||
- APP_NAME=notification
|
||||
|
||||
Loading…
Reference in New Issue
Block a user