update some settings
This commit is contained in:
parent
171ccdc2c4
commit
234c5a491f
@ -1,23 +0,0 @@
|
|||||||
APP_NAME=authentication
|
|
||||||
export SERVICE_API_ACCESS_HOST=0.0.0.0
|
|
||||||
export SERVICE_API_ACCESS_PORT=8004
|
|
||||||
export CONTAINER_APP_ROOT=/app
|
|
||||||
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 JWT_SECRET_KEY=ea84edf152976b2fcec12b78aa8e45bc26a5cf0ef61bf16f5c317ae33b3fd8b0
|
|
||||||
GIT_REPO_ROOT=/mnt/freeleaps/freeleaps-service-hub
|
|
||||||
CODEBASE_ROOT=/mnt/freeleaps/freeleaps-service-hub/apps/authentication
|
|
||||||
SITE_DEPLOY_FOLDER=/mnt/freeleaps/freeleaps-service-hub/sites/authentication/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
|
|
||||||
|
|
||||||
@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
|
from pydantic_settings import BaseSettings
|
||||||
|
from .app_settings import app_settings
|
||||||
|
|
||||||
class LogSettings():
|
class LogSettings():
|
||||||
LOG_LEVEL: str = "DEBUG"
|
LOG_LEVEL: str = "DEBUG"
|
||||||
LOG_PATH_BASE: str = (
|
LOG_BASE_PATH: str = app_settings.LOG_BASE_PATH
|
||||||
"./logs"
|
LOG_PATH: str = LOG_BASE_PATH + '/' + app_settings.BACKEND_LOG_FILE_NAME + '.log'
|
||||||
)
|
|
||||||
LOG_PATH: str = LOG_PATH_BASE + '/' + "app" + '.log'
|
|
||||||
LOG_RETENTION: str = "14 days"
|
LOG_RETENTION: str = "14 days"
|
||||||
LOG_ROTATION: str = "00:00" # mid night
|
LOG_ROTATION: str = "00:00" # mid night
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
|
from pydantic_settings import BaseSettings
|
||||||
|
from .app_settings import app_settings
|
||||||
|
|
||||||
class LogSettings():
|
class LogSettings():
|
||||||
LOG_LEVEL: str = "DEBUG"
|
LOG_LEVEL: str = "DEBUG"
|
||||||
LOG_PATH_BASE: str = (
|
LOG_BASE_PATH: str = app_settings.LOG_BASE_PATH
|
||||||
"./logs"
|
LOG_PATH: str = LOG_BASE_PATH + '/' + app_settings.BACKEND_LOG_FILE_NAME + '.log'
|
||||||
)
|
|
||||||
LOG_PATH: str = LOG_PATH_BASE + '/' + "app" + '.log'
|
|
||||||
LOG_RETENTION: str = "14 days"
|
LOG_RETENTION: str = "14 days"
|
||||||
LOG_ROTATION: str = "00:00" # mid night
|
LOG_ROTATION: str = "00:00" # mid night
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
|
from pydantic_settings import BaseSettings
|
||||||
|
from .app_settings import app_settings
|
||||||
|
|
||||||
class LogSettings():
|
class LogSettings():
|
||||||
LOG_LEVEL: str = "DEBUG"
|
LOG_LEVEL: str = "DEBUG"
|
||||||
LOG_PATH_BASE: str = (
|
LOG_BASE_PATH: str = app_settings.LOG_BASE_PATH
|
||||||
"./logs"
|
LOG_PATH: str = LOG_BASE_PATH + '/' + app_settings.BACKEND_LOG_FILE_NAME + '.log'
|
||||||
)
|
|
||||||
LOG_PATH: str = LOG_PATH_BASE + '/' + "app" + '.log'
|
|
||||||
LOG_RETENTION: str = "14 days"
|
LOG_RETENTION: str = "14 days"
|
||||||
LOG_ROTATION: str = "00:00" # mid night
|
LOG_ROTATION: str = "00:00" # mid night
|
||||||
|
|
||||||
|
|||||||
@ -1,19 +1,46 @@
|
|||||||
# Dockerfile for Python Service
|
FROM python:3.10-slim-buster
|
||||||
FROM python:3.10-slim
|
|
||||||
|
|
||||||
# Set the working directory inside the container
|
# docker settings
|
||||||
WORKDIR /app
|
ARG CONTAINER_APP_ROOT=
|
||||||
|
ENV APP_NAME=
|
||||||
|
|
||||||
# Copy the requirements.txt to the working directory and install dependencies
|
|
||||||
COPY requirements.txt ./
|
#site_settings
|
||||||
|
ENV SERVICE_API_ACCESS_HOST=0.0.0.0
|
||||||
|
ENV SERVICE_API_ACCESS_PORT=8003
|
||||||
|
ENV RABBITMQ_HOST=
|
||||||
|
ENV RABBITMQ_PORT=
|
||||||
|
|
||||||
|
ENV SYSTEM_USER_ID=
|
||||||
|
ENV SMS_FROM=
|
||||||
|
ENV EMAIL_FROM=
|
||||||
|
|
||||||
|
ENV SECRET_KEY=
|
||||||
|
|
||||||
|
ENV SENDGRID_API_KEY=
|
||||||
|
|
||||||
|
ENV TWILIO_ACCOUNT_SID=
|
||||||
|
ENV TWILIO_AUTH_TOKEN=
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#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
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
# Copy the application code to the working directory
|
COPY . ${CONTAINER_APP_ROOT}
|
||||||
COPY . /app
|
|
||||||
|
|
||||||
# Expose the port used by the FastAPI app
|
RUN apt update
|
||||||
EXPOSE 8003
|
RUN apt install -y netcat
|
||||||
|
RUN ln -s /bin/bash /usr/bin/bash
|
||||||
|
|
||||||
|
EXPOSE ${SERVICE_API_ACCESS_PORT}
|
||||||
# Run the application using the start script
|
CMD ["uvicorn", "webapi.main:app", "--reload", "--port=${SERVICE_API_ACCESS_PORT}", "--host=${SERVICE_API_ACCESS_HOST}"]
|
||||||
CMD ["uvicorn", "app.notification.webapi.main:app", "--reload", "--port=8003", "--host=0.0.0.0"]
|
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
## This would be the app specific log setting file
|
|
||||||
class LogSettings:
|
from pydantic_settings import BaseSettings
|
||||||
|
from .app_settings import app_settings
|
||||||
|
|
||||||
|
class LogSettings():
|
||||||
LOG_LEVEL: str = "DEBUG"
|
LOG_LEVEL: str = "DEBUG"
|
||||||
LOG_PATH_BASE: str = "./logs"
|
LOG_BASE_PATH: str = app_settings.LOG_BASE_PATH
|
||||||
LOG_PATH: str = LOG_PATH_BASE + "/" + "app" + ".log"
|
LOG_PATH: str = LOG_BASE_PATH + '/' + app_settings.BACKEND_LOG_FILE_NAME + '.log'
|
||||||
LOG_RETENTION: str = "14 days"
|
LOG_RETENTION: str = "14 days"
|
||||||
LOG_ROTATION: str = "00:00" # mid night
|
LOG_ROTATION: str = "00:00" # mid night
|
||||||
|
|
||||||
|
|||||||
40
apps/notification/start_fastapi.sh
Executable file
40
apps/notification/start_fastapi.sh
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
rp=$(dirname "$(realpath '$1'))")
|
||||||
|
pushd $rp
|
||||||
|
|
||||||
|
APP_NAME=notification
|
||||||
|
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
|
||||||
3
sites/notification/deploy/alpha/.env
Executable file
3
sites/notification/deploy/alpha/.env
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
export MONGODB_URI='mongodb+srv://jetli:8IHKx6dZK8BfugGp@freeleaps2.hanbj.mongodb.net/'
|
||||||
|
export FREELEAPS_ENV=alpha
|
||||||
|
|
||||||
7
sites/notification/.env → sites/notification/deploy/common/.env
Normal file → Executable file
7
sites/notification/.env → sites/notification/deploy/common/.env
Normal file → Executable file
@ -1,5 +1,10 @@
|
|||||||
|
export SERVICE_API_ACCESS_HOST=0.0.0.0
|
||||||
|
export SERVICE_API_ACCESS_PORT=8004
|
||||||
|
export CONTAINER_APP_ROOT=/app
|
||||||
|
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 SENDGRID_API_KEY='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'
|
export SENDGRID_API_KEY='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'
|
||||||
export EMAIL_FROM=freeleaps@freeleaps.com
|
export EMAIL_FROM=freeleaps@freeleaps.com
|
||||||
export TWILIO_ACCOUNT_SID=ACf8c9283a6acda060258eadb29be58bc8
|
export TWILIO_ACCOUNT_SID=ACf8c9283a6acda060258eadb29be58bc8
|
||||||
export TWILIO_AUTH_TOKEN=ef160748cc22c8b7195b49df4b8eca7e
|
export TWILIO_AUTH_TOKEN=ef160748cc22c8b7195b49df4b8eca7e
|
||||||
export JWT_SECRET_KEY=ea84edf152976b2fcec12b78aa8e45bc26a5cf0ef61bf16f5c317ae33b3fd8b0
|
|
||||||
7
sites/notification/deploy/common/.host.env
Executable file
7
sites/notification/deploy/common/.host.env
Executable file
@ -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
|
||||||
36
sites/notification/deploy/common/docker-compose.yaml
Executable file
36
sites/notification/deploy/common/docker-compose.yaml
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
services:
|
||||||
|
authentication:
|
||||||
|
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}
|
||||||
|
- LOG_BASE_PATH=${LOG_BASE_PATH}
|
||||||
|
- BACKEND_LOG_FILE_NAME=${BACKEND_LOG_FILE_NAME}
|
||||||
|
- APPLICATION_ACTIVITY_LOG=${APPLICATION_ACTIVITY_LOG}
|
||||||
|
- JWT_SECRET_KEY=${JWT_SECRET_KEY}
|
||||||
|
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
|
||||||
91
sites/notification/deploy/deploy.sh
Executable file
91
sites/notification/deploy/deploy.sh
Executable file
@ -0,0 +1,91 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
DW_BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
|
||||||
|
APP_NAME=authentication
|
||||||
|
APP_PARENT_FOLDER=apps
|
||||||
|
PROJECT_NAME=authentication
|
||||||
|
|
||||||
|
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=<prod | alpha | dev>\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=<prod | alpha | dev>\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
|
||||||
|
|
||||||
3
sites/notification/deploy/dev/.env
Executable file
3
sites/notification/deploy/dev/.env
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
export MONGODB_URI=mongodb://freeleaps2-mongodb:27017/
|
||||||
|
export FREELEAPS_ENV=dev
|
||||||
|
|
||||||
3
sites/notification/deploy/local/.env
Normal file
3
sites/notification/deploy/local/.env
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export MONGODB_URI=mongodb://localhost:27017/
|
||||||
|
export FREELEAPS_ENV=local
|
||||||
|
|
||||||
2
sites/notification/deploy/prod/.env
Executable file
2
sites/notification/deploy/prod/.env
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
export MONGODB_URI='mongodb+srv://freeadmin:0eMV0bt8oyaknA0m@freeleaps2.zmsmpos.mongodb.net/?retryWrites=true&w=majority'
|
||||||
|
export FREELEAPS_ENV=prod
|
||||||
Loading…
Reference in New Issue
Block a user