From 932571d413655c541553df12e598bcac8fb05028 Mon Sep 17 00:00:00 2001 From: A'zamov Samandar Date: Sat, 19 Apr 2025 16:00:12 +0500 Subject: [PATCH 1/5] deploy.yml: Docker compose profiling for auth and payment optimize --- .github/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index db808fa..0dae23b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -20,5 +20,6 @@ jobs: - name: 🛠 Docker Compose bilan build & deploy run: | + docker compose --profile auth --profile payment build docker compose down - docker compose --profile auth --profile payment up -d --build \ No newline at end of file + docker compose --profile auth --profile payment up -d \ No newline at end of file From e5b57671c873d1670fced14adfbdc4510bbdd727 Mon Sep 17 00:00:00 2001 From: A'zamov Samandar Date: Sat, 19 Apr 2025 16:28:06 +0500 Subject: [PATCH 2/5] Makefile'dan bo'lak qismlar o'chirildi, docker-compose va Dockerfile'ga yangiliklar qo'shildi, yangi payment/api ilovasi yaratildi. --- Makefile | 2 - auth/config/conf/apps.py | 4 - docker-compose.yml | 5 ++ payment/Dockerfile | 14 +++- payment/api/__init__.py | 0 payment/api/admin.py | 3 + payment/api/apps.py | 6 ++ payment/api/migrations/__init__.py | 0 payment/api/models.py | 3 + payment/api/tests.py | 3 + payment/api/urls.py | 6 ++ payment/api/views.py | 7 ++ payment/config/__init__.py | 0 payment/config/asgi.py | 16 ++++ payment/config/settings.py | 126 +++++++++++++++++++++++++++++ payment/config/urls.py | 7 ++ payment/config/wsgi.py | 16 ++++ payment/db.sqlite3 | Bin 0 -> 131072 bytes payment/entrypoint.sh | 5 ++ payment/manage.py | 22 +++++ payment/requirements.txt | 2 + 21 files changed, 239 insertions(+), 8 deletions(-) create mode 100644 payment/api/__init__.py create mode 100644 payment/api/admin.py create mode 100644 payment/api/apps.py create mode 100644 payment/api/migrations/__init__.py create mode 100644 payment/api/models.py create mode 100644 payment/api/tests.py create mode 100644 payment/api/urls.py create mode 100644 payment/api/views.py create mode 100644 payment/config/__init__.py create mode 100644 payment/config/asgi.py create mode 100644 payment/config/settings.py create mode 100644 payment/config/urls.py create mode 100644 payment/config/wsgi.py create mode 100644 payment/db.sqlite3 create mode 100644 payment/entrypoint.sh create mode 100755 payment/manage.py create mode 100644 payment/requirements.txt diff --git a/Makefile b/Makefile index 92f900f..5660e6b 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,8 @@ up-auth: down-auth: docker compose --profile auth down - up-payment: docker compose --profile payment up -d - down-payment: docker compose --profile payment down diff --git a/auth/config/conf/apps.py b/auth/config/conf/apps.py index c6a0459..d9739d9 100644 --- a/auth/config/conf/apps.py +++ b/auth/config/conf/apps.py @@ -1,11 +1,7 @@ from config.env import env APPS = [ - "cacheops", - - - "drf_spectacular", "rest_framework", "corsheaders", diff --git a/docker-compose.yml b/docker-compose.yml index 3c9c52a..72e42f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -75,6 +75,11 @@ services: - auth payment: + labels: + - "traefik.enable=true" + - "traefik.http.routers.payment.rule=PathPrefix(`/payment`)" + - "traefik.http.routers.payment.entrypoints=web" + - "traefik.http.services.payment.loadbalancer.server.port=8000" networks: - lamenu build: diff --git a/payment/Dockerfile b/payment/Dockerfile index 9173c11..7d6e714 100644 --- a/payment/Dockerfile +++ b/payment/Dockerfile @@ -1,3 +1,13 @@ -FROM alpine:latest +FROM python:3.13-alpine -CMD ["sleep", "60"] \ No newline at end of file +ENV PYTHONPYCACHEPREFIX=/dev/null + +RUN apk update && apk add git gettext + +WORKDIR /code + +COPY requirements.txt /code/requirements.txt + +RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt + +CMD ["sh", "./entrypoint.sh"] \ No newline at end of file diff --git a/payment/api/__init__.py b/payment/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/payment/api/admin.py b/payment/api/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/payment/api/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/payment/api/apps.py b/payment/api/apps.py new file mode 100644 index 0000000..878e7d5 --- /dev/null +++ b/payment/api/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ApiConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "api" diff --git a/payment/api/migrations/__init__.py b/payment/api/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/payment/api/models.py b/payment/api/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/payment/api/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/payment/api/tests.py b/payment/api/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/payment/api/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/payment/api/urls.py b/payment/api/urls.py new file mode 100644 index 0000000..108460e --- /dev/null +++ b/payment/api/urls.py @@ -0,0 +1,6 @@ +from django.urls import path +from .views import HealthView + +urlpatterns = [ + path("health/", HealthView.as_view()) +] \ No newline at end of file diff --git a/payment/api/views.py b/payment/api/views.py new file mode 100644 index 0000000..3877edb --- /dev/null +++ b/payment/api/views.py @@ -0,0 +1,7 @@ +from rest_framework.views import APIView +from rest_framework.response import Response + + +class HealthView(APIView): + def get(self, *args, **kwargs): + return Response(data={"detail": "OK"}) \ No newline at end of file diff --git a/payment/config/__init__.py b/payment/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/payment/config/asgi.py b/payment/config/asgi.py new file mode 100644 index 0000000..19b90e3 --- /dev/null +++ b/payment/config/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for config project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") + +application = get_asgi_application() diff --git a/payment/config/settings.py b/payment/config/settings.py new file mode 100644 index 0000000..bb269d2 --- /dev/null +++ b/payment/config/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for config project. + +Generated by 'django-admin startproject' using Django 5.1.3. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.1/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = "django-insecure-iv-iwjd(4d%g5&fyo*+xybkjhaik+r@3j0$h91u0^$u4fwuh53" + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [ + "*" +] + + +# Application definition + +INSTALLED_APPS = [ + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "api", +] + +MIDDLEWARE = [ + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", +] + +ROOT_URLCONF = "config.urls" + +TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", + ], + }, + }, +] + +WSGI_APPLICATION = "config.wsgi.application" + + +# Database +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", + } +} + + +# Password validation +# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/5.1/topics/i18n/ + +LANGUAGE_CODE = "en-us" + +TIME_ZONE = "UTC" + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/5.1/howto/static-files/ + +STATIC_URL = "static/" + +# Default primary key field type +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/payment/config/urls.py b/payment/config/urls.py new file mode 100644 index 0000000..de9a619 --- /dev/null +++ b/payment/config/urls.py @@ -0,0 +1,7 @@ +from django.contrib import admin +from django.urls import path, include + +urlpatterns = [ + path("payment/api/", include("api.urls")), + path("payment/admin/", admin.site.urls), +] diff --git a/payment/config/wsgi.py b/payment/config/wsgi.py new file mode 100644 index 0000000..b2bb19f --- /dev/null +++ b/payment/config/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for config project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") + +application = get_wsgi_application() diff --git a/payment/db.sqlite3 b/payment/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..ebf68870804870e6afeb169ec6ea61b49e9775ea GIT binary patch literal 131072 zcmeI5TWlNIdB-{8kQ617M^}#;TNXvHcFoGNIJ}D9rd_R9vDNj;yS{W|puu!Vj$}H# z$RyoxWo<`w@||TvE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$$M;7FIQ}l$xOOOBp1@sx3^>kl3Z}ZV#Efu{diB6SDjjsY+@QJ-5f*R15Tk|l<(`FgJJzoi>$K=xYiX^=y9Qs= zNN%TdStH$9e6j5!W{WzX1h8`t^x{~pu&w!ca2=LrqMM5WJ-GubT#qSHX(~T^5)rq zl1fSYdFLtBS#p4e`QD}v*YcFdFP6)DN8R^%QZgVc2{hRnQYo9 z=vlYH8M9iwS1kvZ?}6Pl<5lMqHD73tx6hvmC>kvyzvb*HUEBWAoGuiNHKX8`cKQ%$ z&IaT2V$t+-utZmhSp4HZds;js^odnxPv}Z@D>^%{4|L6s)dA{-dq%Ov!I>9Wos*)u zyJ76oBC2&(O}fS_KPS~|+IB_XiA9@Ly;7m)lcIaIW_gEBN8Ph%^zzk>%dhjn;I#ko z4@MJlJ{8`jbxT95(uJ1O;H{ksC`GEwox>_)($@5R#?VWu<2ep@y?^A$)o}YfN(Ia^G-o`V zrKdcC>(c(}QMLC}UQ^S0wvbIF?TZZI+g+VGvpNH=HwM~w=g%QW`+h1)Y$KupMEp(6rx89B&?@!{J=t@}sKkN<*`5*uS zAOHd&00JNY0w4eaAOHd&@ca|N{r~gdhNuAufB*=900@8p2!H?xfB*=900OhhS2YJ<7cJ858=+82YKH#$$f}@0oZ?Rf1a( z009sH0T2KI5C8!X009sH0T2LzXMzBp|9>W$0U|&E1V8`;KmY_l00ck)1V8`;K;Wqo i!2SPI#S7;k00JNY0w4eaAOHd&00JNY0wC~A5cq$?{Pev5 literal 0 HcmV?d00001 diff --git a/payment/entrypoint.sh b/payment/entrypoint.sh new file mode 100644 index 0000000..b4bce27 --- /dev/null +++ b/payment/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +python3 manage.py collectstatus --no-input +python3 manage.py migrate --no-input +python3 manage.py runserver 0.0.0.0:8000 \ No newline at end of file diff --git a/payment/manage.py b/payment/manage.py new file mode 100755 index 0000000..d28672e --- /dev/null +++ b/payment/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == "__main__": + main() diff --git a/payment/requirements.txt b/payment/requirements.txt new file mode 100644 index 0000000..ddd6f0f --- /dev/null +++ b/payment/requirements.txt @@ -0,0 +1,2 @@ +django==5.1.3 +djangorestframework==3.15.2 \ No newline at end of file From 098dce9fdbcff96ed628ecc8739ced4e0fe987bc Mon Sep 17 00:00:00 2001 From: A'zamov Samandar Date: Sat, 19 Apr 2025 17:45:12 +0500 Subject: [PATCH 3/5] `dockerfile, api: Yangi loyiha uchun Dockerfile va Django API modullarini qo'shish. Kiritilgan fayllar: requirements.txt, admin.py, models.py, tests.py va boshqalar.` --- template/Dockerfile | 13 +++ template/api/__init__.py | 0 template/api/admin.py | 3 + template/api/apps.py | 6 ++ template/api/migrations/__init__.py | 0 template/api/models.py | 3 + template/api/tests.py | 3 + template/api/urls.py | 6 ++ template/api/views.py | 7 ++ template/config/__init__.py | 0 template/config/asgi.py | 16 ++++ template/config/settings.py | 126 ++++++++++++++++++++++++++++ template/config/urls.py | 7 ++ template/config/wsgi.py | 16 ++++ template/db.sqlite3 | Bin 0 -> 131072 bytes template/entrypoint.sh | 5 ++ template/manage.py | 22 +++++ template/requirements.txt | 2 + 18 files changed, 235 insertions(+) create mode 100644 template/Dockerfile create mode 100644 template/api/__init__.py create mode 100644 template/api/admin.py create mode 100644 template/api/apps.py create mode 100644 template/api/migrations/__init__.py create mode 100644 template/api/models.py create mode 100644 template/api/tests.py create mode 100644 template/api/urls.py create mode 100644 template/api/views.py create mode 100644 template/config/__init__.py create mode 100644 template/config/asgi.py create mode 100644 template/config/settings.py create mode 100644 template/config/urls.py create mode 100644 template/config/wsgi.py create mode 100644 template/db.sqlite3 create mode 100644 template/entrypoint.sh create mode 100755 template/manage.py create mode 100644 template/requirements.txt diff --git a/template/Dockerfile b/template/Dockerfile new file mode 100644 index 0000000..7d6e714 --- /dev/null +++ b/template/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.13-alpine + +ENV PYTHONPYCACHEPREFIX=/dev/null + +RUN apk update && apk add git gettext + +WORKDIR /code + +COPY requirements.txt /code/requirements.txt + +RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt + +CMD ["sh", "./entrypoint.sh"] \ No newline at end of file diff --git a/template/api/__init__.py b/template/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/template/api/admin.py b/template/api/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/template/api/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/template/api/apps.py b/template/api/apps.py new file mode 100644 index 0000000..878e7d5 --- /dev/null +++ b/template/api/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ApiConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "api" diff --git a/template/api/migrations/__init__.py b/template/api/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/template/api/models.py b/template/api/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/template/api/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/template/api/tests.py b/template/api/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/template/api/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/template/api/urls.py b/template/api/urls.py new file mode 100644 index 0000000..108460e --- /dev/null +++ b/template/api/urls.py @@ -0,0 +1,6 @@ +from django.urls import path +from .views import HealthView + +urlpatterns = [ + path("health/", HealthView.as_view()) +] \ No newline at end of file diff --git a/template/api/views.py b/template/api/views.py new file mode 100644 index 0000000..3877edb --- /dev/null +++ b/template/api/views.py @@ -0,0 +1,7 @@ +from rest_framework.views import APIView +from rest_framework.response import Response + + +class HealthView(APIView): + def get(self, *args, **kwargs): + return Response(data={"detail": "OK"}) \ No newline at end of file diff --git a/template/config/__init__.py b/template/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/template/config/asgi.py b/template/config/asgi.py new file mode 100644 index 0000000..19b90e3 --- /dev/null +++ b/template/config/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for config project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") + +application = get_asgi_application() diff --git a/template/config/settings.py b/template/config/settings.py new file mode 100644 index 0000000..bb269d2 --- /dev/null +++ b/template/config/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for config project. + +Generated by 'django-admin startproject' using Django 5.1.3. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.1/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = "django-insecure-iv-iwjd(4d%g5&fyo*+xybkjhaik+r@3j0$h91u0^$u4fwuh53" + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [ + "*" +] + + +# Application definition + +INSTALLED_APPS = [ + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "api", +] + +MIDDLEWARE = [ + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", +] + +ROOT_URLCONF = "config.urls" + +TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", + ], + }, + }, +] + +WSGI_APPLICATION = "config.wsgi.application" + + +# Database +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", + } +} + + +# Password validation +# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/5.1/topics/i18n/ + +LANGUAGE_CODE = "en-us" + +TIME_ZONE = "UTC" + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/5.1/howto/static-files/ + +STATIC_URL = "static/" + +# Default primary key field type +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/template/config/urls.py b/template/config/urls.py new file mode 100644 index 0000000..de9a619 --- /dev/null +++ b/template/config/urls.py @@ -0,0 +1,7 @@ +from django.contrib import admin +from django.urls import path, include + +urlpatterns = [ + path("payment/api/", include("api.urls")), + path("payment/admin/", admin.site.urls), +] diff --git a/template/config/wsgi.py b/template/config/wsgi.py new file mode 100644 index 0000000..b2bb19f --- /dev/null +++ b/template/config/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for config project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") + +application = get_wsgi_application() diff --git a/template/db.sqlite3 b/template/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..ebf68870804870e6afeb169ec6ea61b49e9775ea GIT binary patch literal 131072 zcmeI5TWlNIdB-{8kQ617M^}#;TNXvHcFoGNIJ}D9rd_R9vDNj;yS{W|puu!Vj$}H# z$RyoxWo<`w@||TvE*?*T>1(rsXWF zHH`av<%XdZ>$R3qYqcKl8cmH_J~_}uHl0o9UL7MBuUjrM&Uy(zmHJM(rq%W;19}a~ z$f|2=Yp(>!ht<}Jw9`kIO?|gDxFVUvnwq*iN*=7XPNbY3jH+I)4DE6xBb`a+6ITP| z#Ok~WtMl4@?eJbho>J*dI(60W^DJFicVgreiEp+3po>@Ie1+42c#~;W&2RdA9)&cO zs^uEFNNL2ATBh+>w6k7p(b&|sEBcOByjw394`}Q}K9R|-%jAkEo34_!D^nJY+B$bT zP)#Damdzx*kv1j+oqBIOts*6+1<=Ei~p`=p=bGhYmCCI+Wt|rlit6y|z=gLQf(#;-4Pzu8f)) zB5uKB7PFFf)v~UZcN#j6fi$Pa$f=)w%ESJheU1Gc`x5&NO5g(mAOHd&00JNY0w4ea zAOHd&00JQJv2%gzhqPldRf6?)!EavJJqo(-la9q9=pyS%Pu-gcITG;{F#1- zGfG+(%QIxLlJf~wjytNZGIL*)KWn}^O~&fWK2x5{+?3c;fZhS&1x%f;0;X1HfjGVY zAuVToT(HZUi*}lxp%*-)g_mTZoZt3!CG$j-Uf!UZ%cfK--_$59=*EYZTIA+$)YQZZo@w7pWM%89}Y>HILu5Fa>mM=+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hS2YJ<7cJ858=+82YKH#$$f}@0oZ?Rf1a( z009sH0T2KI5C8!X009sH0T2LzXMzBp|9>W$0U|&E1V8`;KmY_l00ck)1V8`;K;Wqo i!2SPI#S7;k00JNY0w4eaAOHd&00JNY0wC~A5cq$?{Pev5 literal 0 HcmV?d00001 diff --git a/template/entrypoint.sh b/template/entrypoint.sh new file mode 100644 index 0000000..b4bce27 --- /dev/null +++ b/template/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +python3 manage.py collectstatus --no-input +python3 manage.py migrate --no-input +python3 manage.py runserver 0.0.0.0:8000 \ No newline at end of file diff --git a/template/manage.py b/template/manage.py new file mode 100755 index 0000000..d28672e --- /dev/null +++ b/template/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == "__main__": + main() diff --git a/template/requirements.txt b/template/requirements.txt new file mode 100644 index 0000000..ddd6f0f --- /dev/null +++ b/template/requirements.txt @@ -0,0 +1,2 @@ +django==5.1.3 +djangorestframework==3.15.2 \ No newline at end of file From bc24faeedde455749a8d02fb7700a085b52a80b5 Mon Sep 17 00:00:00 2001 From: A'zamov Samandar Date: Sat, 19 Apr 2025 19:24:18 +0500 Subject: [PATCH 4/5] AUTH_CMD to USER_CMD, updated workflows, Makefile, and docker-compose for user service --- .env.example | 2 +- .github/workflows/deploy.yml | 6 +-- Makefile | 12 +++--- docker-compose.yml | 38 +++++++++--------- {auth => user}/.cruft.json | 0 {auth => user}/.dockerignore | 0 {auth => user}/.env.example | 0 {auth => user}/.flake8 | 0 {auth => user}/.gitignore | 0 {auth => user}/README.MD | 0 {auth => user}/config/__init__.py | 0 {auth => user}/config/asgi.py | 0 {auth => user}/config/celery.py | 0 {auth => user}/config/conf/__init__.py | 0 {auth => user}/config/conf/apps.py | 0 {auth => user}/config/conf/cache.py | 0 {auth => user}/config/conf/celery.py | 0 {auth => user}/config/conf/channels.py | 0 {auth => user}/config/conf/ckeditor.py | 0 {auth => user}/config/conf/cron.py | 0 {auth => user}/config/conf/jwt.py | 0 {auth => user}/config/conf/logs.py | 0 {auth => user}/config/conf/modules.py | 0 {auth => user}/config/conf/navigation.py | 0 {auth => user}/config/conf/rest_framework.py | 0 {auth => user}/config/conf/spectacular.py | 0 {auth => user}/config/conf/storage.py | 0 {auth => user}/config/conf/unfold.py | 0 {auth => user}/config/env.py | 0 {auth => user}/config/settings/__init__.py | 0 {auth => user}/config/settings/common.py | 0 {auth => user}/config/settings/local.py | 0 {auth => user}/config/settings/production.py | 0 {auth => user}/config/urls.py | 0 {auth => user}/config/wsgi.py | 0 {auth => user}/core/__init__.py | 0 {auth => user}/core/apps/__init__.py | 0 {auth => user}/core/apps/accounts/__init__.py | 0 .../core/apps/accounts/admin/__init__.py | 0 .../core/apps/accounts/admin/core.py | 0 .../core/apps/accounts/admin/user.py | 0 {auth => user}/core/apps/accounts/apps.py | 0 .../core/apps/accounts/choices/__init__.py | 0 .../core/apps/accounts/choices/user.py | 0 .../core/apps/accounts/managers/__init__.py | 0 .../core/apps/accounts/managers/user.py | 0 .../apps/accounts/migrations/0001_initial.py | 0 .../core/apps/accounts/migrations/__init__.py | 0 .../core/apps/accounts/models/__init__.py | 0 .../core/apps/accounts/models/reset_token.py | 0 .../core/apps/accounts/models/user.py | 0 .../core/apps/accounts/seeder/__init__.py | 0 .../core/apps/accounts/seeder/core.py | 0 .../apps/accounts/serializers/__init__.py | 0 .../core/apps/accounts/serializers/auth.py | 0 .../accounts/serializers/change_password.py | 0 .../apps/accounts/serializers/set_password.py | 0 .../core/apps/accounts/serializers/user.py | 0 .../core/apps/accounts/signals/__init__.py | 0 .../core/apps/accounts/signals/user.py | 0 .../core/apps/accounts/test/__init__.py | 0 .../core/apps/accounts/test/test_auth.py | 0 .../accounts/test/test_change_password.py | 0 {auth => user}/core/apps/accounts/urls.py | 0 .../core/apps/accounts/views/__init__.py | 0 .../core/apps/accounts/views/auth.py | 0 {auth => user}/core/apps/logs/.gitignore | 0 {auth => user}/core/services/__init__.py | 0 {auth => user}/core/services/otp.py | 0 {auth => user}/core/services/sms.py | 0 {auth => user}/core/services/user.py | 0 {auth => user}/core/utils/__init__.py | 0 {auth => user}/core/utils/cache.py | 0 {auth => user}/core/utils/console.py | 0 {auth => user}/core/utils/core.py | 0 {auth => user}/core/utils/storage.py | 0 {auth => user}/docker-compose.yml | 0 {auth => user}/docker/Dockerfile.nginx | 0 {auth => user}/docker/Dockerfile.web | 0 {auth => user}/jst.json | 0 {auth => user}/manage.py | 0 {auth => user}/pyproject.toml | 0 {auth => user}/requirements.txt | 0 {auth => user}/resources/.gitignore | 0 {auth => user}/resources/layout/.flake8 | 0 .../resources/layout/Dockerfile.alpine | 0 .../resources/layout/Dockerfile.nginx | 0 {auth => user}/resources/layout/mypy.ini | 0 {auth => user}/resources/layout/nginx.conf | 4 +- {auth => user}/resources/locale/.gitkeep | 0 .../resources/locale/en/LC_MESSAGES/django.po | 0 .../resources/locale/ru/LC_MESSAGES/django.po | 0 .../resources/locale/uz/LC_MESSAGES/django.po | 0 {auth => user}/resources/logs/.gitignore | 0 {auth => user}/resources/media/.gitignore | 0 {auth => user}/resources/scripts/backup.sh | 0 .../resources/scripts/entrypoint-server.sh | 0 .../resources/scripts/entrypoint.sh | 0 {auth => user}/resources/static/css/app.css | 0 {auth => user}/resources/static/css/error.css | 0 {auth => user}/resources/static/css/input.css | 0 .../resources/static/css/jazzmin.css | 0 .../resources/static/css/output.css | 0 .../resources/static/images/logo.png | Bin {auth => user}/resources/static/js/alpine.js | 0 {auth => user}/resources/static/js/app.js | 0 {auth => user}/resources/static/js/counter.js | 0 .../resources/static/js/customer.js | 0 .../resources/static/js/vite-refresh.js | 0 .../static/vite/assets/appCss-w40geAFS.js | 0 .../static/vite/assets/appJs-YH6iAcjX.js | 0 .../static/vite/assets/outCss-r8J2MRAR.css | 0 .../resources/static/vite/manifest.json | 0 {auth => user}/resources/templates/400.html | 0 {auth => user}/resources/templates/401.html | 0 {auth => user}/resources/templates/403.html | 0 {auth => user}/resources/templates/404.html | 0 {auth => user}/resources/templates/405.html | 0 {auth => user}/resources/templates/408.html | 0 {auth => user}/resources/templates/500.html | 0 {auth => user}/resources/templates/502.html | 0 {auth => user}/resources/templates/503.html | 0 {auth => user}/resources/templates/504.html | 0 .../resources/templates/admin/index.html | 0 .../templates/registration/login.html | 0 .../resources/templates/user/home.html | 0 126 files changed, 30 insertions(+), 32 deletions(-) rename {auth => user}/.cruft.json (100%) rename {auth => user}/.dockerignore (100%) rename {auth => user}/.env.example (100%) rename {auth => user}/.flake8 (100%) rename {auth => user}/.gitignore (100%) rename {auth => user}/README.MD (100%) rename {auth => user}/config/__init__.py (100%) rename {auth => user}/config/asgi.py (100%) rename {auth => user}/config/celery.py (100%) rename {auth => user}/config/conf/__init__.py (100%) rename {auth => user}/config/conf/apps.py (100%) rename {auth => user}/config/conf/cache.py (100%) rename {auth => user}/config/conf/celery.py (100%) rename {auth => user}/config/conf/channels.py (100%) rename {auth => user}/config/conf/ckeditor.py (100%) rename {auth => user}/config/conf/cron.py (100%) rename {auth => user}/config/conf/jwt.py (100%) rename {auth => user}/config/conf/logs.py (100%) rename {auth => user}/config/conf/modules.py (100%) rename {auth => user}/config/conf/navigation.py (100%) rename {auth => user}/config/conf/rest_framework.py (100%) rename {auth => user}/config/conf/spectacular.py (100%) rename {auth => user}/config/conf/storage.py (100%) rename {auth => user}/config/conf/unfold.py (100%) rename {auth => user}/config/env.py (100%) rename {auth => user}/config/settings/__init__.py (100%) rename {auth => user}/config/settings/common.py (100%) rename {auth => user}/config/settings/local.py (100%) rename {auth => user}/config/settings/production.py (100%) rename {auth => user}/config/urls.py (100%) rename {auth => user}/config/wsgi.py (100%) rename {auth => user}/core/__init__.py (100%) rename {auth => user}/core/apps/__init__.py (100%) rename {auth => user}/core/apps/accounts/__init__.py (100%) rename {auth => user}/core/apps/accounts/admin/__init__.py (100%) rename {auth => user}/core/apps/accounts/admin/core.py (100%) rename {auth => user}/core/apps/accounts/admin/user.py (100%) rename {auth => user}/core/apps/accounts/apps.py (100%) rename {auth => user}/core/apps/accounts/choices/__init__.py (100%) rename {auth => user}/core/apps/accounts/choices/user.py (100%) rename {auth => user}/core/apps/accounts/managers/__init__.py (100%) rename {auth => user}/core/apps/accounts/managers/user.py (100%) rename {auth => user}/core/apps/accounts/migrations/0001_initial.py (100%) rename {auth => user}/core/apps/accounts/migrations/__init__.py (100%) rename {auth => user}/core/apps/accounts/models/__init__.py (100%) rename {auth => user}/core/apps/accounts/models/reset_token.py (100%) rename {auth => user}/core/apps/accounts/models/user.py (100%) rename {auth => user}/core/apps/accounts/seeder/__init__.py (100%) rename {auth => user}/core/apps/accounts/seeder/core.py (100%) rename {auth => user}/core/apps/accounts/serializers/__init__.py (100%) rename {auth => user}/core/apps/accounts/serializers/auth.py (100%) rename {auth => user}/core/apps/accounts/serializers/change_password.py (100%) rename {auth => user}/core/apps/accounts/serializers/set_password.py (100%) rename {auth => user}/core/apps/accounts/serializers/user.py (100%) rename {auth => user}/core/apps/accounts/signals/__init__.py (100%) rename {auth => user}/core/apps/accounts/signals/user.py (100%) rename {auth => user}/core/apps/accounts/test/__init__.py (100%) rename {auth => user}/core/apps/accounts/test/test_auth.py (100%) rename {auth => user}/core/apps/accounts/test/test_change_password.py (100%) rename {auth => user}/core/apps/accounts/urls.py (100%) rename {auth => user}/core/apps/accounts/views/__init__.py (100%) rename {auth => user}/core/apps/accounts/views/auth.py (100%) rename {auth => user}/core/apps/logs/.gitignore (100%) rename {auth => user}/core/services/__init__.py (100%) rename {auth => user}/core/services/otp.py (100%) rename {auth => user}/core/services/sms.py (100%) rename {auth => user}/core/services/user.py (100%) rename {auth => user}/core/utils/__init__.py (100%) rename {auth => user}/core/utils/cache.py (100%) rename {auth => user}/core/utils/console.py (100%) rename {auth => user}/core/utils/core.py (100%) rename {auth => user}/core/utils/storage.py (100%) rename {auth => user}/docker-compose.yml (100%) rename {auth => user}/docker/Dockerfile.nginx (100%) rename {auth => user}/docker/Dockerfile.web (100%) rename {auth => user}/jst.json (100%) rename {auth => user}/manage.py (100%) rename {auth => user}/pyproject.toml (100%) rename {auth => user}/requirements.txt (100%) rename {auth => user}/resources/.gitignore (100%) rename {auth => user}/resources/layout/.flake8 (100%) rename {auth => user}/resources/layout/Dockerfile.alpine (100%) rename {auth => user}/resources/layout/Dockerfile.nginx (100%) rename {auth => user}/resources/layout/mypy.ini (100%) rename {auth => user}/resources/layout/nginx.conf (93%) rename {auth => user}/resources/locale/.gitkeep (100%) rename {auth => user}/resources/locale/en/LC_MESSAGES/django.po (100%) rename {auth => user}/resources/locale/ru/LC_MESSAGES/django.po (100%) rename {auth => user}/resources/locale/uz/LC_MESSAGES/django.po (100%) rename {auth => user}/resources/logs/.gitignore (100%) rename {auth => user}/resources/media/.gitignore (100%) rename {auth => user}/resources/scripts/backup.sh (100%) rename {auth => user}/resources/scripts/entrypoint-server.sh (100%) rename {auth => user}/resources/scripts/entrypoint.sh (100%) rename {auth => user}/resources/static/css/app.css (100%) rename {auth => user}/resources/static/css/error.css (100%) rename {auth => user}/resources/static/css/input.css (100%) rename {auth => user}/resources/static/css/jazzmin.css (100%) rename {auth => user}/resources/static/css/output.css (100%) rename {auth => user}/resources/static/images/logo.png (100%) rename {auth => user}/resources/static/js/alpine.js (100%) rename {auth => user}/resources/static/js/app.js (100%) rename {auth => user}/resources/static/js/counter.js (100%) rename {auth => user}/resources/static/js/customer.js (100%) rename {auth => user}/resources/static/js/vite-refresh.js (100%) rename {auth => user}/resources/static/vite/assets/appCss-w40geAFS.js (100%) rename {auth => user}/resources/static/vite/assets/appJs-YH6iAcjX.js (100%) rename {auth => user}/resources/static/vite/assets/outCss-r8J2MRAR.css (100%) rename {auth => user}/resources/static/vite/manifest.json (100%) rename {auth => user}/resources/templates/400.html (100%) rename {auth => user}/resources/templates/401.html (100%) rename {auth => user}/resources/templates/403.html (100%) rename {auth => user}/resources/templates/404.html (100%) rename {auth => user}/resources/templates/405.html (100%) rename {auth => user}/resources/templates/408.html (100%) rename {auth => user}/resources/templates/500.html (100%) rename {auth => user}/resources/templates/502.html (100%) rename {auth => user}/resources/templates/503.html (100%) rename {auth => user}/resources/templates/504.html (100%) rename {auth => user}/resources/templates/admin/index.html (100%) rename {auth => user}/resources/templates/registration/login.html (100%) rename {auth => user}/resources/templates/user/home.html (100%) diff --git a/.env.example b/.env.example index 5122bf2..5b9f93e 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,2 @@ -AUTH_COMMAND=sh ./resources/scripts/entrypoint.sh +USER_COMMAND=sh ./resources/scripts/entrypoint.sh JWT_KEY=key \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0dae23b..e563394 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -16,10 +16,10 @@ jobs: - name: 📥 Secret orqali .env fayl yaratish run: | echo "${{ secrets.BASE_ENV_FILE }}" > .env - echo "${{ secrets.AUTH_ENV_FILE }}" > ./auth/.env + echo "${{ secrets.USER_ENV_FILE }}" > ./user/.env - name: 🛠 Docker Compose bilan build & deploy run: | - docker compose --profile auth --profile payment build + docker compose --profile user --profile payment build docker compose down - docker compose --profile auth --profile payment up -d \ No newline at end of file + docker compose --profile user --profile payment up -d \ No newline at end of file diff --git a/Makefile b/Makefile index 5660e6b..e43734d 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,10 @@ -up-auth: - docker compose --profile auth up -d - -down-auth: - docker compose --profile auth down +up-user: + docker compose --profile user up -d +down-user: + docker compose --profile user down up-payment: docker compose --profile payment up -d down-payment: docker compose --profile payment down - down-all: - docker compose --profile payment --profile auth down \ No newline at end of file + docker compose --profile payment --profile user down \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 72e42f2..02e2e42 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,46 +21,46 @@ services: - "/var/run/docker.sock:/var/run/docker.sock:ro" networks: - lamenu - auth-nginx: + user-nginx: labels: - "traefik.enable=true" - - "traefik.http.routers.auth.rule=PathPrefix(`/auth`)" - - "traefik.http.routers.auth.entrypoints=web" - - "traefik.http.services.auth.loadbalancer.server.port=80" - - "traefik.http.middlewares.auth-strip-prefix.stripPrefix.prefixes=/auth" - - "traefik.http.routers.auth.middlewares=auth-strip-prefix" + - "traefik.http.routers.user.rule=PathPrefix(`/user`)" + - "traefik.http.routers.user.entrypoints=web" + - "traefik.http.services.user.loadbalancer.server.port=80" + - "traefik.http.middlewares.user-strip-prefix.stripPrefix.prefixes=/user" + - "traefik.http.routers.user.middlewares=user-strip-prefix" networks: - lamenu volumes: - - ./auth/resources/layout/nginx.conf:/etc/nginx/nginx.conf - - ./auth/resources/:/usr/share/nginx/html/resources/ + - ./user/resources/layout/nginx.conf:/etc/nginx/nginx.conf + - ./user/resources/:/usr/share/nginx/html/resources/ build: - context: ./auth + context: ./user dockerfile: ./docker/Dockerfile.nginx depends_on: - - auth + - user profiles: - - auth - auth: + - user + user: networks: - lamenu build: - context: ./auth + context: ./user dockerfile: ./docker/Dockerfile.web restart: always - command: ${AUTH_COMMAND:-sh ./resources/scripts/entrypoint.sh} + command: ${user_COMMAND:-sh ./resources/scripts/entrypoint.sh} environment: - PYTHONPYCACHEPREFIX=/var/cache/pycache - JWT_KEY=${JWT_KEY} volumes: - - ./auth:/code + - ./user:/code - pycache:/var/cache/pycache depends_on: - - auth-db + - user-db - redis profiles: - - auth - auth-db: + - user + user-db: networks: - lamenu image: postgres:16 @@ -72,7 +72,7 @@ services: volumes: - pg_data:/var/lib/postgresql/data profiles: - - auth + - user payment: labels: diff --git a/auth/.cruft.json b/user/.cruft.json similarity index 100% rename from auth/.cruft.json rename to user/.cruft.json diff --git a/auth/.dockerignore b/user/.dockerignore similarity index 100% rename from auth/.dockerignore rename to user/.dockerignore diff --git a/auth/.env.example b/user/.env.example similarity index 100% rename from auth/.env.example rename to user/.env.example diff --git a/auth/.flake8 b/user/.flake8 similarity index 100% rename from auth/.flake8 rename to user/.flake8 diff --git a/auth/.gitignore b/user/.gitignore similarity index 100% rename from auth/.gitignore rename to user/.gitignore diff --git a/auth/README.MD b/user/README.MD similarity index 100% rename from auth/README.MD rename to user/README.MD diff --git a/auth/config/__init__.py b/user/config/__init__.py similarity index 100% rename from auth/config/__init__.py rename to user/config/__init__.py diff --git a/auth/config/asgi.py b/user/config/asgi.py similarity index 100% rename from auth/config/asgi.py rename to user/config/asgi.py diff --git a/auth/config/celery.py b/user/config/celery.py similarity index 100% rename from auth/config/celery.py rename to user/config/celery.py diff --git a/auth/config/conf/__init__.py b/user/config/conf/__init__.py similarity index 100% rename from auth/config/conf/__init__.py rename to user/config/conf/__init__.py diff --git a/auth/config/conf/apps.py b/user/config/conf/apps.py similarity index 100% rename from auth/config/conf/apps.py rename to user/config/conf/apps.py diff --git a/auth/config/conf/cache.py b/user/config/conf/cache.py similarity index 100% rename from auth/config/conf/cache.py rename to user/config/conf/cache.py diff --git a/auth/config/conf/celery.py b/user/config/conf/celery.py similarity index 100% rename from auth/config/conf/celery.py rename to user/config/conf/celery.py diff --git a/auth/config/conf/channels.py b/user/config/conf/channels.py similarity index 100% rename from auth/config/conf/channels.py rename to user/config/conf/channels.py diff --git a/auth/config/conf/ckeditor.py b/user/config/conf/ckeditor.py similarity index 100% rename from auth/config/conf/ckeditor.py rename to user/config/conf/ckeditor.py diff --git a/auth/config/conf/cron.py b/user/config/conf/cron.py similarity index 100% rename from auth/config/conf/cron.py rename to user/config/conf/cron.py diff --git a/auth/config/conf/jwt.py b/user/config/conf/jwt.py similarity index 100% rename from auth/config/conf/jwt.py rename to user/config/conf/jwt.py diff --git a/auth/config/conf/logs.py b/user/config/conf/logs.py similarity index 100% rename from auth/config/conf/logs.py rename to user/config/conf/logs.py diff --git a/auth/config/conf/modules.py b/user/config/conf/modules.py similarity index 100% rename from auth/config/conf/modules.py rename to user/config/conf/modules.py diff --git a/auth/config/conf/navigation.py b/user/config/conf/navigation.py similarity index 100% rename from auth/config/conf/navigation.py rename to user/config/conf/navigation.py diff --git a/auth/config/conf/rest_framework.py b/user/config/conf/rest_framework.py similarity index 100% rename from auth/config/conf/rest_framework.py rename to user/config/conf/rest_framework.py diff --git a/auth/config/conf/spectacular.py b/user/config/conf/spectacular.py similarity index 100% rename from auth/config/conf/spectacular.py rename to user/config/conf/spectacular.py diff --git a/auth/config/conf/storage.py b/user/config/conf/storage.py similarity index 100% rename from auth/config/conf/storage.py rename to user/config/conf/storage.py diff --git a/auth/config/conf/unfold.py b/user/config/conf/unfold.py similarity index 100% rename from auth/config/conf/unfold.py rename to user/config/conf/unfold.py diff --git a/auth/config/env.py b/user/config/env.py similarity index 100% rename from auth/config/env.py rename to user/config/env.py diff --git a/auth/config/settings/__init__.py b/user/config/settings/__init__.py similarity index 100% rename from auth/config/settings/__init__.py rename to user/config/settings/__init__.py diff --git a/auth/config/settings/common.py b/user/config/settings/common.py similarity index 100% rename from auth/config/settings/common.py rename to user/config/settings/common.py diff --git a/auth/config/settings/local.py b/user/config/settings/local.py similarity index 100% rename from auth/config/settings/local.py rename to user/config/settings/local.py diff --git a/auth/config/settings/production.py b/user/config/settings/production.py similarity index 100% rename from auth/config/settings/production.py rename to user/config/settings/production.py diff --git a/auth/config/urls.py b/user/config/urls.py similarity index 100% rename from auth/config/urls.py rename to user/config/urls.py diff --git a/auth/config/wsgi.py b/user/config/wsgi.py similarity index 100% rename from auth/config/wsgi.py rename to user/config/wsgi.py diff --git a/auth/core/__init__.py b/user/core/__init__.py similarity index 100% rename from auth/core/__init__.py rename to user/core/__init__.py diff --git a/auth/core/apps/__init__.py b/user/core/apps/__init__.py similarity index 100% rename from auth/core/apps/__init__.py rename to user/core/apps/__init__.py diff --git a/auth/core/apps/accounts/__init__.py b/user/core/apps/accounts/__init__.py similarity index 100% rename from auth/core/apps/accounts/__init__.py rename to user/core/apps/accounts/__init__.py diff --git a/auth/core/apps/accounts/admin/__init__.py b/user/core/apps/accounts/admin/__init__.py similarity index 100% rename from auth/core/apps/accounts/admin/__init__.py rename to user/core/apps/accounts/admin/__init__.py diff --git a/auth/core/apps/accounts/admin/core.py b/user/core/apps/accounts/admin/core.py similarity index 100% rename from auth/core/apps/accounts/admin/core.py rename to user/core/apps/accounts/admin/core.py diff --git a/auth/core/apps/accounts/admin/user.py b/user/core/apps/accounts/admin/user.py similarity index 100% rename from auth/core/apps/accounts/admin/user.py rename to user/core/apps/accounts/admin/user.py diff --git a/auth/core/apps/accounts/apps.py b/user/core/apps/accounts/apps.py similarity index 100% rename from auth/core/apps/accounts/apps.py rename to user/core/apps/accounts/apps.py diff --git a/auth/core/apps/accounts/choices/__init__.py b/user/core/apps/accounts/choices/__init__.py similarity index 100% rename from auth/core/apps/accounts/choices/__init__.py rename to user/core/apps/accounts/choices/__init__.py diff --git a/auth/core/apps/accounts/choices/user.py b/user/core/apps/accounts/choices/user.py similarity index 100% rename from auth/core/apps/accounts/choices/user.py rename to user/core/apps/accounts/choices/user.py diff --git a/auth/core/apps/accounts/managers/__init__.py b/user/core/apps/accounts/managers/__init__.py similarity index 100% rename from auth/core/apps/accounts/managers/__init__.py rename to user/core/apps/accounts/managers/__init__.py diff --git a/auth/core/apps/accounts/managers/user.py b/user/core/apps/accounts/managers/user.py similarity index 100% rename from auth/core/apps/accounts/managers/user.py rename to user/core/apps/accounts/managers/user.py diff --git a/auth/core/apps/accounts/migrations/0001_initial.py b/user/core/apps/accounts/migrations/0001_initial.py similarity index 100% rename from auth/core/apps/accounts/migrations/0001_initial.py rename to user/core/apps/accounts/migrations/0001_initial.py diff --git a/auth/core/apps/accounts/migrations/__init__.py b/user/core/apps/accounts/migrations/__init__.py similarity index 100% rename from auth/core/apps/accounts/migrations/__init__.py rename to user/core/apps/accounts/migrations/__init__.py diff --git a/auth/core/apps/accounts/models/__init__.py b/user/core/apps/accounts/models/__init__.py similarity index 100% rename from auth/core/apps/accounts/models/__init__.py rename to user/core/apps/accounts/models/__init__.py diff --git a/auth/core/apps/accounts/models/reset_token.py b/user/core/apps/accounts/models/reset_token.py similarity index 100% rename from auth/core/apps/accounts/models/reset_token.py rename to user/core/apps/accounts/models/reset_token.py diff --git a/auth/core/apps/accounts/models/user.py b/user/core/apps/accounts/models/user.py similarity index 100% rename from auth/core/apps/accounts/models/user.py rename to user/core/apps/accounts/models/user.py diff --git a/auth/core/apps/accounts/seeder/__init__.py b/user/core/apps/accounts/seeder/__init__.py similarity index 100% rename from auth/core/apps/accounts/seeder/__init__.py rename to user/core/apps/accounts/seeder/__init__.py diff --git a/auth/core/apps/accounts/seeder/core.py b/user/core/apps/accounts/seeder/core.py similarity index 100% rename from auth/core/apps/accounts/seeder/core.py rename to user/core/apps/accounts/seeder/core.py diff --git a/auth/core/apps/accounts/serializers/__init__.py b/user/core/apps/accounts/serializers/__init__.py similarity index 100% rename from auth/core/apps/accounts/serializers/__init__.py rename to user/core/apps/accounts/serializers/__init__.py diff --git a/auth/core/apps/accounts/serializers/auth.py b/user/core/apps/accounts/serializers/auth.py similarity index 100% rename from auth/core/apps/accounts/serializers/auth.py rename to user/core/apps/accounts/serializers/auth.py diff --git a/auth/core/apps/accounts/serializers/change_password.py b/user/core/apps/accounts/serializers/change_password.py similarity index 100% rename from auth/core/apps/accounts/serializers/change_password.py rename to user/core/apps/accounts/serializers/change_password.py diff --git a/auth/core/apps/accounts/serializers/set_password.py b/user/core/apps/accounts/serializers/set_password.py similarity index 100% rename from auth/core/apps/accounts/serializers/set_password.py rename to user/core/apps/accounts/serializers/set_password.py diff --git a/auth/core/apps/accounts/serializers/user.py b/user/core/apps/accounts/serializers/user.py similarity index 100% rename from auth/core/apps/accounts/serializers/user.py rename to user/core/apps/accounts/serializers/user.py diff --git a/auth/core/apps/accounts/signals/__init__.py b/user/core/apps/accounts/signals/__init__.py similarity index 100% rename from auth/core/apps/accounts/signals/__init__.py rename to user/core/apps/accounts/signals/__init__.py diff --git a/auth/core/apps/accounts/signals/user.py b/user/core/apps/accounts/signals/user.py similarity index 100% rename from auth/core/apps/accounts/signals/user.py rename to user/core/apps/accounts/signals/user.py diff --git a/auth/core/apps/accounts/test/__init__.py b/user/core/apps/accounts/test/__init__.py similarity index 100% rename from auth/core/apps/accounts/test/__init__.py rename to user/core/apps/accounts/test/__init__.py diff --git a/auth/core/apps/accounts/test/test_auth.py b/user/core/apps/accounts/test/test_auth.py similarity index 100% rename from auth/core/apps/accounts/test/test_auth.py rename to user/core/apps/accounts/test/test_auth.py diff --git a/auth/core/apps/accounts/test/test_change_password.py b/user/core/apps/accounts/test/test_change_password.py similarity index 100% rename from auth/core/apps/accounts/test/test_change_password.py rename to user/core/apps/accounts/test/test_change_password.py diff --git a/auth/core/apps/accounts/urls.py b/user/core/apps/accounts/urls.py similarity index 100% rename from auth/core/apps/accounts/urls.py rename to user/core/apps/accounts/urls.py diff --git a/auth/core/apps/accounts/views/__init__.py b/user/core/apps/accounts/views/__init__.py similarity index 100% rename from auth/core/apps/accounts/views/__init__.py rename to user/core/apps/accounts/views/__init__.py diff --git a/auth/core/apps/accounts/views/auth.py b/user/core/apps/accounts/views/auth.py similarity index 100% rename from auth/core/apps/accounts/views/auth.py rename to user/core/apps/accounts/views/auth.py diff --git a/auth/core/apps/logs/.gitignore b/user/core/apps/logs/.gitignore similarity index 100% rename from auth/core/apps/logs/.gitignore rename to user/core/apps/logs/.gitignore diff --git a/auth/core/services/__init__.py b/user/core/services/__init__.py similarity index 100% rename from auth/core/services/__init__.py rename to user/core/services/__init__.py diff --git a/auth/core/services/otp.py b/user/core/services/otp.py similarity index 100% rename from auth/core/services/otp.py rename to user/core/services/otp.py diff --git a/auth/core/services/sms.py b/user/core/services/sms.py similarity index 100% rename from auth/core/services/sms.py rename to user/core/services/sms.py diff --git a/auth/core/services/user.py b/user/core/services/user.py similarity index 100% rename from auth/core/services/user.py rename to user/core/services/user.py diff --git a/auth/core/utils/__init__.py b/user/core/utils/__init__.py similarity index 100% rename from auth/core/utils/__init__.py rename to user/core/utils/__init__.py diff --git a/auth/core/utils/cache.py b/user/core/utils/cache.py similarity index 100% rename from auth/core/utils/cache.py rename to user/core/utils/cache.py diff --git a/auth/core/utils/console.py b/user/core/utils/console.py similarity index 100% rename from auth/core/utils/console.py rename to user/core/utils/console.py diff --git a/auth/core/utils/core.py b/user/core/utils/core.py similarity index 100% rename from auth/core/utils/core.py rename to user/core/utils/core.py diff --git a/auth/core/utils/storage.py b/user/core/utils/storage.py similarity index 100% rename from auth/core/utils/storage.py rename to user/core/utils/storage.py diff --git a/auth/docker-compose.yml b/user/docker-compose.yml similarity index 100% rename from auth/docker-compose.yml rename to user/docker-compose.yml diff --git a/auth/docker/Dockerfile.nginx b/user/docker/Dockerfile.nginx similarity index 100% rename from auth/docker/Dockerfile.nginx rename to user/docker/Dockerfile.nginx diff --git a/auth/docker/Dockerfile.web b/user/docker/Dockerfile.web similarity index 100% rename from auth/docker/Dockerfile.web rename to user/docker/Dockerfile.web diff --git a/auth/jst.json b/user/jst.json similarity index 100% rename from auth/jst.json rename to user/jst.json diff --git a/auth/manage.py b/user/manage.py similarity index 100% rename from auth/manage.py rename to user/manage.py diff --git a/auth/pyproject.toml b/user/pyproject.toml similarity index 100% rename from auth/pyproject.toml rename to user/pyproject.toml diff --git a/auth/requirements.txt b/user/requirements.txt similarity index 100% rename from auth/requirements.txt rename to user/requirements.txt diff --git a/auth/resources/.gitignore b/user/resources/.gitignore similarity index 100% rename from auth/resources/.gitignore rename to user/resources/.gitignore diff --git a/auth/resources/layout/.flake8 b/user/resources/layout/.flake8 similarity index 100% rename from auth/resources/layout/.flake8 rename to user/resources/layout/.flake8 diff --git a/auth/resources/layout/Dockerfile.alpine b/user/resources/layout/Dockerfile.alpine similarity index 100% rename from auth/resources/layout/Dockerfile.alpine rename to user/resources/layout/Dockerfile.alpine diff --git a/auth/resources/layout/Dockerfile.nginx b/user/resources/layout/Dockerfile.nginx similarity index 100% rename from auth/resources/layout/Dockerfile.nginx rename to user/resources/layout/Dockerfile.nginx diff --git a/auth/resources/layout/mypy.ini b/user/resources/layout/mypy.ini similarity index 100% rename from auth/resources/layout/mypy.ini rename to user/resources/layout/mypy.ini diff --git a/auth/resources/layout/nginx.conf b/user/resources/layout/nginx.conf similarity index 93% rename from auth/resources/layout/nginx.conf rename to user/resources/layout/nginx.conf index 12ffb9d..8843dd4 100644 --- a/auth/resources/layout/nginx.conf +++ b/user/resources/layout/nginx.conf @@ -29,14 +29,14 @@ http { server_name _; location / { - proxy_pass http://auth:8000; + proxy_pass http://user:8000; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header Host $http_host; } location /ws/ { - proxy_pass http://auth:8000; # Uvicorn serveri ishga tushadigan port + proxy_pass http://user:8000; # Uvicorn serveri ishga tushadigan port proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; diff --git a/auth/resources/locale/.gitkeep b/user/resources/locale/.gitkeep similarity index 100% rename from auth/resources/locale/.gitkeep rename to user/resources/locale/.gitkeep diff --git a/auth/resources/locale/en/LC_MESSAGES/django.po b/user/resources/locale/en/LC_MESSAGES/django.po similarity index 100% rename from auth/resources/locale/en/LC_MESSAGES/django.po rename to user/resources/locale/en/LC_MESSAGES/django.po diff --git a/auth/resources/locale/ru/LC_MESSAGES/django.po b/user/resources/locale/ru/LC_MESSAGES/django.po similarity index 100% rename from auth/resources/locale/ru/LC_MESSAGES/django.po rename to user/resources/locale/ru/LC_MESSAGES/django.po diff --git a/auth/resources/locale/uz/LC_MESSAGES/django.po b/user/resources/locale/uz/LC_MESSAGES/django.po similarity index 100% rename from auth/resources/locale/uz/LC_MESSAGES/django.po rename to user/resources/locale/uz/LC_MESSAGES/django.po diff --git a/auth/resources/logs/.gitignore b/user/resources/logs/.gitignore similarity index 100% rename from auth/resources/logs/.gitignore rename to user/resources/logs/.gitignore diff --git a/auth/resources/media/.gitignore b/user/resources/media/.gitignore similarity index 100% rename from auth/resources/media/.gitignore rename to user/resources/media/.gitignore diff --git a/auth/resources/scripts/backup.sh b/user/resources/scripts/backup.sh similarity index 100% rename from auth/resources/scripts/backup.sh rename to user/resources/scripts/backup.sh diff --git a/auth/resources/scripts/entrypoint-server.sh b/user/resources/scripts/entrypoint-server.sh similarity index 100% rename from auth/resources/scripts/entrypoint-server.sh rename to user/resources/scripts/entrypoint-server.sh diff --git a/auth/resources/scripts/entrypoint.sh b/user/resources/scripts/entrypoint.sh similarity index 100% rename from auth/resources/scripts/entrypoint.sh rename to user/resources/scripts/entrypoint.sh diff --git a/auth/resources/static/css/app.css b/user/resources/static/css/app.css similarity index 100% rename from auth/resources/static/css/app.css rename to user/resources/static/css/app.css diff --git a/auth/resources/static/css/error.css b/user/resources/static/css/error.css similarity index 100% rename from auth/resources/static/css/error.css rename to user/resources/static/css/error.css diff --git a/auth/resources/static/css/input.css b/user/resources/static/css/input.css similarity index 100% rename from auth/resources/static/css/input.css rename to user/resources/static/css/input.css diff --git a/auth/resources/static/css/jazzmin.css b/user/resources/static/css/jazzmin.css similarity index 100% rename from auth/resources/static/css/jazzmin.css rename to user/resources/static/css/jazzmin.css diff --git a/auth/resources/static/css/output.css b/user/resources/static/css/output.css similarity index 100% rename from auth/resources/static/css/output.css rename to user/resources/static/css/output.css diff --git a/auth/resources/static/images/logo.png b/user/resources/static/images/logo.png similarity index 100% rename from auth/resources/static/images/logo.png rename to user/resources/static/images/logo.png diff --git a/auth/resources/static/js/alpine.js b/user/resources/static/js/alpine.js similarity index 100% rename from auth/resources/static/js/alpine.js rename to user/resources/static/js/alpine.js diff --git a/auth/resources/static/js/app.js b/user/resources/static/js/app.js similarity index 100% rename from auth/resources/static/js/app.js rename to user/resources/static/js/app.js diff --git a/auth/resources/static/js/counter.js b/user/resources/static/js/counter.js similarity index 100% rename from auth/resources/static/js/counter.js rename to user/resources/static/js/counter.js diff --git a/auth/resources/static/js/customer.js b/user/resources/static/js/customer.js similarity index 100% rename from auth/resources/static/js/customer.js rename to user/resources/static/js/customer.js diff --git a/auth/resources/static/js/vite-refresh.js b/user/resources/static/js/vite-refresh.js similarity index 100% rename from auth/resources/static/js/vite-refresh.js rename to user/resources/static/js/vite-refresh.js diff --git a/auth/resources/static/vite/assets/appCss-w40geAFS.js b/user/resources/static/vite/assets/appCss-w40geAFS.js similarity index 100% rename from auth/resources/static/vite/assets/appCss-w40geAFS.js rename to user/resources/static/vite/assets/appCss-w40geAFS.js diff --git a/auth/resources/static/vite/assets/appJs-YH6iAcjX.js b/user/resources/static/vite/assets/appJs-YH6iAcjX.js similarity index 100% rename from auth/resources/static/vite/assets/appJs-YH6iAcjX.js rename to user/resources/static/vite/assets/appJs-YH6iAcjX.js diff --git a/auth/resources/static/vite/assets/outCss-r8J2MRAR.css b/user/resources/static/vite/assets/outCss-r8J2MRAR.css similarity index 100% rename from auth/resources/static/vite/assets/outCss-r8J2MRAR.css rename to user/resources/static/vite/assets/outCss-r8J2MRAR.css diff --git a/auth/resources/static/vite/manifest.json b/user/resources/static/vite/manifest.json similarity index 100% rename from auth/resources/static/vite/manifest.json rename to user/resources/static/vite/manifest.json diff --git a/auth/resources/templates/400.html b/user/resources/templates/400.html similarity index 100% rename from auth/resources/templates/400.html rename to user/resources/templates/400.html diff --git a/auth/resources/templates/401.html b/user/resources/templates/401.html similarity index 100% rename from auth/resources/templates/401.html rename to user/resources/templates/401.html diff --git a/auth/resources/templates/403.html b/user/resources/templates/403.html similarity index 100% rename from auth/resources/templates/403.html rename to user/resources/templates/403.html diff --git a/auth/resources/templates/404.html b/user/resources/templates/404.html similarity index 100% rename from auth/resources/templates/404.html rename to user/resources/templates/404.html diff --git a/auth/resources/templates/405.html b/user/resources/templates/405.html similarity index 100% rename from auth/resources/templates/405.html rename to user/resources/templates/405.html diff --git a/auth/resources/templates/408.html b/user/resources/templates/408.html similarity index 100% rename from auth/resources/templates/408.html rename to user/resources/templates/408.html diff --git a/auth/resources/templates/500.html b/user/resources/templates/500.html similarity index 100% rename from auth/resources/templates/500.html rename to user/resources/templates/500.html diff --git a/auth/resources/templates/502.html b/user/resources/templates/502.html similarity index 100% rename from auth/resources/templates/502.html rename to user/resources/templates/502.html diff --git a/auth/resources/templates/503.html b/user/resources/templates/503.html similarity index 100% rename from auth/resources/templates/503.html rename to user/resources/templates/503.html diff --git a/auth/resources/templates/504.html b/user/resources/templates/504.html similarity index 100% rename from auth/resources/templates/504.html rename to user/resources/templates/504.html diff --git a/auth/resources/templates/admin/index.html b/user/resources/templates/admin/index.html similarity index 100% rename from auth/resources/templates/admin/index.html rename to user/resources/templates/admin/index.html diff --git a/auth/resources/templates/registration/login.html b/user/resources/templates/registration/login.html similarity index 100% rename from auth/resources/templates/registration/login.html rename to user/resources/templates/registration/login.html diff --git a/auth/resources/templates/user/home.html b/user/resources/templates/user/home.html similarity index 100% rename from auth/resources/templates/user/home.html rename to user/resources/templates/user/home.html From a3e8ed3e368908997880188bc66e15f5b9dbccf1 Mon Sep 17 00:00:00 2001 From: A'zamov Samandar Date: Sun, 20 Apr 2025 16:15:04 +0500 Subject: [PATCH 5/5] feat: Notification service qo'shildi va RabbitMQ integratsiya qilindi --- Makefile | 2 +- docker-compose.yml | 22 ++++ notification/Dockerfile | 19 +++ notification/README.MD | 112 ++++++++++++++++++ notification/cmd/main.go | 10 ++ notification/go.mod | 12 ++ notification/go.sum | 13 ++ notification/internal/config/config.go | 13 ++ .../internal/consumer/notification.go | 62 ++++++++++ notification/internal/domain/notification.go | 18 +++ notification/internal/notifier/email.go | 16 +++ notification/internal/notifier/sms.go | 16 +++ notification/internal/rabbitmq/connection.go | 21 ++++ test.py | 17 +++ user/docker-compose.yml | 10 +- 15 files changed, 357 insertions(+), 6 deletions(-) create mode 100644 notification/Dockerfile create mode 100644 notification/README.MD create mode 100644 notification/cmd/main.go create mode 100644 notification/go.mod create mode 100644 notification/go.sum create mode 100644 notification/internal/config/config.go create mode 100644 notification/internal/consumer/notification.go create mode 100644 notification/internal/domain/notification.go create mode 100644 notification/internal/notifier/email.go create mode 100644 notification/internal/notifier/sms.go create mode 100644 notification/internal/rabbitmq/connection.go create mode 100644 test.py diff --git a/Makefile b/Makefile index e43734d..d71cf8d 100644 --- a/Makefile +++ b/Makefile @@ -7,4 +7,4 @@ up-payment: down-payment: docker compose --profile payment down down-all: - docker compose --profile payment --profile user down \ No newline at end of file + docker compose --profile payment --profile user --profile notification down \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 02e2e42..e15fdf0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,7 @@ networks: volumes: pg_data: null pycache: null + rabbitmq-data: null services: traefik: @@ -94,8 +95,29 @@ services: profiles: - payment + notification: + build: + context: ./notification + dockerfile: Dockerfile + networks: + - lamenu + profiles: + - notification + redis: networks: - lamenu restart: always image: redis + + rabbitmq: + image: rabbitmq:management + container_name: rabbitmq + ports: + - "5672:5672" # RabbitMQ porti + - "15672:15672" # Web konsol porti + environment: + - RABBITMQ_DEFAULT_USER=guest # Foydalanuvchi nomi + - RABBITMQ_DEFAULT_PASS=guest # Parol + volumes: + - rabbitmq-data:/var/lib/rabbitmq # Ma'lumotlarni saqlash diff --git a/notification/Dockerfile b/notification/Dockerfile new file mode 100644 index 0000000..b5f9de3 --- /dev/null +++ b/notification/Dockerfile @@ -0,0 +1,19 @@ +FROM golang:alpine as build + +WORKDIR /app + +COPY go.mod go.sum ./ + +RUN go mod download + +COPY . . + +RUN go build -o notification ./cmd/main.go + +FROM alpine + +WORKDIR /app + +COPY --from=build /app/notification . + +CMD ["./notification"] diff --git a/notification/README.MD b/notification/README.MD new file mode 100644 index 0000000..1a573f1 --- /dev/null +++ b/notification/README.MD @@ -0,0 +1,112 @@ +# Notification Service + +A microservice for handling and delivering notifications through various channels like SMS and email using RabbitMQ as a message broker. + +## Overview + +This notification service is designed as a standalone microservice that consumes notification requests from a RabbitMQ queue and routes them to the appropriate notification provider based on the notification type. Currently, it supports SMS and email notifications. + +## Features + +- Message consumption from RabbitMQ +- Support for multiple notification channels (SMS, email) +- Extensible architecture for adding new notification types +- Asynchronous notification handling + +## Architecture + +The notification service follows a clean architecture approach: + +- **Domain Layer**: Contains core business logic and port interfaces +- **Infrastructure Layer**: Implements the ports with concrete adapters +- **RabbitMQ**: Used as a message broker for consuming notification requests + +## Installation + +### Prerequisites + +- Go 1.x+ +- RabbitMQ server + +### Setup + +1. Clone the repository: +```bash +git clone https://github.com/JscorpTech/notification.git +cd notification +``` + +2. Install dependencies: +```bash +go mod download +``` + +3. Build the application: +```bash +go build -o notification-service +``` + +## Configuration + +Configure your RabbitMQ connection and other settings in the appropriate configuration files. + +## Usage + +### Running the service + +```bash +./notification-service +``` + +This will start the notification consumer that listens for incoming notification requests. + +### Sending a notification + +Notifications should be published to the RabbitMQ exchange with the following JSON format: + +```json +{ + "type": "email", + "message": "Hello, this is a test notification.", + "to": ["user@example.com"] +} +``` + +Available notification types: +- `email`: For email notifications +- `sms`: For SMS notifications + +## Project Structure + +``` +notification/ +├── cmd/ +│ └── main.go # Entry point +├── internal/ +│ ├── domain/ +│ │ └── ports.go # Interfaces +│ ├── notifier/ +│ │ ├── email.go # Email notification implementation +│ │ └── sms.go # SMS notification implementation +│ ├── rabbitmq/ +│ │ └── connection.go # RabbitMQ connection handling +│ └── consumer/ +│ └── consumer.go # Implementation of the notification consumer +└── README.md +``` + +## Contributing + +1. Fork the repository +2. Create your feature branch: `git checkout -b feature/my-new-feature` +3. Commit your changes: `git commit -am 'Add some feature'` +4. Push to the branch: `git push origin feature/my-new-feature` +5. Submit a pull request + +## License + +[Add your license here] + +## Contact + +JscorpTech - [GitHub](https://github.com/JscorpTech) diff --git a/notification/cmd/main.go b/notification/cmd/main.go new file mode 100644 index 0000000..845e0aa --- /dev/null +++ b/notification/cmd/main.go @@ -0,0 +1,10 @@ +package main + +import ( + "github.com/JscorpTech/notification/internal/consumer" +) + +func main() { + notification := consumer.NewNotificationConsumer() + notification.Start() +} diff --git a/notification/go.mod b/notification/go.mod new file mode 100644 index 0000000..8c97b6b --- /dev/null +++ b/notification/go.mod @@ -0,0 +1,12 @@ +module github.com/JscorpTech/notification + +go 1.24.0 + +require ( + github.com/k0kubun/pp/v3 v3.4.1 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.16 // indirect + github.com/streadway/amqp v1.1.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.19.0 // indirect +) diff --git a/notification/go.sum b/notification/go.sum new file mode 100644 index 0000000..27459d5 --- /dev/null +++ b/notification/go.sum @@ -0,0 +1,13 @@ +github.com/k0kubun/pp/v3 v3.4.1 h1:1WdFZDRRqe8UsR61N/2RoOZ3ziTEqgTPVqKrHeb779Y= +github.com/k0kubun/pp/v3 v3.4.1/go.mod h1:+SiNiqKnBfw1Nkj82Lh5bIeKQOAkPy6Xw9CAZUZ8npI= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/streadway/amqp v1.1.0 h1:py12iX8XSyI7aN/3dUT8DFIDJazNJsVJdxNVEpnQTZM= +github.com/streadway/amqp v1.1.0/go.mod h1:WYSrTEYHOXHd0nwFeUXAe2G2hRnQT+deZJJf88uS9Bg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= diff --git a/notification/internal/config/config.go b/notification/internal/config/config.go new file mode 100644 index 0000000..2f86d1c --- /dev/null +++ b/notification/internal/config/config.go @@ -0,0 +1,13 @@ +package config + +import ( + "os" +) + +func GetEnv(key, fallback string) string { + val := os.Getenv(key) + if val == "" { + return fallback + } + return val +} diff --git a/notification/internal/consumer/notification.go b/notification/internal/consumer/notification.go new file mode 100644 index 0000000..a32571c --- /dev/null +++ b/notification/internal/consumer/notification.go @@ -0,0 +1,62 @@ +package consumer + +import ( + "encoding/json" + "fmt" + "log" + + "github.com/JscorpTech/notification/internal/domain" + "github.com/JscorpTech/notification/internal/notifier" + "github.com/JscorpTech/notification/internal/rabbitmq" + "github.com/streadway/amqp" +) + +type notificationConsumer struct{} + +func NewNotificationConsumer() domain.NotificationConsumerPort { + return ¬ificationConsumer{} +} + +func (n *notificationConsumer) Start() { + conn, ch, err := rabbitmq.Connect() + if err != nil { + log.Fatal(err) + } + defer conn.Close() + defer ch.Close() + + exchangeName := "notification" + queueName := "notification" + routingKey := "notification" + + ch.ExchangeDeclare(exchangeName, "direct", true, false, false, false, nil) + q, _ := ch.QueueDeclare(queueName, true, false, false, false, nil) + ch.QueueBind(q.Name, routingKey, exchangeName, false, nil) + + msgs, _ := ch.Consume(q.Name, "", true, false, false, false, nil) + + go func() { + for msg := range msgs { + go n.Handler(msg) + } + }() + + fmt.Println("🚀 Server started. Ctrl+C to quit.") + select {} +} + +func (n *notificationConsumer) Handler(msg amqp.Delivery) { + var notification domain.NotificationMsg + err := json.Unmarshal(msg.Body, ¬ification) + if err != nil { + fmt.Print(err.Error()) + } + var ntf domain.NotifierPort + switch notification.Type { + case "sms": + ntf = notifier.NewSmsNotifier() + case "email": + ntf = notifier.NewEmailNotifier() + } + ntf.SendMessage(notification.To, notification.Message) +} diff --git a/notification/internal/domain/notification.go b/notification/internal/domain/notification.go new file mode 100644 index 0000000..be5bc44 --- /dev/null +++ b/notification/internal/domain/notification.go @@ -0,0 +1,18 @@ +package domain + +import "github.com/streadway/amqp" + +type NotificationConsumerPort interface { + Start() + Handler(amqp.Delivery) +} + +type NotifierPort interface { + SendMessage([]string, string) +} + +type NotificationMsg struct { + Type string `json:"type"` + Message string `json:"message"` + To []string `json:"to"` +} diff --git a/notification/internal/notifier/email.go b/notification/internal/notifier/email.go new file mode 100644 index 0000000..fb4b52d --- /dev/null +++ b/notification/internal/notifier/email.go @@ -0,0 +1,16 @@ +package notifier + +import ( + "github.com/JscorpTech/notification/internal/domain" + "github.com/k0kubun/pp/v3" +) + +type emailNotifier struct{} + +func NewEmailNotifier() domain.NotifierPort { + return &emailNotifier{} +} + +func (n *emailNotifier) SendMessage(to []string, body string) { + pp.Print(to, body) +} diff --git a/notification/internal/notifier/sms.go b/notification/internal/notifier/sms.go new file mode 100644 index 0000000..ab495d8 --- /dev/null +++ b/notification/internal/notifier/sms.go @@ -0,0 +1,16 @@ +package notifier + +import ( + "github.com/JscorpTech/notification/internal/domain" + "github.com/k0kubun/pp/v3" +) + +type smsNotifier struct{} + +func NewSmsNotifier() domain.NotifierPort { + return &smsNotifier{} +} + +func (n *smsNotifier) SendMessage(to []string, body string) { + pp.Print(to, body) +} diff --git a/notification/internal/rabbitmq/connection.go b/notification/internal/rabbitmq/connection.go new file mode 100644 index 0000000..2c432e1 --- /dev/null +++ b/notification/internal/rabbitmq/connection.go @@ -0,0 +1,21 @@ +package rabbitmq + +import ( + "log" + + "github.com/streadway/amqp" +) + +func Connect() (*amqp.Connection, *amqp.Channel, error) { + conn, err := amqp.Dial("amqp://guest:guest@127.0.0.1:5672/") + if err != nil { + return nil, nil, err + } + ch, err := conn.Channel() + if err != nil { + return nil, nil, err + } + log.Println("🐇 Connected to RabbitMQ") + + return conn, ch, nil +} diff --git a/test.py b/test.py new file mode 100644 index 0000000..bb53ca4 --- /dev/null +++ b/test.py @@ -0,0 +1,17 @@ +from kombu import Connection, Exchange, Producer + +# RabbitMQ ulanishi +rabbit_url = 'amqp://guest:guest@127.0.0.1:5672/' +connection = Connection(rabbit_url) +channel = connection.channel() + +exchange = Exchange('notification', type='direct') + +# Producer yaratish +producer = Producer(channel, exchange=exchange, routing_key="notification") + +# Xabar yuborish +message = {'type': 'email', 'message': 'Hello, Workers!', "to": ["+998888112309", "+998943990509"]} +producer.publish(message) + +print("Message sent to all workers!") diff --git a/user/docker-compose.yml b/user/docker-compose.yml index cc717e8..b80c25b 100644 --- a/user/docker-compose.yml +++ b/user/docker-compose.yml @@ -1,5 +1,5 @@ networks: - auth: + user: driver: bridge volumes: @@ -10,7 +10,7 @@ volumes: services: nginx: networks: - - auth + - user ports: - ${PORT:-8001}:80 volumes: @@ -23,7 +23,7 @@ services: - web web: networks: - - auth + - user build: context: . dockerfile: ./docker/Dockerfile.web @@ -39,7 +39,7 @@ services: - redis db: networks: - - auth + - user image: postgres:16 restart: always environment: @@ -50,6 +50,6 @@ services: - pg_data:/var/lib/postgresql/data redis: networks: - - auth + - user restart: always image: redis \ No newline at end of file