Makefile'dan bo'lak qismlar o'chirildi, docker-compose va Dockerfile'ga yangiliklar qo'shildi, yangi payment/api ilovasi yaratildi.

This commit is contained in:
A'zamov Samandar
2025-04-19 16:28:06 +05:00
parent 5d27809f17
commit e5b57671c8
21 changed files with 239 additions and 8 deletions

View File

@@ -3,10 +3,8 @@ up-auth:
down-auth: down-auth:
docker compose --profile auth down docker compose --profile auth down
up-payment: up-payment:
docker compose --profile payment up -d docker compose --profile payment up -d
down-payment: down-payment:
docker compose --profile payment down docker compose --profile payment down

View File

@@ -1,11 +1,7 @@
from config.env import env from config.env import env
APPS = [ APPS = [
"cacheops", "cacheops",
"drf_spectacular", "drf_spectacular",
"rest_framework", "rest_framework",
"corsheaders", "corsheaders",

View File

@@ -75,6 +75,11 @@ services:
- auth - auth
payment: 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: networks:
- lamenu - lamenu
build: build:

View File

@@ -1,3 +1,13 @@
FROM alpine:latest FROM python:3.13-alpine
CMD ["sleep", "60"] 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"]

0
payment/api/__init__.py Normal file
View File

3
payment/api/admin.py Normal file
View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
payment/api/apps.py Normal file
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class ApiConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "api"

View File

3
payment/api/models.py Normal file
View File

@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

3
payment/api/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

6
payment/api/urls.py Normal file
View File

@@ -0,0 +1,6 @@
from django.urls import path
from .views import HealthView
urlpatterns = [
path("health/", HealthView.as_view())
]

7
payment/api/views.py Normal file
View File

@@ -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"})

View File

16
payment/config/asgi.py Normal file
View File

@@ -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()

126
payment/config/settings.py Normal file
View File

@@ -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"

7
payment/config/urls.py Normal file
View File

@@ -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),
]

16
payment/config/wsgi.py Normal file
View File

@@ -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()

BIN
payment/db.sqlite3 Normal file

Binary file not shown.

5
payment/entrypoint.sh Normal file
View File

@@ -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

22
payment/manage.py Executable file
View File

@@ -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()

2
payment/requirements.txt Normal file
View File

@@ -0,0 +1,2 @@
django==5.1.3
djangorestframework==3.15.2