diff --git a/app/central_storage/Dockerfile b/app/central_storage/Dockerfile deleted file mode 100644 index 9aeaf6c..0000000 --- a/app/central_storage/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -# Dockerfile for Python Service -FROM python:3.10-slim - -# Set the working directory inside the container -WORKDIR /app - -# Copy the requirements.txt to the working directory and install dependencies -COPY requirements.txt ./ -RUN pip install --no-cache-dir -r requirements.txt - -# Copy the application code to the working directory -COPY . /app - -# Expose the port used by the FastAPI app -EXPOSE 8005 - - -# Run the application using the start script -CMD ["uvicorn", "app.central_storage.webapi.main:app", "--reload", "--port=8005", "--host=0.0.0.0"] diff --git a/app/central_storage/webapi/providers/database.py b/app/central_storage/webapi/providers/database.py deleted file mode 100644 index 8dbb9e9..0000000 --- a/app/central_storage/webapi/providers/database.py +++ /dev/null @@ -1,25 +0,0 @@ -from infra.config.app_settings import app_settings -from beanie import init_beanie -from motor.motor_asyncio import AsyncIOMotorClient -from app.central_storage.backend.models import backend_models - - -def register(app): - app.debug = "mongo_debug" - app.title = "mongo_name" - - @app.on_event("startup") - async def start_database(): - await initiate_database() - - -async def initiate_database(): - client = AsyncIOMotorClient( - app_settings.MONGODB_URI, - serverSelectionTimeoutMS=60000, - minPoolSize=5, # Minimum number of connections in the pool - maxPoolSize=20, # Maximum number of connections in the pool - ) - await init_beanie( - database=client[app_settings.MONGODB_NAME], document_models=backend_models - ) diff --git a/app/authentication/Dockerfile b/apps/authentication/Dockerfile similarity index 100% rename from app/authentication/Dockerfile rename to apps/authentication/Dockerfile diff --git a/app/authentication/backend/application/signin_hub.py b/apps/authentication/backend/application/signin_hub.py similarity index 100% rename from app/authentication/backend/application/signin_hub.py rename to apps/authentication/backend/application/signin_hub.py diff --git a/app/authentication/backend/business/signin_manager.py b/apps/authentication/backend/business/signin_manager.py similarity index 100% rename from app/authentication/backend/business/signin_manager.py rename to apps/authentication/backend/business/signin_manager.py diff --git a/app/authentication/backend/infra/auth/user_auth_handler.py b/apps/authentication/backend/infra/auth/user_auth_handler.py similarity index 100% rename from app/authentication/backend/infra/auth/user_auth_handler.py rename to apps/authentication/backend/infra/auth/user_auth_handler.py diff --git a/app/authentication/backend/infra/code_management/depot_handler.py b/apps/authentication/backend/infra/code_management/depot_handler.py similarity index 100% rename from app/authentication/backend/infra/code_management/depot_handler.py rename to apps/authentication/backend/infra/code_management/depot_handler.py diff --git a/app/authentication/backend/infra/code_management/gitea/__init__.py b/apps/authentication/backend/infra/code_management/gitea/__init__.py similarity index 100% rename from app/authentication/backend/infra/code_management/gitea/__init__.py rename to apps/authentication/backend/infra/code_management/gitea/__init__.py diff --git a/app/authentication/backend/infra/code_management/gitea/api_object_base.py b/apps/authentication/backend/infra/code_management/gitea/api_object_base.py similarity index 100% rename from app/authentication/backend/infra/code_management/gitea/api_object_base.py rename to apps/authentication/backend/infra/code_management/gitea/api_object_base.py diff --git a/app/authentication/backend/infra/code_management/gitea/api_objects.py b/apps/authentication/backend/infra/code_management/gitea/api_objects.py similarity index 100% rename from app/authentication/backend/infra/code_management/gitea/api_objects.py rename to apps/authentication/backend/infra/code_management/gitea/api_objects.py diff --git a/app/authentication/backend/infra/code_management/gitea/exceptions.py b/apps/authentication/backend/infra/code_management/gitea/exceptions.py similarity index 100% rename from app/authentication/backend/infra/code_management/gitea/exceptions.py rename to apps/authentication/backend/infra/code_management/gitea/exceptions.py diff --git a/app/authentication/backend/infra/code_management/gitea/gitea.py b/apps/authentication/backend/infra/code_management/gitea/gitea.py similarity index 100% rename from app/authentication/backend/infra/code_management/gitea/gitea.py rename to apps/authentication/backend/infra/code_management/gitea/gitea.py diff --git a/app/authentication/backend/infra/code_management/readme.md b/apps/authentication/backend/infra/code_management/readme.md similarity index 100% rename from app/authentication/backend/infra/code_management/readme.md rename to apps/authentication/backend/infra/code_management/readme.md diff --git a/app/authentication/backend/infra/user_profile/user_profile_handler.py b/apps/authentication/backend/infra/user_profile/user_profile_handler.py similarity index 100% rename from app/authentication/backend/infra/user_profile/user_profile_handler.py rename to apps/authentication/backend/infra/user_profile/user_profile_handler.py diff --git a/app/authentication/backend/models/__init__.py b/apps/authentication/backend/models/__init__.py similarity index 100% rename from app/authentication/backend/models/__init__.py rename to apps/authentication/backend/models/__init__.py diff --git a/app/authentication/backend/models/gitea/__init__.py b/apps/authentication/backend/models/gitea/__init__.py similarity index 100% rename from app/authentication/backend/models/gitea/__init__.py rename to apps/authentication/backend/models/gitea/__init__.py diff --git a/app/authentication/backend/models/gitea/constants.py b/apps/authentication/backend/models/gitea/constants.py similarity index 100% rename from app/authentication/backend/models/gitea/constants.py rename to apps/authentication/backend/models/gitea/constants.py diff --git a/app/authentication/backend/models/gitea/models.py b/apps/authentication/backend/models/gitea/models.py similarity index 100% rename from app/authentication/backend/models/gitea/models.py rename to apps/authentication/backend/models/gitea/models.py diff --git a/app/authentication/backend/models/gitea/readme.md b/apps/authentication/backend/models/gitea/readme.md similarity index 100% rename from app/authentication/backend/models/gitea/readme.md rename to apps/authentication/backend/models/gitea/readme.md diff --git a/app/authentication/backend/models/permission/constants.py b/apps/authentication/backend/models/permission/constants.py similarity index 100% rename from app/authentication/backend/models/permission/constants.py rename to apps/authentication/backend/models/permission/constants.py diff --git a/app/authentication/backend/models/user/__init__.py b/apps/authentication/backend/models/user/__init__.py similarity index 100% rename from app/authentication/backend/models/user/__init__.py rename to apps/authentication/backend/models/user/__init__.py diff --git a/app/authentication/backend/models/user/constants.py b/apps/authentication/backend/models/user/constants.py similarity index 100% rename from app/authentication/backend/models/user/constants.py rename to apps/authentication/backend/models/user/constants.py diff --git a/app/authentication/backend/models/user/models.py b/apps/authentication/backend/models/user/models.py similarity index 100% rename from app/authentication/backend/models/user/models.py rename to apps/authentication/backend/models/user/models.py diff --git a/app/authentication/backend/models/user_profile/__init__.py b/apps/authentication/backend/models/user_profile/__init__.py similarity index 100% rename from app/authentication/backend/models/user_profile/__init__.py rename to apps/authentication/backend/models/user_profile/__init__.py diff --git a/app/authentication/backend/models/user_profile/models.py b/apps/authentication/backend/models/user_profile/models.py similarity index 100% rename from app/authentication/backend/models/user_profile/models.py rename to apps/authentication/backend/models/user_profile/models.py diff --git a/app/authentication/backend/services/auth/user_auth_service.py b/apps/authentication/backend/services/auth/user_auth_service.py similarity index 100% rename from app/authentication/backend/services/auth/user_auth_service.py rename to apps/authentication/backend/services/auth/user_auth_service.py diff --git a/app/authentication/backend/services/code_depot/code_depot_service.py b/apps/authentication/backend/services/code_depot/code_depot_service.py similarity index 100% rename from app/authentication/backend/services/code_depot/code_depot_service.py rename to apps/authentication/backend/services/code_depot/code_depot_service.py diff --git a/app/authentication/backend/services/notification/notification_service.py b/apps/authentication/backend/services/notification/notification_service.py similarity index 100% rename from app/authentication/backend/services/notification/notification_service.py rename to apps/authentication/backend/services/notification/notification_service.py diff --git a/app/authentication/backend/services/user/user_management_service.py b/apps/authentication/backend/services/user/user_management_service.py similarity index 100% rename from app/authentication/backend/services/user/user_management_service.py rename to apps/authentication/backend/services/user/user_management_service.py diff --git a/app/authentication/common/config/app_settings.py b/apps/authentication/common/config/app_settings.py similarity index 100% rename from app/authentication/common/config/app_settings.py rename to apps/authentication/common/config/app_settings.py diff --git a/app/authentication/requirements.txt b/apps/authentication/requirements.txt similarity index 100% rename from app/authentication/requirements.txt rename to apps/authentication/requirements.txt diff --git a/app/authentication/webapi/bootstrap/application.py b/apps/authentication/webapi/bootstrap/application.py similarity index 100% rename from app/authentication/webapi/bootstrap/application.py rename to apps/authentication/webapi/bootstrap/application.py diff --git a/app/authentication/webapi/bootstrap/freeleaps_app.py b/apps/authentication/webapi/bootstrap/freeleaps_app.py similarity index 100% rename from app/authentication/webapi/bootstrap/freeleaps_app.py rename to apps/authentication/webapi/bootstrap/freeleaps_app.py diff --git a/app/authentication/webapi/config/site_settings.py b/apps/authentication/webapi/config/site_settings.py similarity index 100% rename from app/authentication/webapi/config/site_settings.py rename to apps/authentication/webapi/config/site_settings.py diff --git a/app/authentication/webapi/main.py b/apps/authentication/webapi/main.py similarity index 100% rename from app/authentication/webapi/main.py rename to apps/authentication/webapi/main.py diff --git a/app/authentication/webapi/providers/common.py b/apps/authentication/webapi/providers/common.py similarity index 100% rename from app/authentication/webapi/providers/common.py rename to apps/authentication/webapi/providers/common.py diff --git a/app/authentication/webapi/providers/database.py b/apps/authentication/webapi/providers/database.py similarity index 100% rename from app/authentication/webapi/providers/database.py rename to apps/authentication/webapi/providers/database.py diff --git a/app/authentication/webapi/providers/exception_handler.py b/apps/authentication/webapi/providers/exception_handler.py similarity index 100% rename from app/authentication/webapi/providers/exception_handler.py rename to apps/authentication/webapi/providers/exception_handler.py diff --git a/app/authentication/webapi/providers/logger.py b/apps/authentication/webapi/providers/logger.py similarity index 100% rename from app/authentication/webapi/providers/logger.py rename to apps/authentication/webapi/providers/logger.py diff --git a/app/authentication/webapi/providers/router.py b/apps/authentication/webapi/providers/router.py similarity index 100% rename from app/authentication/webapi/providers/router.py rename to apps/authentication/webapi/providers/router.py diff --git a/app/authentication/webapi/providers/scheduler.py b/apps/authentication/webapi/providers/scheduler.py similarity index 100% rename from app/authentication/webapi/providers/scheduler.py rename to apps/authentication/webapi/providers/scheduler.py diff --git a/app/authentication/webapi/routes/__init__.py b/apps/authentication/webapi/routes/__init__.py similarity index 100% rename from app/authentication/webapi/routes/__init__.py rename to apps/authentication/webapi/routes/__init__.py diff --git a/app/authentication/webapi/routes/api.py b/apps/authentication/webapi/routes/api.py similarity index 100% rename from app/authentication/webapi/routes/api.py rename to apps/authentication/webapi/routes/api.py diff --git a/app/authentication/webapi/routes/auth/__init__.py b/apps/authentication/webapi/routes/auth/__init__.py similarity index 100% rename from app/authentication/webapi/routes/auth/__init__.py rename to apps/authentication/webapi/routes/auth/__init__.py diff --git a/app/authentication/webapi/routes/auth/send_email_code.py b/apps/authentication/webapi/routes/auth/send_email_code.py similarity index 100% rename from app/authentication/webapi/routes/auth/send_email_code.py rename to apps/authentication/webapi/routes/auth/send_email_code.py diff --git a/app/authentication/webapi/routes/auth/send_mobile_code.py b/apps/authentication/webapi/routes/auth/send_mobile_code.py similarity index 100% rename from app/authentication/webapi/routes/auth/send_mobile_code.py rename to apps/authentication/webapi/routes/auth/send_mobile_code.py diff --git a/app/authentication/webapi/routes/signin/__init__.py b/apps/authentication/webapi/routes/signin/__init__.py similarity index 100% rename from app/authentication/webapi/routes/signin/__init__.py rename to apps/authentication/webapi/routes/signin/__init__.py diff --git a/app/authentication/webapi/routes/signin/reset_password_through_email.py b/apps/authentication/webapi/routes/signin/reset_password_through_email.py similarity index 100% rename from app/authentication/webapi/routes/signin/reset_password_through_email.py rename to apps/authentication/webapi/routes/signin/reset_password_through_email.py diff --git a/app/authentication/webapi/routes/signin/sign_out.py b/apps/authentication/webapi/routes/signin/sign_out.py similarity index 100% rename from app/authentication/webapi/routes/signin/sign_out.py rename to apps/authentication/webapi/routes/signin/sign_out.py diff --git a/app/authentication/webapi/routes/signin/signin_with_email_and_code.py b/apps/authentication/webapi/routes/signin/signin_with_email_and_code.py similarity index 100% rename from app/authentication/webapi/routes/signin/signin_with_email_and_code.py rename to apps/authentication/webapi/routes/signin/signin_with_email_and_code.py diff --git a/app/authentication/webapi/routes/signin/signin_with_email_and_password.py b/apps/authentication/webapi/routes/signin/signin_with_email_and_password.py similarity index 100% rename from app/authentication/webapi/routes/signin/signin_with_email_and_password.py rename to apps/authentication/webapi/routes/signin/signin_with_email_and_password.py diff --git a/app/authentication/webapi/routes/signin/try_signin_with_email.py b/apps/authentication/webapi/routes/signin/try_signin_with_email.py similarity index 100% rename from app/authentication/webapi/routes/signin/try_signin_with_email.py rename to apps/authentication/webapi/routes/signin/try_signin_with_email.py diff --git a/app/authentication/webapi/routes/signin/update_new_user_flid.py b/apps/authentication/webapi/routes/signin/update_new_user_flid.py similarity index 100% rename from app/authentication/webapi/routes/signin/update_new_user_flid.py rename to apps/authentication/webapi/routes/signin/update_new_user_flid.py diff --git a/app/authentication/webapi/routes/signin/update_user_password.py b/apps/authentication/webapi/routes/signin/update_user_password.py similarity index 100% rename from app/authentication/webapi/routes/signin/update_user_password.py rename to apps/authentication/webapi/routes/signin/update_user_password.py diff --git a/app/authentication/webapi/routes/tokens/__init__.py b/apps/authentication/webapi/routes/tokens/__init__.py similarity index 100% rename from app/authentication/webapi/routes/tokens/__init__.py rename to apps/authentication/webapi/routes/tokens/__init__.py diff --git a/app/authentication/webapi/routes/tokens/generate_tokens.py b/apps/authentication/webapi/routes/tokens/generate_tokens.py similarity index 100% rename from app/authentication/webapi/routes/tokens/generate_tokens.py rename to apps/authentication/webapi/routes/tokens/generate_tokens.py diff --git a/app/authentication/webapi/routes/tokens/refresh_token.py b/apps/authentication/webapi/routes/tokens/refresh_token.py similarity index 100% rename from app/authentication/webapi/routes/tokens/refresh_token.py rename to apps/authentication/webapi/routes/tokens/refresh_token.py diff --git a/app/authentication/webapi/routes/tokens/verify_token.py b/apps/authentication/webapi/routes/tokens/verify_token.py similarity index 100% rename from app/authentication/webapi/routes/tokens/verify_token.py rename to apps/authentication/webapi/routes/tokens/verify_token.py diff --git a/apps/central_storage/.env b/apps/central_storage/.env new file mode 100644 index 0000000..8d3503c --- /dev/null +++ b/apps/central_storage/.env @@ -0,0 +1,24 @@ +APP_NAME=central_storage +export SERVICE_API_ACCESS_HOST=0.0.0.0 +export SERVICE_API_ACCESS_PORT=8005 +export CONTAINER_APP_ROOT=/app +export AZURE_STORAGE_DOCUMENT_API_KEY=xbiFtFeQ6v5dozgVM99fZ9huUomL7QcLu6s0y8zYHtIXZ8XdneKDMcg4liQr/9oNlVoRFcZhWjLY+ASt9cjICQ== +export AZURE_STORAGE_DOCUMENT_API_ENDPOINT="https://freeleaps1document.blob.core.windows.net/" +export LOG_BASE_PATH=$CONTAINER_APP_ROOT/log/$APP_NAME +export BACKEND_LOG_FILE_NAME=$APP_NAME +export APPLICATION_ACTIVITY_LOG=$APP_NAME-activity +export MONGODB_NAME=freeleaps2 +export MONGODB_PORT=27017 +GIT_REPO_ROOT=/mnt/freeleaps/freeleaps-service-hub +CODEBASE_ROOT=/mnt/freeleaps/freeleaps-service-hub/app/central_storage +SITE_DEPLOY_FOLDER=/mnt/freeleaps/freeleaps-service-hub/sites/central_storage/deploy +#!/bin/bash +export VENV_DIR=venv_t +export VENV_ACTIVATE=venv_t/bin/activate +export DOCKER_HOME=/var/lib/docker +export DOCKER_APP_HOME=$DOCKER_HOME/app +export DOCKER_BACKEND_HOME=$DOCKER_APP_HOME/$APP_NAME +export DOCKER_BACKEND_LOG_HOME=$DOCKER_BACKEND_HOME/log +export MONGODB_URI=mongodb://localhost:27017/ +export FREELEAPS_ENV=local + diff --git a/apps/central_storage/Dockerfile b/apps/central_storage/Dockerfile new file mode 100644 index 0000000..d76b4c1 --- /dev/null +++ b/apps/central_storage/Dockerfile @@ -0,0 +1,38 @@ +FROM python:3.10-slim-buster + +# docker settings +ARG CONTAINER_APP_ROOT= +ENV APP_NAME= + +ENV AZURE_STORAGE_DOCUMENT_API_KEY="" +ENV AZURE_STORAGE_DOCUMENT_API_ENDPOINT="" + +#site_settings +ENV SERVICE_API_ACCESS_HOST=0.0.0.0 +ENV SERVICE_API_ACCESS_PORT=8005 +ENV MONGODB_NAME= +ENV MONGODB_PORT= +ENV MONGODB_URI= + + + +#log_settings +ENV LOG_BASE_PATH= +ENV BACKEND_LOG_FILE_NAME= +ENV APPLICATION_ACTIVITY_LOG= + + +WORKDIR ${CONTAINER_APP_ROOT} +COPY requirements.txt . + +RUN pip install --upgrade pip +RUN pip install --no-cache-dir -r requirements.txt + +COPY . ${CONTAINER_APP_ROOT} + +RUN apt update +RUN apt install -y netcat +RUN ln -s /bin/bash /usr/bin/bash + +EXPOSE ${SERVICE_API_ACCESS_PORT} +CMD ["uvicorn", "webapi.main:app", "--reload", "--port=${SERVICE_API_ACCESS_PORT}", "--host=${SERVICE_API_ACCESS_HOST}"] diff --git a/app/central_storage/backend/application/document_hub.py b/apps/central_storage/backend/application/document_hub.py similarity index 92% rename from app/central_storage/backend/application/document_hub.py rename to apps/central_storage/backend/application/document_hub.py index c9ae0b3..1fa1439 100644 --- a/app/central_storage/backend/application/document_hub.py +++ b/apps/central_storage/backend/application/document_hub.py @@ -1,4 +1,4 @@ -from app.central_storage.backend.business.document_manager import ( +from backend.business.document_manager import ( DocumentManager, ) diff --git a/app/central_storage/backend/business/document_manager.py b/apps/central_storage/backend/business/document_manager.py similarity index 90% rename from app/central_storage/backend/business/document_manager.py rename to apps/central_storage/backend/business/document_manager.py index 6ed4201..7c7eee1 100644 --- a/app/central_storage/backend/business/document_manager.py +++ b/apps/central_storage/backend/business/document_manager.py @@ -1,5 +1,5 @@ -from app.central_storage.backend.services.document_service import DocumentService -from app.central_storage.backend.models.models import MediaType, DataFormat +from backend.services.document_service import DocumentService +from backend.models.models import MediaType, DataFormat class DocumentManager: diff --git a/app/central_storage/backend/infra/azure_storage/blob_handler.py b/apps/central_storage/backend/infra/azure_storage/blob_handler.py similarity index 98% rename from app/central_storage/backend/infra/azure_storage/blob_handler.py rename to apps/central_storage/backend/infra/azure_storage/blob_handler.py index 35a537f..94851c4 100644 --- a/app/central_storage/backend/infra/azure_storage/blob_handler.py +++ b/apps/central_storage/backend/infra/azure_storage/blob_handler.py @@ -1,4 +1,4 @@ -from app.central_storage.common.config.app_settings import app_settings +from common.config.app_settings import app_settings import datetime import asyncio diff --git a/app/central_storage/backend/models/__init__.py b/apps/central_storage/backend/models/__init__.py similarity index 100% rename from app/central_storage/backend/models/__init__.py rename to apps/central_storage/backend/models/__init__.py diff --git a/app/central_storage/backend/models/constants.py b/apps/central_storage/backend/models/constants.py similarity index 100% rename from app/central_storage/backend/models/constants.py rename to apps/central_storage/backend/models/constants.py diff --git a/app/central_storage/backend/models/models.py b/apps/central_storage/backend/models/models.py similarity index 100% rename from app/central_storage/backend/models/models.py rename to apps/central_storage/backend/models/models.py diff --git a/app/central_storage/backend/services/document_service.py b/apps/central_storage/backend/services/document_service.py similarity index 95% rename from app/central_storage/backend/services/document_service.py rename to apps/central_storage/backend/services/document_service.py index d3b773b..ec1bb6d 100644 --- a/app/central_storage/backend/services/document_service.py +++ b/apps/central_storage/backend/services/document_service.py @@ -1,9 +1,9 @@ from datetime import datetime as dt, timezone as tz -from app.central_storage.backend.models.models import DocumentDoc -from app.central_storage.backend.models.constants import MediaType, DataFormat +from backend.models.models import DocumentDoc +from backend.models.constants import MediaType, DataFormat -from infra.exception.exceptions import DoesNotExistError -from app.central_storage.backend.infra.azure_storage.blob_handler import ( +from common.exception.exceptions import DoesNotExistError +from backend.infra.azure_storage.blob_handler import ( AzureBlobHandler, ) import base64 diff --git a/app/central_storage/common/config/app_settings.py b/apps/central_storage/common/config/app_settings.py similarity index 71% rename from app/central_storage/common/config/app_settings.py rename to apps/central_storage/common/config/app_settings.py index f2028e1..95889f7 100644 --- a/app/central_storage/common/config/app_settings.py +++ b/apps/central_storage/common/config/app_settings.py @@ -5,9 +5,8 @@ from pydantic_settings import BaseSettings class AppSettings(BaseSettings): NAME: str = "central_storage" - AZURE_STORAGE_DOCUMENT_API_ENDPOINT: str = ( - "https://freeleaps1document.blob.core.windows.net/" - ) + AZURE_STORAGE_DOCUMENT_API_ENDPOINT: str = "" + AZURE_STORAGE_DOCUMENT_API_KEY: str = "" class Config: diff --git a/app/content/common/config/log_settings.py b/apps/central_storage/common/config/log_settings.py similarity index 100% rename from app/content/common/config/log_settings.py rename to apps/central_storage/common/config/log_settings.py diff --git a/app/content/backend/document/__init__.py b/apps/central_storage/common/exception/__init__.py similarity index 100% rename from app/content/backend/document/__init__.py rename to apps/central_storage/common/exception/__init__.py diff --git a/app/content/common/exception/exceptions.py b/apps/central_storage/common/exception/exceptions.py similarity index 100% rename from app/content/common/exception/exceptions.py rename to apps/central_storage/common/exception/exceptions.py diff --git a/app/central_storage/requirements.txt b/apps/central_storage/requirements.txt similarity index 100% rename from app/central_storage/requirements.txt rename to apps/central_storage/requirements.txt diff --git a/apps/central_storage/start_fastapi.sh b/apps/central_storage/start_fastapi.sh new file mode 100755 index 0000000..90c5e86 --- /dev/null +++ b/apps/central_storage/start_fastapi.sh @@ -0,0 +1,40 @@ +#! /bin/bash +rp=$(dirname "$(realpath '$1'))") +pushd $rp + +APP_NAME=central_storage +APP_PARENT_FOLDER=apps + +GIT_REPO_ROOT=$(git rev-parse --show-toplevel) +CODEBASE_ROOT=$GIT_REPO_ROOT/$APP_PARENT_FOLDER/$APP_NAME +SITE_DEPLOY_FOLDER=$GIT_REPO_ROOT/sites/$APP_NAME/deploy + + +echo APP_NAME=$APP_NAME > .env +cat $SITE_DEPLOY_FOLDER/common/.env >> .env +echo GIT_REPO_ROOT=$(git rev-parse --show-toplevel) >> .env +echo CODEBASE_ROOT=$GIT_REPO_ROOT/$APP_PARENT_FOLDER/$APP_NAME >> .env +echo SITE_DEPLOY_FOLDER=$GIT_REPO_ROOT/sites/$APP_NAME/deploy >> .env +cat $SITE_DEPLOY_FOLDER/common/.host.env >> .env +cat $SITE_DEPLOY_FOLDER/local/.env >> .env + +. .env + +if [ -d "$VENV_DIR" ] +then + echo "Folder $VENV_DIR exists. Proceed to next steps" +else + echo "Folder $VENV_DIR dosen't exist. create it" + sudo apt install python3-pip + python3 -m pip install virtualenv + python3 -m virtualenv $VENV_DIR +fi + +source $VENV_DIR/bin/activate +pip install --upgrade pip +pip install -r requirements.txt + +uvicorn webapi.main:app --reload --host 0.0.0.0 --port $SERVICE_API_ACCESS_PORT + + +popd diff --git a/app/central_storage/webapi/bootstrap/application.py b/apps/central_storage/webapi/bootstrap/application.py similarity index 83% rename from app/central_storage/webapi/bootstrap/application.py rename to apps/central_storage/webapi/bootstrap/application.py index cf20628..8e14dcd 100644 --- a/app/central_storage/webapi/bootstrap/application.py +++ b/apps/central_storage/webapi/bootstrap/application.py @@ -2,12 +2,12 @@ import logging from fastapi import FastAPI from fastapi.openapi.utils import get_openapi -from app.central_storage.webapi.providers import common -from app.central_storage.webapi.providers import logger -from app.central_storage.webapi.providers import router -from app.central_storage.webapi.providers import database -from app.central_storage.webapi.providers import scheduler -from app.central_storage.webapi.providers import exception_handler +from webapi.providers import common +from webapi.providers import logger +from webapi.providers import router +from webapi.providers import database +from webapi.providers import scheduler +from webapi.providers import exception_handler from .freeleaps_app import FreeleapsApp diff --git a/app/central_storage/webapi/bootstrap/freeleaps_app.py b/apps/central_storage/webapi/bootstrap/freeleaps_app.py similarity index 100% rename from app/central_storage/webapi/bootstrap/freeleaps_app.py rename to apps/central_storage/webapi/bootstrap/freeleaps_app.py diff --git a/app/central_storage/webapi/config/site_settings.py b/apps/central_storage/webapi/config/site_settings.py similarity index 83% rename from app/central_storage/webapi/config/site_settings.py rename to apps/central_storage/webapi/config/site_settings.py index a72e6d0..44e8f1c 100644 --- a/app/central_storage/webapi/config/site_settings.py +++ b/apps/central_storage/webapi/config/site_settings.py @@ -16,6 +16,8 @@ class SiteSettings(BaseSettings): TIME_ZONE: str = "UTC" BASE_PATH: str = os.path.dirname(os.path.dirname((os.path.abspath(__file__)))) + MONGODB_NAME: str = os.environ["MONGODB_NAME"] + MONGODB_URI: str = os.environ["MONGODB_URI"] class Config: env_file = ".devbase-webapi.env" diff --git a/app/central_storage/webapi/main.py b/apps/central_storage/webapi/main.py similarity index 83% rename from app/central_storage/webapi/main.py rename to apps/central_storage/webapi/main.py index 2f1dad7..c35ffa3 100755 --- a/app/central_storage/webapi/main.py +++ b/apps/central_storage/webapi/main.py @@ -1,5 +1,5 @@ -from app.central_storage.webapi.bootstrap.application import create_app -from app.central_storage.webapi.config.site_settings import site_settings +from webapi.bootstrap.application import create_app +from webapi.config.site_settings import site_settings from fastapi.responses import RedirectResponse from fastapi.middleware.cors import CORSMiddleware import uvicorn diff --git a/app/content/webapi/providers/common.py b/apps/central_storage/webapi/providers/common.py similarity index 100% rename from app/content/webapi/providers/common.py rename to apps/central_storage/webapi/providers/common.py diff --git a/apps/central_storage/webapi/providers/database.py b/apps/central_storage/webapi/providers/database.py new file mode 100644 index 0000000..0024f82 --- /dev/null +++ b/apps/central_storage/webapi/providers/database.py @@ -0,0 +1,20 @@ +from webapi.config.site_settings import site_settings +from beanie import init_beanie +from motor.motor_asyncio import AsyncIOMotorClient +from backend.models import backend_models + + +def register(app): + app.debug = "mongo_debug" + app.title = "mongo_name" + + @app.on_event("startup") + async def start_database(): + await initiate_database() + + +async def initiate_database(): + client = AsyncIOMotorClient(site_settings.MONGODB_URI, serverSelectionTimeoutMS=60000) + await init_beanie( + database=client[site_settings.MONGODB_NAME], document_models=backend_models + ) diff --git a/app/central_storage/webapi/providers/exception_handler.py b/apps/central_storage/webapi/providers/exception_handler.py similarity index 100% rename from app/central_storage/webapi/providers/exception_handler.py rename to apps/central_storage/webapi/providers/exception_handler.py diff --git a/app/notification/webapi/providers/logger.py b/apps/central_storage/webapi/providers/logger.py similarity index 96% rename from app/notification/webapi/providers/logger.py rename to apps/central_storage/webapi/providers/logger.py index 0b37c27..9bc8adb 100644 --- a/app/notification/webapi/providers/logger.py +++ b/apps/central_storage/webapi/providers/logger.py @@ -1,7 +1,7 @@ import logging import sys from loguru import logger -from infra.config.log_settings import log_settings +from common.config.log_settings import log_settings def register(app=None): diff --git a/app/content/webapi/providers/router.py b/apps/central_storage/webapi/providers/router.py similarity index 100% rename from app/content/webapi/providers/router.py rename to apps/central_storage/webapi/providers/router.py diff --git a/app/central_storage/webapi/providers/scheduler.py b/apps/central_storage/webapi/providers/scheduler.py similarity index 100% rename from app/central_storage/webapi/providers/scheduler.py rename to apps/central_storage/webapi/providers/scheduler.py diff --git a/app/central_storage/webapi/routes/__init__.py b/apps/central_storage/webapi/routes/__init__.py similarity index 100% rename from app/central_storage/webapi/routes/__init__.py rename to apps/central_storage/webapi/routes/__init__.py diff --git a/app/central_storage/webapi/routes/api.py b/apps/central_storage/webapi/routes/api.py similarity index 100% rename from app/central_storage/webapi/routes/api.py rename to apps/central_storage/webapi/routes/api.py diff --git a/app/central_storage/webapi/routes/read_document_as_http_media.py b/apps/central_storage/webapi/routes/read_document_as_http_media.py similarity index 86% rename from app/central_storage/webapi/routes/read_document_as_http_media.py rename to apps/central_storage/webapi/routes/read_document_as_http_media.py index 76b141c..c84e108 100644 --- a/app/central_storage/webapi/routes/read_document_as_http_media.py +++ b/apps/central_storage/webapi/routes/read_document_as_http_media.py @@ -1,5 +1,4 @@ from fastapi import APIRouter -from infra.token.token_manager import TokenManager from fastapi import APIRouter, Depends from fastapi.encoders import jsonable_encoder from fastapi.responses import JSONResponse @@ -7,8 +6,7 @@ from fastapi import Depends, HTTPException from starlette.status import HTTP_401_UNAUTHORIZED from fastapi.encoders import jsonable_encoder from fastapi.responses import JSONResponse -from infra.token.token_manager import TokenManager -from app.central_storage.backend.application.document_hub import DocumentHub +from backend.application.document_hub import DocumentHub router = APIRouter() diff --git a/app/central_storage/webapi/routes/retrieve_document_info.py b/apps/central_storage/webapi/routes/retrieve_document_info.py similarity index 84% rename from app/central_storage/webapi/routes/retrieve_document_info.py rename to apps/central_storage/webapi/routes/retrieve_document_info.py index 941a586..5273247 100644 --- a/app/central_storage/webapi/routes/retrieve_document_info.py +++ b/apps/central_storage/webapi/routes/retrieve_document_info.py @@ -1,5 +1,4 @@ from fastapi import APIRouter -from infra.token.token_manager import TokenManager from fastapi import APIRouter, Depends from fastapi.encoders import jsonable_encoder from fastapi.responses import JSONResponse @@ -7,11 +6,9 @@ from fastapi import Depends, HTTPException from starlette.status import HTTP_401_UNAUTHORIZED from fastapi.encoders import jsonable_encoder from fastapi.responses import JSONResponse -from infra.token.token_manager import TokenManager -from app.central_storage.backend.application.document_hub import DocumentHub +from backend.application.document_hub import DocumentHub router = APIRouter() -token_manager = TokenManager() # Web API diff --git a/app/central_storage/webapi/routes/upload_document.py b/apps/central_storage/webapi/routes/upload_document.py similarity index 90% rename from app/central_storage/webapi/routes/upload_document.py rename to apps/central_storage/webapi/routes/upload_document.py index 637e4f4..a4d20f1 100644 --- a/app/central_storage/webapi/routes/upload_document.py +++ b/apps/central_storage/webapi/routes/upload_document.py @@ -1,10 +1,9 @@ from fastapi import APIRouter, UploadFile, File, Form, HTTPException from fastapi import APIRouter, Depends -from infra.token.token_manager import TokenManager from starlette.status import HTTP_401_UNAUTHORIZED from fastapi.encoders import jsonable_encoder from fastapi.responses import JSONResponse -from app.central_storage.backend.application.document_hub import DocumentHub +from backend.application.document_hub import DocumentHub from pydantic import BaseModel router = APIRouter() diff --git a/app/central_storage/webapi/routes/upload_file.py b/apps/central_storage/webapi/routes/upload_file.py similarity index 94% rename from app/central_storage/webapi/routes/upload_file.py rename to apps/central_storage/webapi/routes/upload_file.py index 26e1515..243297f 100644 --- a/app/central_storage/webapi/routes/upload_file.py +++ b/apps/central_storage/webapi/routes/upload_file.py @@ -4,7 +4,7 @@ from infra.token.token_manager import TokenManager from starlette.status import HTTP_401_UNAUTHORIZED from fastapi.encoders import jsonable_encoder from fastapi.responses import JSONResponse -from app.central_storage.backend.application.document_hub import DocumentHub +from backend.application.document_hub import DocumentHub router = APIRouter() diff --git a/app/content/Dockerfile b/apps/content/Dockerfile similarity index 100% rename from app/content/Dockerfile rename to apps/content/Dockerfile diff --git a/app/content/backend/content/__init__.py b/apps/content/backend/content/__init__.py similarity index 100% rename from app/content/backend/content/__init__.py rename to apps/content/backend/content/__init__.py diff --git a/app/content/backend/content/constants.py b/apps/content/backend/content/constants.py similarity index 100% rename from app/content/backend/content/constants.py rename to apps/content/backend/content/constants.py diff --git a/app/content/backend/content/content_service.py b/apps/content/backend/content/content_service.py similarity index 100% rename from app/content/backend/content/content_service.py rename to apps/content/backend/content/content_service.py diff --git a/app/content/backend/content/content_sharepoint_manager.py b/apps/content/backend/content/content_sharepoint_manager.py similarity index 100% rename from app/content/backend/content/content_sharepoint_manager.py rename to apps/content/backend/content/content_sharepoint_manager.py diff --git a/app/content/backend/content/models.py b/apps/content/backend/content/models.py similarity index 100% rename from app/content/backend/content/models.py rename to apps/content/backend/content/models.py diff --git a/app/content/backend/content/refresh_sharepoint_content.py b/apps/content/backend/content/refresh_sharepoint_content.py similarity index 100% rename from app/content/backend/content/refresh_sharepoint_content.py rename to apps/content/backend/content/refresh_sharepoint_content.py diff --git a/app/content/backend/sharepoint/__init__.py b/apps/content/backend/document/__init__.py similarity index 100% rename from app/content/backend/sharepoint/__init__.py rename to apps/content/backend/document/__init__.py diff --git a/app/content/backend/document/document_manager.py b/apps/content/backend/document/document_manager.py similarity index 100% rename from app/content/backend/document/document_manager.py rename to apps/content/backend/document/document_manager.py diff --git a/app/content/backend/models/__init__.py b/apps/content/backend/models/__init__.py similarity index 100% rename from app/content/backend/models/__init__.py rename to apps/content/backend/models/__init__.py diff --git a/app/content/backend/readme.md b/apps/content/backend/readme.md similarity index 100% rename from app/content/backend/readme.md rename to apps/content/backend/readme.md diff --git a/app/content/common/constants/__init__.py b/apps/content/backend/sharepoint/__init__.py similarity index 100% rename from app/content/common/constants/__init__.py rename to apps/content/backend/sharepoint/__init__.py diff --git a/app/content/backend/sharepoint/access_sharepoint_samples.py b/apps/content/backend/sharepoint/access_sharepoint_samples.py similarity index 100% rename from app/content/backend/sharepoint/access_sharepoint_samples.py rename to apps/content/backend/sharepoint/access_sharepoint_samples.py diff --git a/app/content/backend/sharepoint/sharepoint_graph_client.py b/apps/content/backend/sharepoint/sharepoint_graph_client.py similarity index 100% rename from app/content/backend/sharepoint/sharepoint_graph_client.py rename to apps/content/backend/sharepoint/sharepoint_graph_client.py diff --git a/app/content/common/config/app_settings.py b/apps/content/common/config/app_settings.py similarity index 100% rename from app/content/common/config/app_settings.py rename to apps/content/common/config/app_settings.py diff --git a/apps/content/common/config/log_settings.py b/apps/content/common/config/log_settings.py new file mode 100644 index 0000000..856281d --- /dev/null +++ b/apps/content/common/config/log_settings.py @@ -0,0 +1,17 @@ + + +class LogSettings(): + LOG_LEVEL: str = "DEBUG" + LOG_PATH_BASE: str = ( + "./logs" + ) + LOG_PATH: str = LOG_PATH_BASE + '/' + "app" + '.log' + LOG_RETENTION: str = "14 days" + LOG_ROTATION: str = "00:00" # mid night + + class Config: + env_file = ".log.env" + env_file_encoding = "utf-8" + + +log_settings = LogSettings() diff --git a/app/content/common/exception/__init__.py b/apps/content/common/constants/__init__.py similarity index 100% rename from app/content/common/exception/__init__.py rename to apps/content/common/constants/__init__.py diff --git a/app/content/common/constants/contract.py b/apps/content/common/constants/contract.py similarity index 100% rename from app/content/common/constants/contract.py rename to apps/content/common/constants/contract.py diff --git a/app/content/common/constants/payment.py b/apps/content/common/constants/payment.py similarity index 100% rename from app/content/common/constants/payment.py rename to apps/content/common/constants/payment.py diff --git a/app/content/common/constants/region.py b/apps/content/common/constants/region.py similarity index 100% rename from app/content/common/constants/region.py rename to apps/content/common/constants/region.py diff --git a/app/content/common/log/__init__.py b/apps/content/common/exception/__init__.py similarity index 100% rename from app/content/common/log/__init__.py rename to apps/content/common/exception/__init__.py diff --git a/apps/content/common/exception/exceptions.py b/apps/content/common/exception/exceptions.py new file mode 100644 index 0000000..2c489c3 --- /dev/null +++ b/apps/content/common/exception/exceptions.py @@ -0,0 +1,23 @@ +class DoesNotExistError(Exception): + def __init__(self, message: str = "Does Not Exist"): + self.message = message + + +class AuthenticationError(Exception): + def __init__(self, message: str = "Unauthorized"): + self.message = message + + +class AuthorizationError(Exception): + def __init__(self, message: str = "Forbidden"): + self.message = message + + +class InvalidOperationError(Exception): + def __init__(self, message: str = "Invalid Operation"): + self.message = message + + +class InvalidDataError(Exception): + def __init__(self, message: str = "Invalid Data"): + self.message = message diff --git a/app/content/scheduler/__init__.py b/apps/content/common/log/__init__.py old mode 100755 new mode 100644 similarity index 100% rename from app/content/scheduler/__init__.py rename to apps/content/common/log/__init__.py diff --git a/app/content/common/log/application_logger.py b/apps/content/common/log/application_logger.py similarity index 100% rename from app/content/common/log/application_logger.py rename to apps/content/common/log/application_logger.py diff --git a/app/content/common/log/base_logger.py b/apps/content/common/log/base_logger.py similarity index 100% rename from app/content/common/log/base_logger.py rename to apps/content/common/log/base_logger.py diff --git a/app/content/common/log/business_metric_logger.py b/apps/content/common/log/business_metric_logger.py similarity index 100% rename from app/content/common/log/business_metric_logger.py rename to apps/content/common/log/business_metric_logger.py diff --git a/app/content/common/log/function_logger.py b/apps/content/common/log/function_logger.py similarity index 100% rename from app/content/common/log/function_logger.py rename to apps/content/common/log/function_logger.py diff --git a/app/content/common/log/log_utils.py b/apps/content/common/log/log_utils.py similarity index 100% rename from app/content/common/log/log_utils.py rename to apps/content/common/log/log_utils.py diff --git a/app/content/common/log/module_logger.py b/apps/content/common/log/module_logger.py similarity index 100% rename from app/content/common/log/module_logger.py rename to apps/content/common/log/module_logger.py diff --git a/app/content/common/log/user_logger.py b/apps/content/common/log/user_logger.py similarity index 100% rename from app/content/common/log/user_logger.py rename to apps/content/common/log/user_logger.py diff --git a/app/content/common/utils/date.py b/apps/content/common/utils/date.py similarity index 100% rename from app/content/common/utils/date.py rename to apps/content/common/utils/date.py diff --git a/app/content/common/utils/region.py b/apps/content/common/utils/region.py similarity index 100% rename from app/content/common/utils/region.py rename to apps/content/common/utils/region.py diff --git a/app/content/common/utils/string.py b/apps/content/common/utils/string.py similarity index 100% rename from app/content/common/utils/string.py rename to apps/content/common/utils/string.py diff --git a/app/content/database/mongo/models.py b/apps/content/database/mongo/models.py similarity index 100% rename from app/content/database/mongo/models.py rename to apps/content/database/mongo/models.py diff --git a/app/content/database/mongo/mongo_driver.py b/apps/content/database/mongo/mongo_driver.py similarity index 100% rename from app/content/database/mongo/mongo_driver.py rename to apps/content/database/mongo/mongo_driver.py diff --git a/app/content/requirements.txt b/apps/content/requirements.txt similarity index 100% rename from app/content/requirements.txt rename to apps/content/requirements.txt diff --git a/app/notification/backend/infra/rabbitmq/__init__.py b/apps/content/scheduler/__init__.py old mode 100644 new mode 100755 similarity index 100% rename from app/notification/backend/infra/rabbitmq/__init__.py rename to apps/content/scheduler/__init__.py diff --git a/app/content/scheduler/constants.py b/apps/content/scheduler/constants.py similarity index 100% rename from app/content/scheduler/constants.py rename to apps/content/scheduler/constants.py diff --git a/app/content/scheduler/models.py b/apps/content/scheduler/models.py similarity index 100% rename from app/content/scheduler/models.py rename to apps/content/scheduler/models.py diff --git a/app/content/scheduler/refresh_sharepoint_content_job.py b/apps/content/scheduler/refresh_sharepoint_content_job.py similarity index 100% rename from app/content/scheduler/refresh_sharepoint_content_job.py rename to apps/content/scheduler/refresh_sharepoint_content_job.py diff --git a/app/content/scheduler/schedule_job_locker.py b/apps/content/scheduler/schedule_job_locker.py similarity index 100% rename from app/content/scheduler/schedule_job_locker.py rename to apps/content/scheduler/schedule_job_locker.py diff --git a/app/content/scheduler/scheduler_manager.py b/apps/content/scheduler/scheduler_manager.py similarity index 100% rename from app/content/scheduler/scheduler_manager.py rename to apps/content/scheduler/scheduler_manager.py diff --git a/app/content/start_fastapi.sh b/apps/content/start_fastapi.sh similarity index 100% rename from app/content/start_fastapi.sh rename to apps/content/start_fastapi.sh diff --git a/app/content/webapi/bootstrap/application.py b/apps/content/webapi/bootstrap/application.py similarity index 100% rename from app/content/webapi/bootstrap/application.py rename to apps/content/webapi/bootstrap/application.py diff --git a/app/content/webapi/bootstrap/freeleaps_app.py b/apps/content/webapi/bootstrap/freeleaps_app.py similarity index 100% rename from app/content/webapi/bootstrap/freeleaps_app.py rename to apps/content/webapi/bootstrap/freeleaps_app.py diff --git a/app/content/webapi/config/site_settings.py b/apps/content/webapi/config/site_settings.py similarity index 100% rename from app/content/webapi/config/site_settings.py rename to apps/content/webapi/config/site_settings.py diff --git a/app/content/webapi/main.py b/apps/content/webapi/main.py similarity index 100% rename from app/content/webapi/main.py rename to apps/content/webapi/main.py diff --git a/app/central_storage/webapi/providers/common.py b/apps/content/webapi/providers/common.py similarity index 90% rename from app/central_storage/webapi/providers/common.py rename to apps/content/webapi/providers/common.py index f61954d..1dd849f 100644 --- a/app/central_storage/webapi/providers/common.py +++ b/apps/content/webapi/providers/common.py @@ -1,5 +1,5 @@ from fastapi.middleware.cors import CORSMiddleware -from app.central_storage.webapi.config.site_settings import site_settings +from webapi.config.site_settings import site_settings def register(app): diff --git a/app/content/webapi/providers/database.py b/apps/content/webapi/providers/database.py similarity index 100% rename from app/content/webapi/providers/database.py rename to apps/content/webapi/providers/database.py diff --git a/app/content/webapi/providers/exception_handler.py b/apps/content/webapi/providers/exception_handler.py similarity index 100% rename from app/content/webapi/providers/exception_handler.py rename to apps/content/webapi/providers/exception_handler.py diff --git a/app/content/webapi/providers/logger.py b/apps/content/webapi/providers/logger.py similarity index 100% rename from app/content/webapi/providers/logger.py rename to apps/content/webapi/providers/logger.py diff --git a/app/central_storage/webapi/providers/router.py b/apps/content/webapi/providers/router.py similarity index 94% rename from app/central_storage/webapi/providers/router.py rename to apps/content/webapi/providers/router.py index 276b944..3ad11ae 100644 --- a/app/central_storage/webapi/providers/router.py +++ b/apps/content/webapi/providers/router.py @@ -1,4 +1,4 @@ -from app.central_storage.webapi.routes import api_router +from webapi.routes import api_router from starlette import routing diff --git a/app/content/webapi/providers/scheduler.py b/apps/content/webapi/providers/scheduler.py similarity index 100% rename from app/content/webapi/providers/scheduler.py rename to apps/content/webapi/providers/scheduler.py diff --git a/app/content/webapi/routes/__init__.py b/apps/content/webapi/routes/__init__.py similarity index 100% rename from app/content/webapi/routes/__init__.py rename to apps/content/webapi/routes/__init__.py diff --git a/app/content/webapi/routes/api.py b/apps/content/webapi/routes/api.py similarity index 100% rename from app/content/webapi/routes/api.py rename to apps/content/webapi/routes/api.py diff --git a/app/content/webapi/routes/content/__init__.py b/apps/content/webapi/routes/content/__init__.py similarity index 100% rename from app/content/webapi/routes/content/__init__.py rename to apps/content/webapi/routes/content/__init__.py diff --git a/app/content/webapi/routes/content/retrieve_content_as_media_data.py b/apps/content/webapi/routes/content/retrieve_content_as_media_data.py similarity index 100% rename from app/content/webapi/routes/content/retrieve_content_as_media_data.py rename to apps/content/webapi/routes/content/retrieve_content_as_media_data.py diff --git a/app/content/webapi/routes/content/retrieve_directories_for_folder.py b/apps/content/webapi/routes/content/retrieve_directories_for_folder.py similarity index 100% rename from app/content/webapi/routes/content/retrieve_directories_for_folder.py rename to apps/content/webapi/routes/content/retrieve_directories_for_folder.py diff --git a/app/notification/Dockerfile b/apps/notification/Dockerfile similarity index 100% rename from app/notification/Dockerfile rename to apps/notification/Dockerfile diff --git a/app/notification/backend/application/notification_hub.py b/apps/notification/backend/application/notification_hub.py similarity index 100% rename from app/notification/backend/application/notification_hub.py rename to apps/notification/backend/application/notification_hub.py diff --git a/app/notification/backend/business/notification_manager.py b/apps/notification/backend/business/notification_manager.py similarity index 100% rename from app/notification/backend/business/notification_manager.py rename to apps/notification/backend/business/notification_manager.py diff --git a/app/notification/backend/infra/email_handler.py b/apps/notification/backend/infra/email_handler.py similarity index 100% rename from app/notification/backend/infra/email_handler.py rename to apps/notification/backend/infra/email_handler.py diff --git a/app/notification/backend/infra/in_app_notif_handler.py b/apps/notification/backend/infra/in_app_notif_handler.py similarity index 100% rename from app/notification/backend/infra/in_app_notif_handler.py rename to apps/notification/backend/infra/in_app_notif_handler.py diff --git a/app/notification/backend/models/models.py b/apps/notification/backend/infra/rabbitmq/__init__.py similarity index 100% rename from app/notification/backend/models/models.py rename to apps/notification/backend/infra/rabbitmq/__init__.py diff --git a/app/notification/backend/infra/rabbitmq/async_client.py b/apps/notification/backend/infra/rabbitmq/async_client.py similarity index 100% rename from app/notification/backend/infra/rabbitmq/async_client.py rename to apps/notification/backend/infra/rabbitmq/async_client.py diff --git a/app/notification/backend/infra/rabbitmq/async_publisher.py b/apps/notification/backend/infra/rabbitmq/async_publisher.py similarity index 100% rename from app/notification/backend/infra/rabbitmq/async_publisher.py rename to apps/notification/backend/infra/rabbitmq/async_publisher.py diff --git a/app/notification/backend/infra/rabbitmq/async_subscriber.py b/apps/notification/backend/infra/rabbitmq/async_subscriber.py similarity index 100% rename from app/notification/backend/infra/rabbitmq/async_subscriber.py rename to apps/notification/backend/infra/rabbitmq/async_subscriber.py diff --git a/app/notification/backend/infra/sms_handler.py b/apps/notification/backend/infra/sms_handler.py similarity index 100% rename from app/notification/backend/infra/sms_handler.py rename to apps/notification/backend/infra/sms_handler.py diff --git a/app/notification/backend/models/constants.py b/apps/notification/backend/models/constants.py similarity index 100% rename from app/notification/backend/models/constants.py rename to apps/notification/backend/models/constants.py diff --git a/apps/notification/backend/models/models.py b/apps/notification/backend/models/models.py new file mode 100644 index 0000000..e69de29 diff --git a/app/notification/backend/readme.md b/apps/notification/backend/readme.md similarity index 100% rename from app/notification/backend/readme.md rename to apps/notification/backend/readme.md diff --git a/app/notification/backend/services/email_service.py b/apps/notification/backend/services/email_service.py similarity index 100% rename from app/notification/backend/services/email_service.py rename to apps/notification/backend/services/email_service.py diff --git a/app/notification/backend/services/in_app_notif_service.py b/apps/notification/backend/services/in_app_notif_service.py similarity index 100% rename from app/notification/backend/services/in_app_notif_service.py rename to apps/notification/backend/services/in_app_notif_service.py diff --git a/app/notification/backend/services/notification_publisher_service.py b/apps/notification/backend/services/notification_publisher_service.py similarity index 100% rename from app/notification/backend/services/notification_publisher_service.py rename to apps/notification/backend/services/notification_publisher_service.py diff --git a/app/notification/backend/services/sms_service.py b/apps/notification/backend/services/sms_service.py similarity index 100% rename from app/notification/backend/services/sms_service.py rename to apps/notification/backend/services/sms_service.py diff --git a/app/notification/common/config/app_settings.py b/apps/notification/common/config/app_settings.py similarity index 100% rename from app/notification/common/config/app_settings.py rename to apps/notification/common/config/app_settings.py diff --git a/app/notification/common/config/log_settings.py b/apps/notification/common/config/log_settings.py similarity index 100% rename from app/notification/common/config/log_settings.py rename to apps/notification/common/config/log_settings.py diff --git a/app/notification/requirements.txt b/apps/notification/requirements.txt similarity index 100% rename from app/notification/requirements.txt rename to apps/notification/requirements.txt diff --git a/app/notification/webapi/bootstrap/application.py b/apps/notification/webapi/bootstrap/application.py similarity index 100% rename from app/notification/webapi/bootstrap/application.py rename to apps/notification/webapi/bootstrap/application.py diff --git a/app/notification/webapi/bootstrap/freeleaps_app.py b/apps/notification/webapi/bootstrap/freeleaps_app.py similarity index 100% rename from app/notification/webapi/bootstrap/freeleaps_app.py rename to apps/notification/webapi/bootstrap/freeleaps_app.py diff --git a/app/notification/webapi/config/site_settings.py b/apps/notification/webapi/config/site_settings.py similarity index 100% rename from app/notification/webapi/config/site_settings.py rename to apps/notification/webapi/config/site_settings.py diff --git a/app/notification/webapi/main.py b/apps/notification/webapi/main.py similarity index 100% rename from app/notification/webapi/main.py rename to apps/notification/webapi/main.py diff --git a/app/notification/webapi/providers/common.py b/apps/notification/webapi/providers/common.py similarity index 100% rename from app/notification/webapi/providers/common.py rename to apps/notification/webapi/providers/common.py diff --git a/app/notification/webapi/providers/database.py b/apps/notification/webapi/providers/database.py similarity index 100% rename from app/notification/webapi/providers/database.py rename to apps/notification/webapi/providers/database.py diff --git a/app/notification/webapi/providers/exception_handler.py b/apps/notification/webapi/providers/exception_handler.py similarity index 100% rename from app/notification/webapi/providers/exception_handler.py rename to apps/notification/webapi/providers/exception_handler.py diff --git a/app/central_storage/webapi/providers/logger.py b/apps/notification/webapi/providers/logger.py similarity index 100% rename from app/central_storage/webapi/providers/logger.py rename to apps/notification/webapi/providers/logger.py diff --git a/app/notification/webapi/providers/message_queue.py b/apps/notification/webapi/providers/message_queue.py similarity index 100% rename from app/notification/webapi/providers/message_queue.py rename to apps/notification/webapi/providers/message_queue.py diff --git a/app/notification/webapi/providers/router.py b/apps/notification/webapi/providers/router.py similarity index 100% rename from app/notification/webapi/providers/router.py rename to apps/notification/webapi/providers/router.py diff --git a/app/notification/webapi/providers/scheduler.py b/apps/notification/webapi/providers/scheduler.py similarity index 100% rename from app/notification/webapi/providers/scheduler.py rename to apps/notification/webapi/providers/scheduler.py diff --git a/app/notification/webapi/routes/__init__.py b/apps/notification/webapi/routes/__init__.py similarity index 100% rename from app/notification/webapi/routes/__init__.py rename to apps/notification/webapi/routes/__init__.py diff --git a/app/notification/webapi/routes/api.py b/apps/notification/webapi/routes/api.py similarity index 100% rename from app/notification/webapi/routes/api.py rename to apps/notification/webapi/routes/api.py diff --git a/app/notification/webapi/routes/online_platform_notification.py b/apps/notification/webapi/routes/online_platform_notification.py similarity index 100% rename from app/notification/webapi/routes/online_platform_notification.py rename to apps/notification/webapi/routes/online_platform_notification.py diff --git a/app/notification/webapi/routes/send_notification.py b/apps/notification/webapi/routes/send_notification.py similarity index 100% rename from app/notification/webapi/routes/send_notification.py rename to apps/notification/webapi/routes/send_notification.py diff --git a/app/notification/webapi/utils/email_consumer.py b/apps/notification/webapi/utils/email_consumer.py similarity index 100% rename from app/notification/webapi/utils/email_consumer.py rename to apps/notification/webapi/utils/email_consumer.py diff --git a/app/notification/webapi/utils/sms_consumer.py b/apps/notification/webapi/utils/sms_consumer.py similarity index 100% rename from app/notification/webapi/utils/sms_consumer.py rename to apps/notification/webapi/utils/sms_consumer.py diff --git a/sites/central_storage/.env b/sites/central_storage/.env deleted file mode 100644 index 4df0fdd..0000000 --- a/sites/central_storage/.env +++ /dev/null @@ -1,2 +0,0 @@ -export AZURE_STORAGE_DOCUMENT_API_KEY=xbiFtFeQ6v5dozgVM99fZ9huUomL7QcLu6s0y8zYHtIXZ8XdneKDMcg4liQr/9oNlVoRFcZhWjLY+ASt9cjICQ== -export JWT_SECRET_KEY=ea84edf152976b2fcec12b78aa8e45bc26a5cf0ef61bf16f5c317ae33b3fd8b0 \ No newline at end of file diff --git a/sites/central_storage/deploy/.env b/sites/central_storage/deploy/.env new file mode 100644 index 0000000..b3409ef --- /dev/null +++ b/sites/central_storage/deploy/.env @@ -0,0 +1,25 @@ +export APP_NAME=central_storage +export GIT_REPO_ROOT=/mnt/freeleaps/freeleaps-service-hub +export APP_PARENT_FOLDER=apps +export SERVICE_API_ACCESS_HOST=0.0.0.0 +export SERVICE_API_ACCESS_PORT=8005 +export CONTAINER_APP_ROOT=/app +export AZURE_STORAGE_DOCUMENT_API_KEY=xbiFtFeQ6v5dozgVM99fZ9huUomL7QcLu6s0y8zYHtIXZ8XdneKDMcg4liQr/9oNlVoRFcZhWjLY+ASt9cjICQ== +export AZURE_STORAGE_DOCUMENT_API_ENDPOINT="https://freeleaps1document.blob.core.windows.net/" +export LOG_BASE_PATH=$CONTAINER_APP_ROOT/log/$APP_NAME +export BACKEND_LOG_FILE_NAME=$APP_NAME +export APPLICATION_ACTIVITY_LOG=$APP_NAME-activity +export MONGODB_NAME=freeleaps2 +export MONGODB_PORT=27017 +export CODEBASE_ROOT=/mnt/freeleaps/freeleaps-service-hub/apps/central_storage +export WORKING_DIR=/mnt/freeleaps/freeleaps-service-hub/sites/central_storage/deploy +#!/bin/bash +export VENV_DIR=venv_t +export VENV_ACTIVATE=venv_t/bin/activate +export DOCKER_HOME=/var/lib/docker +export DOCKER_APP_HOME=$DOCKER_HOME/app +export DOCKER_BACKEND_HOME=$DOCKER_APP_HOME/$APP_NAME +export DOCKER_BACKEND_LOG_HOME=$DOCKER_BACKEND_HOME/log +export MONGODB_URI=mongodb://freeleaps2-mongodb:27017/ +export FREELEAPS_ENV=dev + diff --git a/sites/central_storage/deploy/alpha/.env b/sites/central_storage/deploy/alpha/.env new file mode 100755 index 0000000..68beb14 --- /dev/null +++ b/sites/central_storage/deploy/alpha/.env @@ -0,0 +1,3 @@ +export MONGODB_URI='mongodb+srv://jetli:8IHKx6dZK8BfugGp@freeleaps2.hanbj.mongodb.net/' +export FREELEAPS_ENV=alpha + diff --git a/sites/central_storage/deploy/common/.env b/sites/central_storage/deploy/common/.env new file mode 100755 index 0000000..fb5bf41 --- /dev/null +++ b/sites/central_storage/deploy/common/.env @@ -0,0 +1,10 @@ +export SERVICE_API_ACCESS_HOST=0.0.0.0 +export SERVICE_API_ACCESS_PORT=8005 +export CONTAINER_APP_ROOT=/app +export AZURE_STORAGE_DOCUMENT_API_KEY=xbiFtFeQ6v5dozgVM99fZ9huUomL7QcLu6s0y8zYHtIXZ8XdneKDMcg4liQr/9oNlVoRFcZhWjLY+ASt9cjICQ== +export AZURE_STORAGE_DOCUMENT_API_ENDPOINT="https://freeleaps1document.blob.core.windows.net/" +export LOG_BASE_PATH=$CONTAINER_APP_ROOT/log/$APP_NAME +export BACKEND_LOG_FILE_NAME=$APP_NAME +export APPLICATION_ACTIVITY_LOG=$APP_NAME-activity +export MONGODB_NAME=freeleaps2 +export MONGODB_PORT=27017 diff --git a/sites/central_storage/deploy/common/.host.env b/sites/central_storage/deploy/common/.host.env new file mode 100755 index 0000000..73c2468 --- /dev/null +++ b/sites/central_storage/deploy/common/.host.env @@ -0,0 +1,7 @@ +#!/bin/bash +export VENV_DIR=venv_t +export VENV_ACTIVATE=venv_t/bin/activate +export DOCKER_HOME=/var/lib/docker +export DOCKER_APP_HOME=$DOCKER_HOME/app +export DOCKER_BACKEND_HOME=$DOCKER_APP_HOME/$APP_NAME +export DOCKER_BACKEND_LOG_HOME=$DOCKER_BACKEND_HOME/log diff --git a/sites/central_storage/deploy/common/docker-compose.yaml b/sites/central_storage/deploy/common/docker-compose.yaml new file mode 100755 index 0000000..5a0e61d --- /dev/null +++ b/sites/central_storage/deploy/common/docker-compose.yaml @@ -0,0 +1,37 @@ +services: + central_storage: + container_name: $APP_NAME + build: + context: ${CODEBASE_ROOT} + args: + CONTAINER_APP_ROOT: ${CONTAINER_APP_ROOT} + profiles: [prod,alpha,dev] + restart: always + environment: + - APP_NAME=${APP_NAME} + - MONGODB_NAME=${MONGODB_NAME} + - MONGODB_PORT=${MONGODB_PORT} + - MONGODB_URI=${MONGODB_URI} + - SERVICE_API_ACCESS_HOST=${SERVICE_API_ACCESS_HOST} + - SERVICE_API_ACCESS_PORT=${SERVICE_API_ACCESS_PORT} + - AZURE_STORAGE_DOCUMENT_API_KEY=${AZURE_STORAGE_DOCUMENT_API_KEY} + - AZURE_STORAGE_DOCUMENT_API_ENDPOINT=${AZURE_STORAGE_DOCUMENT_API_ENDPOINT} + - LOG_BASE_PATH=${LOG_BASE_PATH} + - BACKEND_LOG_FILE_NAME=${BACKEND_LOG_FILE_NAME} + - APPLICATION_ACTIVITY_LOG=${APPLICATION_ACTIVITY_LOG} + ports: + - ${SERVICE_API_ACCESS_PORT}:${SERVICE_API_ACCESS_PORT} + command: + - /bin/sh + - -c + - | + uvicorn webapi.main:app --reload --port=${SERVICE_API_ACCESS_PORT} --host=${SERVICE_API_ACCESS_HOST} + networks: + - devbox_freeleaps2-network + volumes: + - type: bind + source: $DOCKER_BACKEND_LOG_HOME + target: $LOG_BASE_PATH +networks: + devbox_freeleaps2-network: + external: true \ No newline at end of file diff --git a/sites/central_storage/deploy/deploy.sh b/sites/central_storage/deploy/deploy.sh new file mode 100755 index 0000000..b380945 --- /dev/null +++ b/sites/central_storage/deploy/deploy.sh @@ -0,0 +1,90 @@ +#!/bin/bash +DW_BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +APP_NAME=central_storage +APP_PARENT_FOLDER=apps +PROJECT_NAME=central_storage + +while [ $# -gt 0 ]; do + case "$1" in + --target* | -u*) + if [[ "$1" != *=* ]]; then shift; fi # Value is next arg if no `=` + TARGET_ENV="${1#*=}" + ;; + --help | -h) + printf "$BASE_NAME --target=\n" # Flag argument + return 0 + ;; + *) + printf >&2 "Error: Invalid argument\n" + return 1 + ;; + esac + shift +done + +if [[ "${TARGET_ENV}" != "prod" && "${TARGET_ENV}" != "alpha" && "${TARGET_ENV}" != "dev" ]]; then + printf "$BASE_NAME --target=\n" # Flag argument + return 0 +fi +if git rev-parse --git-dir > /dev/null 2>&1; then + # git repo! + GIT_REPO_ROOT=$(git rev-parse --show-toplevel) + CODEBASE_ROOT=$GIT_REPO_ROOT/$APP_PARENT_FOLDER/$APP_NAME + WORKING_DIR=$GIT_REPO_ROOT/sites/$APP_NAME/deploy + +else + # NOT a git repo! + printf "Please run this command under a git repo" + return 0 +fi + +. $DW_BASE_DIR/common/.host.env + + +DW_PUSHD_COUNTER=0 + +ENV_FOLDER=$WORKING_DIR/$TARGET_ENV +COMMON_ENV_FOLDER=$WORKING_DIR/common + + +pushd $WORKING_DIR +DW_PUSHD_COUNTER=$((DW_PUSHD_COUNTER + 1)) + +echo export APP_NAME=$APP_NAME > $WORKING_DIR/.env +echo export GIT_REPO_ROOT=$GIT_REPO_ROOT >> $WORKING_DIR/.env +echo export APP_PARENT_FOLDER=$APP_PARENT_FOLDER >> $WORKING_DIR/.env + +cat $COMMON_ENV_FOLDER/.env >> $WORKING_DIR/.env +echo export CODEBASE_ROOT=$CODEBASE_ROOT >> $WORKING_DIR/.env +echo export WORKING_DIR=$WORKING_DIR >> $WORKING_DIR/.env +cat $COMMON_ENV_FOLDER/.host.env >> $WORKING_DIR/.env +cat $ENV_FOLDER/.env >>$WORKING_DIR/.env +DOCKER_COMPOSE_YAML=$WORKING_DIR/docker-compose-$APP_NAME.yaml +cp $DW_BASE_DIR/common/docker-compose.yaml $DOCKER_COMPOSE_YAML -u + +. $WORKING_DIR/.env + +sudo mkdir $DOCKER_BACKEND_LOG_HOME -p + +sudo docker compose -p $PROJECT_NAME -f $DOCKER_COMPOSE_YAML --profile $TARGET_ENV down --remove-orphans +sudo docker compose -p $PROJECT_NAME -f $DOCKER_COMPOSE_YAML --profile $TARGET_ENV build --no-cache + +# Clean up any previous resources that are not needed +# sudo docker system prune -f --volumes +# sudo docker image prune -f +# sudo docker container prune -f +# sudo docker network prune -f + +# Start up the Docker containers in detached mode and remove orphans +sudo docker compose -p $PROJECT_NAME -f $DOCKER_COMPOSE_YAML --profile $TARGET_ENV up --detach --remove-orphans +echo 'You can use "sudo docker compose logs -f" to check the output of the containers' +sudo docker ps -a + +#rm $WORKING_DIR/.env +#rm $DOCKER_COMPOSE_YAML + +while [[ "$DW_PUSHD_COUNTER" -gt 0 ]]; do + DW_PUSHD_COUNTER=$((DW_PUSHD_COUNTER - 1)) + popd +done + diff --git a/sites/central_storage/deploy/dev/.env b/sites/central_storage/deploy/dev/.env new file mode 100755 index 0000000..a43a6fe --- /dev/null +++ b/sites/central_storage/deploy/dev/.env @@ -0,0 +1,3 @@ +export MONGODB_URI=mongodb://freeleaps2-mongodb:27017/ +export FREELEAPS_ENV=dev + diff --git a/sites/central_storage/deploy/docker-compose-central_storage.yaml b/sites/central_storage/deploy/docker-compose-central_storage.yaml new file mode 100755 index 0000000..5a0e61d --- /dev/null +++ b/sites/central_storage/deploy/docker-compose-central_storage.yaml @@ -0,0 +1,37 @@ +services: + central_storage: + container_name: $APP_NAME + build: + context: ${CODEBASE_ROOT} + args: + CONTAINER_APP_ROOT: ${CONTAINER_APP_ROOT} + profiles: [prod,alpha,dev] + restart: always + environment: + - APP_NAME=${APP_NAME} + - MONGODB_NAME=${MONGODB_NAME} + - MONGODB_PORT=${MONGODB_PORT} + - MONGODB_URI=${MONGODB_URI} + - SERVICE_API_ACCESS_HOST=${SERVICE_API_ACCESS_HOST} + - SERVICE_API_ACCESS_PORT=${SERVICE_API_ACCESS_PORT} + - AZURE_STORAGE_DOCUMENT_API_KEY=${AZURE_STORAGE_DOCUMENT_API_KEY} + - AZURE_STORAGE_DOCUMENT_API_ENDPOINT=${AZURE_STORAGE_DOCUMENT_API_ENDPOINT} + - LOG_BASE_PATH=${LOG_BASE_PATH} + - BACKEND_LOG_FILE_NAME=${BACKEND_LOG_FILE_NAME} + - APPLICATION_ACTIVITY_LOG=${APPLICATION_ACTIVITY_LOG} + ports: + - ${SERVICE_API_ACCESS_PORT}:${SERVICE_API_ACCESS_PORT} + command: + - /bin/sh + - -c + - | + uvicorn webapi.main:app --reload --port=${SERVICE_API_ACCESS_PORT} --host=${SERVICE_API_ACCESS_HOST} + networks: + - devbox_freeleaps2-network + volumes: + - type: bind + source: $DOCKER_BACKEND_LOG_HOME + target: $LOG_BASE_PATH +networks: + devbox_freeleaps2-network: + external: true \ No newline at end of file diff --git a/sites/central_storage/deploy/local/.env b/sites/central_storage/deploy/local/.env new file mode 100644 index 0000000..4938c5e --- /dev/null +++ b/sites/central_storage/deploy/local/.env @@ -0,0 +1,3 @@ +export MONGODB_URI=mongodb://localhost:27017/ +export FREELEAPS_ENV=local + diff --git a/sites/central_storage/deploy/prod/.env b/sites/central_storage/deploy/prod/.env new file mode 100755 index 0000000..0167e99 --- /dev/null +++ b/sites/central_storage/deploy/prod/.env @@ -0,0 +1,2 @@ +export MONGODB_URI='mongodb+srv://freeadmin:0eMV0bt8oyaknA0m@freeleaps2.zmsmpos.mongodb.net/?retryWrites=true&w=majority' +export FREELEAPS_ENV=prod diff --git a/sites/content/deploy/deploy.sh b/sites/content/deploy/deploy.sh index 8a7f029..4837bc6 100755 --- a/sites/content/deploy/deploy.sh +++ b/sites/content/deploy/deploy.sh @@ -1,6 +1,7 @@ #!/bin/bash DW_BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" APP_NAME=content +PROJECT_NAME=content while [ $# -gt 0 ]; do case "$1" in @@ -54,14 +55,15 @@ echo export WORKING_DIR=$WORKING_DIR >> $WORKING_DIR/.env cat $COMMON_ENV_FOLDER/.host.env >> $WORKING_DIR/.env cat $ENV_FOLDER/.env >>$WORKING_DIR/.env -cp $DW_BASE_DIR/common/docker-compose.yaml $WORKING_DIR +DOCKER_COMPOSE_YAML=$WORKING_DIR/docker-compose-$APP_NAME.yaml +cp $DW_BASE_DIR/common/docker-compose.yaml $DOCKER_COMPOSE_YAML -u . $WORKING_DIR/.env sudo mkdir $DOCKER_BACKEND_LOG_HOME -p -sudo docker compose --profile $TARGET_ENV down --remove-orphans -sudo docker compose --profile $TARGET_ENV build --no-cache +sudo docker compose -p $PROJECT_NAME -f $DOCKER_COMPOSE_YAML --profile $TARGET_ENV down --remove-orphans +sudo docker compose -p $PROJECT_NAME -f $DOCKER_COMPOSE_YAML --profile $TARGET_ENV build --no-cache # Clean up any previous resources that are not needed # sudo docker system prune -f --volumes @@ -70,12 +72,12 @@ sudo docker compose --profile $TARGET_ENV build --no-cache # sudo docker network prune -f # Start up the Docker containers in detached mode and remove orphans -sudo docker compose --profile $TARGET_ENV up --detach --remove-orphans +sudo docker compose -p $PROJECT_NAME -f $DOCKER_COMPOSE_YAML --profile $TARGET_ENV up --detach --remove-orphans echo 'You can use "sudo docker compose logs -f" to check the output of the containers' sudo docker ps -a rm $WORKING_DIR/.env -rm $WORKING_DIR/docker-compose.yaml +rm $DOCKER_COMPOSE_YAML while [[ "$DW_PUSHD_COUNTER" -gt 0 ]]; do DW_PUSHD_COUNTER=$((DW_PUSHD_COUNTER - 1))