From de37fcddba6a36ad34c7a509426e9626dfcc913e Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Sat, 22 Feb 2025 11:40:23 +0000 Subject: [PATCH 01/11] build(docker): remove additional scripts --- apps/authentication/Dockerfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/authentication/Dockerfile b/apps/authentication/Dockerfile index 9b05c5c..a586477 100644 --- a/apps/authentication/Dockerfile +++ b/apps/authentication/Dockerfile @@ -34,15 +34,15 @@ RUN pip install --no-cache-dir -r requirements.txt COPY . ${CONTAINER_APP_ROOT} # Install tools and keyring updates -RUN apt-get update && apt-get install -y --no-install-recommends \ - gnupg wget && \ - apt-get install -y debian-keyring debian-archive-keyring && \ - rm -rf /var/lib/apt/lists/* +#RUN apt-get update && apt-get install -y --no-install-recommends \ +# gnupg wget && \ +# apt-get install -y debian-keyring debian-archive-keyring && \ +# rm -rf /var/lib/apt/lists/* # Install additional tools and create symbolic links -RUN apt-get update && apt-get install -y netcat && \ - ln -s /bin/bash /usr/bin/bash && \ - rm -rf /var/lib/apt/lists/* +#RUN apt-get update && apt-get install -y netcat && \ +# ln -s /bin/bash /usr/bin/bash && \ +# rm -rf /var/lib/apt/lists/* EXPOSE ${SERVICE_API_ACCESS_PORT} CMD ["uvicorn", "webapi.main:app", "--reload", "--port=${SERVICE_API_ACCESS_PORT}", "--host=${SERVICE_API_ACCESS_HOST}"] From be910d4c958e55f7f4c9462a1727d9379a047eff Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Sat, 22 Feb 2025 11:54:59 +0000 Subject: [PATCH 02/11] build(docker): remove useless scripts in Dockerfile --- apps/central_storage/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/central_storage/Dockerfile b/apps/central_storage/Dockerfile index 0f59f09..fd7d0cf 100644 --- a/apps/central_storage/Dockerfile +++ b/apps/central_storage/Dockerfile @@ -30,9 +30,9 @@ 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 +#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}"] From f22a2eedf2b0bbee47684e8d27eed29eaaccfa02 Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Sat, 22 Feb 2025 11:55:16 +0000 Subject: [PATCH 03/11] build(docker): remove useless scripts in Dockerfile --- apps/content/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/content/Dockerfile b/apps/content/Dockerfile index bc442b7..2b4b2fd 100644 --- a/apps/content/Dockerfile +++ b/apps/content/Dockerfile @@ -30,9 +30,9 @@ 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 +#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}"] From 0a7c7429c3ab72f747ac0fb5b27079308a0faaad Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Sat, 22 Feb 2025 11:55:44 +0000 Subject: [PATCH 04/11] Updated Dockerfile --- apps/notification/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/notification/Dockerfile b/apps/notification/Dockerfile index 4973096..ea71d9b 100644 --- a/apps/notification/Dockerfile +++ b/apps/notification/Dockerfile @@ -38,9 +38,9 @@ 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 +#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}"] From 3769af6e93929488869f6f579aec5e2c70b6f1fd Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Sat, 22 Feb 2025 12:34:08 +0000 Subject: [PATCH 05/11] build(docker): update Dockerfile for notification --- apps/notification/Dockerfile | 8 -------- 1 file changed, 8 deletions(-) diff --git a/apps/notification/Dockerfile b/apps/notification/Dockerfile index ea71d9b..8f7bdd0 100644 --- a/apps/notification/Dockerfile +++ b/apps/notification/Dockerfile @@ -4,7 +4,6 @@ FROM python:3.10-slim-buster ARG CONTAINER_APP_ROOT=/app ENV APP_NAME=notification - #site_settings ENV SERVICE_API_ACCESS_HOST=0.0.0.0 ENV SERVICE_API_ACCESS_PORT=8003 @@ -22,14 +21,11 @@ ENV SENDGRID_API_KEY=SG.OrxsRI0IRaOxkd7xTfb8SA.J8CfOXsJy3vrJgTubbLmZOR6ii7z7m7C9 ENV TWILIO_ACCOUNT_SID=ACf8c9283a6acda060258eadb29be58bc8 ENV TWILIO_AUTH_TOKEN=120165c0550111ddfd58efc97dafc2fe - - #log_settings ENV LOG_BASE_PATH=$CONTAINER_APP_ROOT/log/$APP_NAME ENV BACKEND_LOG_FILE_NAME=$APP_NAME ENV APPLICATION_ACTIVITY_LOG=$APP_NAME-activity - WORKDIR ${CONTAINER_APP_ROOT} COPY requirements.txt . @@ -38,9 +34,5 @@ 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}"] From 8f799c60ffd5a48481bdf1d0d45f2cb02f4f07ec Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Sat, 22 Feb 2025 12:34:30 +0000 Subject: [PATCH 06/11] build(docker): update Dockerfile for payment --- apps/payment/Dockerfile | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/apps/payment/Dockerfile b/apps/payment/Dockerfile index ea1836d..756a34b 100644 --- a/apps/payment/Dockerfile +++ b/apps/payment/Dockerfile @@ -15,14 +15,11 @@ ENV MONGODB_NAME=freeleaps2 ENV MONGODB_PORT=27017 ENV MONGODB_URI="mongodb://freeleaps2-mongodb:27017/" - - #log_settings ENV LOG_BASE_PATH=$CONTAINER_APP_ROOT/log/$APP_NAME ENV BACKEND_LOG_FILE_NAME=$APP_NAME ENV APPLICATION_ACTIVITY_LOG=$APP_NAME-activity - WORKDIR ${CONTAINER_APP_ROOT} COPY requirements.txt . @@ -31,21 +28,6 @@ RUN pip install --no-cache-dir -r requirements.txt COPY . ${CONTAINER_APP_ROOT} -#RUN apt update -y -#RUN apt install -y netcat -#RUN ln -s /bin/bash /usr/bin/bash - -# Install tools and keyring updates -#RUN apt-get update && apt-get install -y --no-install-recommends \ -# gnupg wget && \ -# apt-get install -y debian-keyring debian-archive-keyring && \ -# rm -rf /var/lib/apt/lists/* -# -## Install additional tools and create symbolic links -#RUN apt-get update && apt-get install -y netcat && \ -# ln -s /bin/bash /usr/bin/bash && \ -# rm -rf /var/lib/apt/lists/* - EXPOSE ${SERVICE_API_ACCESS_PORT} #CMD ["uvicorn", "webapi.main:app", "--reload", "--port=${SERVICE_API_ACCESS_PORT}", "--host=${SERVICE_API_ACCESS_HOST}"] CMD uvicorn webapi.main:app --reload --port=${SERVICE_API_ACCESS_PORT} --host=${SERVICE_API_ACCESS_HOST} \ No newline at end of file From b0acad860e40c52f5da1b3ee247abef7cb40fd39 Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Sat, 22 Feb 2025 13:00:05 +0000 Subject: [PATCH 07/11] build(docker): update Dockerfile for notification --- apps/notification/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/notification/Dockerfile b/apps/notification/Dockerfile index 8f7bdd0..cf60fab 100644 --- a/apps/notification/Dockerfile +++ b/apps/notification/Dockerfile @@ -4,7 +4,6 @@ FROM python:3.10-slim-buster ARG CONTAINER_APP_ROOT=/app ENV APP_NAME=notification -#site_settings ENV SERVICE_API_ACCESS_HOST=0.0.0.0 ENV SERVICE_API_ACCESS_PORT=8003 ENV RABBITMQ_HOST=localhost From 9b42dbfa7f16c1699e03c27ccb1e1a6947773dd8 Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Sat, 22 Feb 2025 13:37:47 +0000 Subject: [PATCH 08/11] build(dockerfile): update entrypoint for authentication --- apps/authentication/Dockerfile | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/apps/authentication/Dockerfile b/apps/authentication/Dockerfile index a586477..1439b4b 100644 --- a/apps/authentication/Dockerfile +++ b/apps/authentication/Dockerfile @@ -17,8 +17,6 @@ ENV MONGODB_NAME=freeleaps2 ENV MONGODB_PORT=27017 ENV MONGODB_URI="mongodb://localhost:27017/" - - #log_settings ENV LOG_BASE_PATH=$CONTAINER_APP_ROOT/log/$APP_NAME ENV BACKEND_LOG_FILE_NAME=$APP_NAME @@ -33,16 +31,6 @@ RUN pip install --no-cache-dir -r requirements.txt COPY . ${CONTAINER_APP_ROOT} -# Install tools and keyring updates -#RUN apt-get update && apt-get install -y --no-install-recommends \ -# gnupg wget && \ -# apt-get install -y debian-keyring debian-archive-keyring && \ -# rm -rf /var/lib/apt/lists/* - -# Install additional tools and create symbolic links -#RUN apt-get update && apt-get install -y netcat && \ -# ln -s /bin/bash /usr/bin/bash && \ -# rm -rf /var/lib/apt/lists/* - EXPOSE ${SERVICE_API_ACCESS_PORT} -CMD ["uvicorn", "webapi.main:app", "--reload", "--port=${SERVICE_API_ACCESS_PORT}", "--host=${SERVICE_API_ACCESS_HOST}"] +# Using shell to expand environemnt to enure pass the actual environment value to uvicorn +CMD uvicorn webapi.main:app --reload --port=$SERVICE_API_ACCESS_PORT --host=$SERVICE_API_ACCESS_HOST \ No newline at end of file From da584b8ffa0a4abf4efbb6106e09bc695194deda Mon Sep 17 00:00:00 2001 From: zhenyus Date: Sat, 22 Feb 2025 22:30:37 +0800 Subject: [PATCH 09/11] build(docker): update CMD to use shell for environment variable expansion in Dockerfiles Signed-off-by: zhenyus --- apps/central_storage/Dockerfile | 3 ++- apps/content/Dockerfile | 3 ++- apps/notification/Dockerfile | 3 ++- apps/payment/Dockerfile | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/central_storage/Dockerfile b/apps/central_storage/Dockerfile index fd7d0cf..fbf07c1 100644 --- a/apps/central_storage/Dockerfile +++ b/apps/central_storage/Dockerfile @@ -35,4 +35,5 @@ COPY . ${CONTAINER_APP_ROOT} #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}"] +# Using shell to expand environemnt to enure pass the actual environment value to uvicorn +CMD uvicorn webapi.main:app --reload --port=$SERVICE_API_ACCESS_PORT --host=$SERVICE_API_ACCESS_HOST diff --git a/apps/content/Dockerfile b/apps/content/Dockerfile index 2b4b2fd..bfad1fd 100644 --- a/apps/content/Dockerfile +++ b/apps/content/Dockerfile @@ -35,4 +35,5 @@ COPY . ${CONTAINER_APP_ROOT} #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}"] +# Using shell to expand environemnt to enure pass the actual environment value to uvicorn +CMD uvicorn webapi.main:app --reload --port=$SERVICE_API_ACCESS_PORT --host=$SERVICE_API_ACCESS_HOST \ No newline at end of file diff --git a/apps/notification/Dockerfile b/apps/notification/Dockerfile index cf60fab..b246de3 100644 --- a/apps/notification/Dockerfile +++ b/apps/notification/Dockerfile @@ -34,4 +34,5 @@ RUN pip install --no-cache-dir -r requirements.txt COPY . ${CONTAINER_APP_ROOT} EXPOSE ${SERVICE_API_ACCESS_PORT} -CMD ["uvicorn", "webapi.main:app", "--reload", "--port=${SERVICE_API_ACCESS_PORT}", "--host=${SERVICE_API_ACCESS_HOST}"] +# Using shell to expand environemnt to enure pass the actual environment value to uvicorn +CMD uvicorn webapi.main:app --reload --port=$SERVICE_API_ACCESS_PORT --host=$SERVICE_API_ACCESS_HOST \ No newline at end of file diff --git a/apps/payment/Dockerfile b/apps/payment/Dockerfile index 756a34b..f5ac56d 100644 --- a/apps/payment/Dockerfile +++ b/apps/payment/Dockerfile @@ -29,5 +29,5 @@ RUN pip install --no-cache-dir -r requirements.txt COPY . ${CONTAINER_APP_ROOT} EXPOSE ${SERVICE_API_ACCESS_PORT} -#CMD ["uvicorn", "webapi.main:app", "--reload", "--port=${SERVICE_API_ACCESS_PORT}", "--host=${SERVICE_API_ACCESS_HOST}"] +# Using shell to expand environemnt to enure pass the actual environment value to uvicorn CMD uvicorn webapi.main:app --reload --port=${SERVICE_API_ACCESS_PORT} --host=${SERVICE_API_ACCESS_HOST} \ No newline at end of file From 853d81793332513e89286d61429444d520252c27 Mon Sep 17 00:00:00 2001 From: zhenyus Date: Mon, 24 Feb 2025 02:05:25 +0800 Subject: [PATCH 10/11] feat(notification): add rabbitmq credentials relates notification services configs Signed-off-by: zhenyus --- apps/notification/backend/infra/rabbitmq/async_client.py | 5 ++++- apps/notification/common/config/app_settings.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/notification/backend/infra/rabbitmq/async_client.py b/apps/notification/backend/infra/rabbitmq/async_client.py index 4b5c929..2387125 100644 --- a/apps/notification/backend/infra/rabbitmq/async_client.py +++ b/apps/notification/backend/infra/rabbitmq/async_client.py @@ -25,7 +25,10 @@ class AsyncMQClient: try: self.connection = await aio_pika.connect_robust( host=app_settings.RABBITMQ_HOST, - port=int(app_settings.RABBITMQ_PORT), + port=int(app_settings.RABBITMQ_PORT, + login=app_settings.RABBITMQ_USERNAME, + password=app_settings.RABBITMQ_PASSWORD, + virtualhost=app_settings.RABBITMQ_VIRTUAL_HOST), loop=event_loop, ) self.channel = await self.connection.channel() diff --git a/apps/notification/common/config/app_settings.py b/apps/notification/common/config/app_settings.py index 620d05c..ec72713 100644 --- a/apps/notification/common/config/app_settings.py +++ b/apps/notification/common/config/app_settings.py @@ -8,6 +8,9 @@ class AppSettings(BaseSettings): RABBITMQ_HOST: str = "" RABBITMQ_PORT: int = 5672 + RABBITMQ_USERNAME: str = "" + RABBITMQ_PASSWORD: str = "" + RABBITMQ_VIRTUAL_HOST: str = "" SYSTEM_USER_ID: str = "" SMS_FROM: str = "" From 78c72179ec3fdb15d4af01bee15a441f0e383638 Mon Sep 17 00:00:00 2001 From: zhenyus Date: Mon, 24 Feb 2025 02:20:01 +0800 Subject: [PATCH 11/11] fix(rabbitmq): correct syntax for port and virtual host parameters in AsyncMQClient Signed-off-by: zhenyus --- apps/notification/backend/infra/rabbitmq/async_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/notification/backend/infra/rabbitmq/async_client.py b/apps/notification/backend/infra/rabbitmq/async_client.py index 2387125..0df0745 100644 --- a/apps/notification/backend/infra/rabbitmq/async_client.py +++ b/apps/notification/backend/infra/rabbitmq/async_client.py @@ -25,10 +25,10 @@ class AsyncMQClient: try: self.connection = await aio_pika.connect_robust( host=app_settings.RABBITMQ_HOST, - port=int(app_settings.RABBITMQ_PORT, + port=int(app_settings.RABBITMQ_PORT), login=app_settings.RABBITMQ_USERNAME, password=app_settings.RABBITMQ_PASSWORD, - virtualhost=app_settings.RABBITMQ_VIRTUAL_HOST), + virtualhost=app_settings.RABBITMQ_VIRTUAL_HOST, loop=event_loop, ) self.channel = await self.connection.channel()