diff --git a/devbox/devbox.local/cli/devbox b/devbox/devbox.local/cli/devbox index fe1ce9d..9f37a08 100644 --- a/devbox/devbox.local/cli/devbox +++ b/devbox/devbox.local/cli/devbox @@ -105,6 +105,10 @@ devbox_init_usage() { printf " --authentication-image-repo -V [Optional] : Specifies the repository for authentication component.\n" printf " --authentication-image-name -L [Optional] : Specifies the image name for authentication component.\n" printf " --authentication-image-tag -W [Optional] : Specifies the image tag for authentication component. Default: latest.\n" + printf " --chat-image-repo -B [Optional] : Specifies the repository for chat component.\n" + printf " --chat-image-name -N [Optional] : Specifies the image name for chat component.\n" + printf " --chat-image-tag -T [Optional] : Specifies the image tag for chat component. Default: latest.\n" + printf " --force -f [Optional] : Force initialization even if resources already exist.\n\n" printf "Global Arguments\n" @@ -151,8 +155,8 @@ devbox_start_usage() { printf " devbox start : Start the local development environment based on DevBox container.\n\n" printf "Arguments\n" - printf " --component COMPONENT [Optional] : Specifies the name of the component to start (e.g., mongodb, rabbitmq, backend, frontend, devsvc, content, central_storage, authentication).\n\n" - printf " --freeleaps-endpoint -e [Optional] : Specifies the Freeleaps.com endpoint to start in the DevBox container.\n\n" + printf " --component COMPONENT [Optional] : Specifies the name of the component to start (e.g., mongodb, rabbitmq, devsvc, content, central_storage, notification, chat, authentication).\n\n" + printf " --freeleaps-endpoint -e [Optional] : Specifies the Freeleaps.com endpoint backend & frontend to start in the DevBox container.\n\n" printf "Global Arguments\n" printf " --help, -h : Show this help message and exit.\n\n" @@ -174,7 +178,7 @@ devbox_stop_usage() { printf "Command\n" printf " devbox stop : Stop the local development environment based on DevBox container.\n\n" printf "Arguments\n" - printf " --component -c [Optional] : Specifies the name of the component to stop (e.g., mongodb, rabbitmq, devbox, devsvc, content, central_storage, authentication).\n\n" + printf " --component -c [Optional] : Specifies the name of the component to stop (e.g., mongodb, rabbitmq, devbox, devsvc, content, central_storage, notification, chat, authentication).\n\n" printf "Global Arguments\n" printf " --help -h : Show this help message and exit.\n\n" printf "Examples\n" @@ -195,7 +199,7 @@ devbox_status_usage() { printf " devbox status : Display the status of the local development environment based on DevBox container.\n\n" printf "Arguments\n" - printf " --component -c [Optional] : Specifies the component to show status (e.g., devbox, devsvc, etc.).\n\n" + printf " --component -c [Optional] : Specifies the component to show status (e.g., devbox, devsvc, content, central_storage, notification, chat, authentication).\n\n" printf "Global Arguments\n" printf " --help -h : Show this help message and exit.\n\n" @@ -217,9 +221,9 @@ devbox_restart_usage() { printf "Command\n" printf " devbox restart : Restart the local development environment based on DevBox container.\n\n" printf "Arguments\n" - printf " --component -c [Optional] : Specifies the component to restart (e.g., backend, frontend, etc.).\n" - printf " --freeleaps-endpoint -e [Optional] : Specifies the Freeleaps.com endpoint to restart in the DevBox container.\n" - printf " --force -f : Force the restart operation without prompt.\n\n" + printf " --component -c [Optional] : Specifies the component to restart (e.g., devbox, devsvc, content, central_storage, notification, chat, authentication).\n" + printf " --freeleaps-endpoint -e [Optional] : Specifies the Freeleaps.com backend & frontend to restart in the DevBox container.\n" + printf " --force -f [Optional] : Force the restart operation without prompt.\n\n" printf "Global Arguments\n" printf " --help -h : Show this help message and exit.\n" printf "Examples\n" @@ -430,8 +434,11 @@ check_docker_running() { } # 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") +# local_components_ports_keys=("devsvc" "notification" "content" "central_storage" "chat" "authentication") + +declare -g local_components_ports_keys=("devsvc" "notification" "content" "central_storage" "chat" "authentication") + +local_components_ports_values=("8007" "8003" "8013" "8005" "8012" "8004") # Get the port number for a local component get_port() { @@ -494,6 +501,10 @@ devbox_init_command() { local NOTIFICATION_IMAGE="$args_notification_image_image" # --notification-image-image local NOTIFICATION_TAG="$args_notification_image_tag" # --notification-image-tag + local CHAT_REPO="$args_chat_image_repo" # --chat-image-repo + local CHAT_IMAGE="$args_chat_image_image" # --chat-image-image + local CHAT_TAG="$args_chat_image_tag" # --chat-image-tag + local CUSTOM_GIT_REPO="$args_custom_git_repo" # --custom-git-repo # --force flag to overwrite existing resources @@ -527,12 +538,16 @@ devbox_init_command() { 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 CHAT_REPO="$(get_arg '--chat-image-repo')" + local CHAT_IMAGE="$(get_arg '--chat-image-name')" + local CHAT_TAG="$(get_arg '--chat-image-tag')" + local CUSTOM_GIT_REPO="$(get_arg '--custom-git-repo')" local FORCE_INIT="$(get_arg '--force')" local is_pull_all_components=true - local components=("devsvc" "notification" "content" "central_storage" "authentication") + local components=("devsvc" "notification" "content" "central_storage" "chat" "authentication") local start_components=() # Check if using local components @@ -583,6 +598,12 @@ devbox_init_command() { elif [[ "$ARCH" == "arm64" && "$component" == "notification" ]]; then NOTIFICATION_TAG="latest-linux-arm64" fi + + if [[ "$ARCH" == "amd64" && "$component" == "chat" ]]; then + CHAT_TAG="latest-linux-amd64" + elif [[ "$ARCH" == "arm64" && "$component" == "chat" ]]; then + CHAT_TAG="latest-linux-arm64" + fi done @@ -621,6 +642,9 @@ devbox_init_command() { echo " NOTIFICATION_REPO = $NOTIFICATION_REPO" echo " NOTIFICATION_IMAGE= $NOTIFICATION_IMAGE" echo " NOTIFICATION_TAG = $NOTIFICATION_TAG" + echo " CHAT_REPO = $CHAT_REPO" + echo " CHAT_IMAGE = $CHAT_IMAGE" + echo " CHAT_TAG = $CHAT_TAG" echo " FORCE_INIT = $FORCE_INIT" echo @@ -779,7 +803,54 @@ devbox_init_command() { # record container id, DEVBOX_FRONTEND_PORT, DEVBOX_BACKEND_PORT echo "$container_id" > "$WORKING_HOME/.devbox-instance" echo "$DEVBOX_FRONTEND_PORT" > "$WORKING_HOME/.devbox-frontend-port" - echo "$DEVBOX_BACKEND_PORT" > "$WORKING_HOME/.devbox-backend-port" + echo "$DEVBOX_BACKEND_PORT" > "$WORKING_HOME/.devbox-backend-port"] + + # Check if username and password are set + if [[ -z "$FREELEAPS_USERNAME" || -z "$FREELEAPS_PASSWORD" ]]; then + echo "Warining: Username and password are required to pull freeleaps.com code." + echo "==> [INIT] DevBox environment initialization completed." + exit 1 + fi + + # Test if the user can access the freeleaps.com repository + echo "==> Testing access to freeleaps.com repository..." + if ! git ls-remote "https://$FREELEAPS_USERNAME:$FREELEAPS_PASSWORD@freeleaps.com:3443/products/freeleaps.git" &>/dev/null; then + echo "ERROR: Failed to access freeleaps.com repository. Please check your username and password." + echo "==> [INIT] DevBox environment initialization completed successfully, but access to the freeleaps.com repository failed." + exit 1 + fi + + DOVBOX_CLI_DIR=$(pwd) + + FREELEAPS_DIR="$WORKING_HOME/freeleaps" + FRONTEND_GIT_URL="https://$FREELEAPS_USERNAME:$FREELEAPS_PASSWORD@freeleaps.com:3443/products/freeleaps.git" + # Check if freeleaps2-frontend exists, if not git clone it + if [ ! -d "$FREELEAPS_DIR" ]; then + pushd "$WORKING_HOME" > /dev/null + echo "Git cloning freeleaps.com:3443/products/freeleaps.git 1" + git clone --depth 5 $FRONTEND_GIT_URL + else + echo "Git pulling 2" + pushd "$FREELEAPS_DIR" > /dev/null + # Check $WORKING_HOME/freeleaps exists and it is a git repository, if not git clone it + if ! git rev-parse --is-inside-work-tree &>/dev/null; then + popd > /dev/null # Exit from $FREELEAPS_DIR + rm -rf "$FREELEAPS_DIR" # Remove $FREELEAPS_DIR + rmdir "$FREELEAPS_DIR" # Remove $FREELEAPS_DIR + + # Git clone freeleaps.com:3443/products/freeleaps.git + echo "Cloning repository again: $FRONTEND_GIT_URL" + sudo chown -R "$OWNER_GROUP" "$WORKING_HOME" + git clone --depth 5 "$FRONTEND_GIT_URL" + else + echo "Git pulling freeleaps.com:3443/products/freeleaps.git" + git pull + fi + + popd > /dev/null + fi + + pushd $DOVBOX_CLI_DIR > /dev/null # ------------------------------------------------------------------- # 6. linbwang: pull and start other components @@ -789,6 +860,9 @@ echo "==> [INIT] Starting Freeleaps services... Use Local component $USE_LOCAL_C export ARCH="$ARCH" export WORKING_HOME="$WORKING_HOME" + + + # Check if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then @@ -799,7 +873,8 @@ if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then export CENTRAL_STORAGE_IMAGE_TAG="$CENTRAL_STORAGE_TAG" export AUTHENTICATION_IMAGE_TAG="$AUTHENTICATION_TAG" export NOTIFICATION_IMAGE_TAG="$NOTIFICATION_TAG" - + export CHAT_IMAGE_TAG="$CHAT_TAG" + # Check if gitea_data_backup.tar.gz exists at current script directory, if not exit if [[ ! -f "gitea_data_backup.tar.gz" ]]; then echo "ERROR: gitea_data_backup.tar.gz not found. Please make sure it exists in the current directory." @@ -814,46 +889,8 @@ if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then echo "ERROR: Failed to extract gitea data backup." exit 1 fi - - - - echo "==> Starting Gitea, MongoDB, RabbitMQ containers..." - # 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) - docker-compose -f docker-compose.dev.arm64.new.yaml up -d mongodb rabbitmq gitea - - sleep 5 - - # start component service from start_components array - docker-compose -f docker-compose.dev.arm64.new.yaml up -d "${start_components[@]}" - - - gitea_container_id=$(docker ps --no-trunc -a --filter "name=^freeleaps2-gitea$" --format "{{.ID}}") - echo "$gitea_container_id" > "$WORKING_HOME/.gitea-instance" - - mongo_container_id=$(docker ps --no-trunc -a --filter "name=^freeleaps2-mongodb$" --format "{{.ID}}") - echo "$mongo_container_id" > "$WORKING_HOME/.mongodb-instance" - - rabbitmq_container_id=$(docker ps --no-trunc -a --filter "name=^freeleaps2-rabbitmq$" --format "{{.ID}}") - echo "$rabbitmq_container_id" > "$WORKING_HOME/.rabbitmq-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" - - # Get the owner group of the WORKING_HOME - if [[ "$(uname)" == "Darwin" ]]; then - OWNER_GROUP=$(stat -f "%Su:%Sg" "${WORKING_HOME}") - else - OWNER_GROUP=$(stat -c "%U:%G" "${WORKING_HOME}") - fi - - # Echo OWNER_GROUP + # Echo OWNER_GROUP echo "OWNER_GROUP: $OWNER_GROUP" # Copy gitea data to the gitea container @@ -879,17 +916,52 @@ if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then exit 1 fi - # restart gitea container - docker-compose -f docker-compose.dev.arm64.new.yaml restart rabbitmq - sleep 10 - docker-compose -f docker-compose.dev.arm64.new.yaml restart gitea - sleep 5 + mkdir -p ${WORKING_HOME}/logs + mkdir -p ${WORKING_HOME}/logs/devsvc + mkdir -p ${WORKING_HOME}/logs/content + mkdir -p ${WORKING_HOME}/logs/central_storage + mkdir -p ${WORKING_HOME}/logs/authentication + mkdir -p ${WORKING_HOME}/logs/notification + mkdir -p ${WORKING_HOME}/logs/chat - # restart notification if it is in the start_components - if [[ " ${start_components[@]} " =~ "notification" ]]; then - docker-compose -f docker-compose.dev.arm64.new.yaml restart notification + + # for each component create log directory + for component in "${start_components[@]}"; do + if [[ ! -d "${WORKING_HOME}/log/${component}" ]]; then + mkdir -p "${WORKING_HOME}/log/${component}" + fi + done + + # Start Gitea, MongoDB, RabbitMQ and other components containers + echo "===> start Gitea, MongoDB, RabbitMQ and other components containers" + docker-compose -f docker-compose.dev.arm64.new.yaml up -d mongodb rabbitmq gitea "${start_components[@]}" + + gitea_container_id=$(docker ps --no-trunc -a --filter "name=^freeleaps2-gitea$" --format "{{.ID}}") + echo "$gitea_container_id" > "$WORKING_HOME/.gitea-instance" + + mongo_container_id=$(docker ps --no-trunc -a --filter "name=^freeleaps2-mongodb$" --format "{{.ID}}") + echo "$mongo_container_id" > "$WORKING_HOME/.mongodb-instance" + + rabbitmq_container_id=$(docker ps --no-trunc -a --filter "name=^freeleaps2-rabbitmq$" --format "{{.ID}}") + echo "$rabbitmq_container_id" > "$WORKING_HOME/.rabbitmq-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" + + # Get the owner group of the WORKING_HOME + if [[ "$(uname)" == "Darwin" ]]; then + OWNER_GROUP=$(stat -f "%Su:%Sg" "${WORKING_HOME}") + else + OWNER_GROUP=$(stat -c "%U:%G" "${WORKING_HOME}") fi + else echo '============================================' echo ' ===> Using online components for Freeleaps services.' @@ -940,38 +1012,6 @@ fi IS_START_FRONTEND=true -# Check if username and password are set -if [[ -z "$FREELEAPS_USERNAME" || -z "$FREELEAPS_PASSWORD" ]]; then - echo "Warining: Username and password are required to pull freeleaps.com code." - echo "==> [INIT] DevBox environment initialization completed." - exit 1 -fi - -# Test if the user can access the freeleaps.com repository -echo "==> Testing access to freeleaps.com repository..." -if ! git ls-remote "https://$FREELEAPS_USERNAME:$FREELEAPS_PASSWORD@freeleaps.com:3443/products/freeleaps.git" &>/dev/null; then - echo "ERROR: Failed to access freeleaps.com repository. Please check your username and password." - echo "==> [INIT] DevBox environment initialization completed successfully, but access to the freeleaps.com repository failed." - exit 1 -fi - -FRONTEND_GIT_URL="https://$FREELEAPS_USERNAME:$FREELEAPS_PASSWORD@freeleaps.com:3443/products/freeleaps.git" -# 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" - git clone --depth 5 $FRONTEND_GIT_URL -else - pushd $WORKING_HOME/freeleaps - # Check $WORKING_HOME/freeleaps exists and it is a git repository, if not git clone it - if ! git rev-parse --is-inside-work-tree &>/dev/null; then - echo "Git cloning freeleaps.com:3443/products/freeleaps.git" - git clone --depth 5 $FRONTEND_GIT_URL - else - echo "Git pulling freeleaps.com:3443/products/freeleaps.git" - git pull - fi -fi - # Run banckend service and frontend service in the container docker exec -i "$DEVBOX_NAME" bash < Starting $comp service..." # Check if the component container file exists local component_container_id_file_path="${WORKING_HOME}/.${comp}-instance" @@ -1607,7 +1647,7 @@ devbox_stop_command() { # If the DevBox container is not running, exit if [[ -z "$COMPONENT" ]]; then - COMPONENTS=("gitea" "mongodb" "rabbitmq" "devbox" "devsvc" "notification" "content" "central_storage" "authentication") + COMPONENTS=("gitea" "mongodb" "rabbitmq" "devbox" "devsvc" "notification" "content" "central_storage" "chat" "authentication") else COMPONENTS=("$COMPONENT") fi @@ -1633,7 +1673,7 @@ devbox_stop_command() { fi ;; - "gitea"| "mongodb"| "rabbitmq" | "devsvc" | "notification" | "content" | "central_storage" | "authentication") + "gitea"| "mongodb"| "rabbitmq" | "devsvc" | "notification" | "content" | "central_storage" | "chat" | "authentication") if [[ -f "${WORKING_HOME}/.${comp}-instance" ]]; then local container_id container_id=$(cat "${WORKING_HOME}/.${comp}-instance") @@ -1679,7 +1719,7 @@ devbox_status_command() { # If no component is specified, check all components if [[ -z "$COMPONENT" ]]; then - COMPONENTS=("mongodb" "rabbitmq" "devbox" "devsvc" "notification" "content" "central_storage" "authentication") + COMPONENTS=("mongodb" "rabbitmq" "devbox" "devsvc" "notification" "content" "central_storage" "chat" "authentication") else COMPONENTS=("$COMPONENT") fi @@ -1732,7 +1772,7 @@ devbox_status_command() { fi ;; - "devsvc" | "notification" | "content" | "central_storage" | "authentication") + "devsvc" | "notification" | "content" | "central_storage" | "chat" | "authentication") echo "==> Checking $comp service status..." if [[ -f "${WORKING_HOME}/.${comp}-instance" ]]; then local container_id @@ -1777,7 +1817,7 @@ devbox_restart_command() { if [[ "$USE_LOCAL_COMPONENT" == "true" ]]; then echo "==> Using local components..." if [[ -z "$COMPONENT" ]]; then - COMPONENTS=("gitea" "mongodb" "rabbitmq" "devbox" "devsvc" "notification" "content" "central_storage" "authentication") + COMPONENTS=("gitea" "mongodb" "rabbitmq" "devbox" "devsvc" "notification" "content" "central_storage" "chat" "authentication") else COMPONENTS=("$COMPONENT") fi @@ -1786,7 +1826,7 @@ devbox_restart_command() { if [[ -z "$COMPONENT" ]]; then COMPONENTS=("mongodb" "rabbitmq" "devbox") else - if [[ "$COMPONENT" == "devsvc" || "$COMPONENT" == "notification" || "$COMPONENT" == "content" || "$COMPONENT" == "central_storage" || "$COMPONENT" == "authentication" ]]; then + if [[ "$COMPONENT" == "devsvc" || "$COMPONENT" == "notification" || "$COMPONENT" == "content" || "$COMPONENT" == "central_storage" || "$COMPONENT" == "chat" || "$COMPONENT" == "authentication" ]]; then echo "ERROR: Remote component $COMPONENT cannot be restarted." exit 1 fi @@ -1813,7 +1853,7 @@ devbox_restart_command() { fi ;; - "gitea" | "mongodb" | "rabbitmq" | "devsvc" | "notification" | "content" | "central_storage" | "authentication") + "gitea" | "mongodb" | "rabbitmq" | "devsvc" | "notification" | "content" | "central_storage" | "chat" | "authentication") if [[ -f "${WORKING_HOME}/.${comp}-instance" ]]; then local container_id @@ -1834,7 +1874,7 @@ devbox_restart_command() { # Start the specified components for comp in "${COMPONENTS[@]}"; do case "$comp" in - "gitea" | "mongodb" | "rabbitmq" | "devbox" | "devsvc" | "notification" | "content" | "central_storage" | "authentication") + "gitea" | "mongodb" | "rabbitmq" | "devbox" | "devsvc" | "notification" | "content" | "central_storage" | "chat" | "authentication") echo "==> Restarting $comp service..." if [[ -f "${WORKING_HOME}/.${comp}-instance" ]]; then local container_id @@ -2415,6 +2455,36 @@ devbox_init_parse_requirements() { fi ;; # :flag.case + --chat-image-repo | -B) + if [[ -n ${2+x} ]]; then + add_arg '--chat-image-repo' "$2" + shift 2 + else + printf "%s\n" "--chat-image-repo requires an argument: --chat-image-repo FREELEAPS_CHAT_IMAGE_REPO" >&2 + exit 1 + fi + ;; + # :flag.case + --chat-image-name | -N) + if [[ -n ${2+x} ]]; then + add_arg '--chat-image-name' "$2" + shift 2 + else + printf "%s\n" "--chat-image-name requires an argument: --chat-image-name FREELEAPS_CHAT_IMAGE_NAME" >&2 + exit 1 + fi + ;; + # :flag.case + --chat-image-tag | -T) + if [[ -n ${2+x} ]]; then + add_arg '--chat-image-tag' "$2" + shift 2 + else + printf "%s\n" "--chat-image-tag requires an argument: --chat-image-tag FREELEAPS_CHAT_IMAGE_TAG" >&2 + exit 1 + fi + ;; + # :flag.case --force | -f) # :flag.case_no_arg add_arg '--force' '1' diff --git a/devbox/devbox.local/cli/docker-compose.dev.arm64.new.yaml b/devbox/devbox.local/cli/docker-compose.dev.arm64.new.yaml index f5f74ea..c203f24 100644 --- a/devbox/devbox.local/cli/docker-compose.dev.arm64.new.yaml +++ b/devbox/devbox.local/cli/docker-compose.dev.arm64.new.yaml @@ -14,6 +14,12 @@ services: - ${WORKING_HOME}/freeleaps2-gitea:/data:Z networks: - devbox_freeleaps2-network + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:3000/"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 40s mongodb: # For apple chip, add: platform: linux/amd64 @@ -29,6 +35,12 @@ services: networks: - devbox_freeleaps2-network command: ["mongod", "--bind_ip_all"] + healthcheck: + test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 40s rabbitmq: # For apple chip, add: platform: linux/amd64 @@ -43,11 +55,23 @@ services: - ${WORKING_HOME}/freeleaps2-rabbitmq-data:/var/lib/rabbitmq networks: - devbox_freeleaps2-network + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "status"] + interval: 10s + timeout: 5s + retries: 5 devsvc: container_name: devsvc image: freeleaps/devsvc:${DEVSVC_IMAGE_TAG:-latest-linux-arm64} restart: always + depends_on: + mongodb: + condition: service_healthy + rabbitmq: + condition: service_healthy + gitea: + condition: service_healthy environment: - APP_NAME=devsvc - SERVICE_API_ACCESS_HOST=localhost @@ -81,7 +105,6 @@ services: central_storage: container_name: central_storage image: freeleaps/central_storage:${CENTRAL_STORAGE_IMAGE_TAG:-latest-linux-arm64} - # profiles: [ prod, alpha, dev ] platform: linux/${ARCH:-arm64} restart: always environment: @@ -113,7 +136,6 @@ services: authentication: container_name: authentication image: freeleaps/authentication:${AUTHENTICATION_IMAGE_TAG:-latest-linux-arm64} - # profiles: [ prod, alpha, dev ] platform: linux/${ARCH:-arm64} restart: always environment: @@ -147,7 +169,6 @@ services: content: container_name: content image: freeleaps/content:${CONTENT_IMAGE_TAG:-latest-linux-arm64} - # profiles: [ prod, alpha, dev ] platform: linux/${ARCH:-arm64} restart: always environment: @@ -178,9 +199,11 @@ services: notification: container_name: notification image: freeleaps/notification:${NOTIFICATION_IMAGE_TAG:-latest-linux-arm64} - # profiles: [ prod, alpha, dev ] platform: linux/${ARCH:-arm64} restart: always + depends_on: + rabbitmq: + condition: service_healthy environment: - APP_NAME=notification - SERVICE_API_ACCESS_HOST=localhost @@ -243,6 +266,54 @@ services: - type: bind source: /var/lib/docker/app/payment/log target: /app/log/payment + chat: + container_name: chat + build: + context: ${WORKING_HOME}/freeleaps/apps + dockerfile: ${WORKING_HOME}/freeleaps/apps/chat/Dockerfile + restart: always + depends_on: + mongodb: + condition: service_healthy + rabbitmq: + condition: service_healthy + ports: + - 8012:8012 + environment: + - APP_NAME=chat + - CERT_PATH=/app/certs + - EMAIL_FROM=freeleaps@freeleaps.com + - MONGODB_NAME=freeleaps2 + - MONGODB_URI=mongodb://freeleaps2-mongodb:27017/ + - SITE_URL_ROOT=http://localhost + - JWT_SECRET_KEY=8f87ca8c3c9c3df09a9c78e0adb0927855568f6072d9efc892534aee35f5867b + - JWT_ALGORITHM=HS256 + - SERVICE_API_ACCESS_PORT=8012 + - RABBITMQ_HOST=freeleaps2-rabbitmq + - RABBITMQ_PORT=5672 + - LOG_BASE_PATH=/app/log/freeleaps-chat + - BACKEND_LOG_FILE_NAME=freeleaps-chat.log + - APPLICATION_ACTIVITY_LOG=freeleaps-chat.application.log + - FREELEAPS_ENV=dev + - FREELEAPS_CHAT_ENDPOINT=http://freeleaps-alpha.com/api/chat/ + - FREELEAPS_DEVSVC_ENDPOINT=http://devsvc:8007/api/devsvc/ + - FREELEAPS_CONTENT_ENDPOINT=http://content:8013/api/content/ + - FREELEAPS_NOTIFICATION_ENDPOINT=http://notification:8003/api/notification/ + - FREELEAPS_CENTRAL_STORAGE_ENDPOINT=http://central_storage:8005/api/central_storage/ + - FREELEAPS_AUTHENTICATION_ENDPOINT=http://authentication:8004/api/auth/ + - TZ=Asia/Shanghai + command: + # Use a conditional check for RabbitMQ in alpha profile + - /bin/sh + - -c + - | + uvicorn chat.main:app --reload --host=0.0.0.0 --port=8012 --workers 4 --timeout-keep-alive 120 --log-level info + volumes: + - type: bind + source: ${WORKING_HOME}/logs/freeleaps-chat + target: /app/log/freeleaps-chat + networks: + - devbox_freeleaps2-network volumes: freeleaps2-mongodb-data: freeleaps2-gitea-data: diff --git a/devbox/devbox.local/cli/freeleaps b/devbox/devbox.local/cli/freeleaps new file mode 160000 index 0000000..ca58e0b --- /dev/null +++ b/devbox/devbox.local/cli/freeleaps @@ -0,0 +1 @@ +Subproject commit ca58e0b8f9d91c297da64c440b799ff913cb24f2