This commit is contained in:
Kseninia Mikhaylova 2025-06-23 11:38:39 +03:00
commit ce9f916b39
24 changed files with 11346 additions and 0 deletions

14
.dockerignore Normal file
View File

@ -0,0 +1,14 @@
front/node_modules
app/files
/files
/step_files
# Optional: other common ignores
.git
*.pyc
__pycache__
env/
venv/
.dockerignore
.gitignore
*.md

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
.env
*.pyc
**/__pycache__/
.vscode
app/files
files
step_files
redis
celerybeat-schedule
flower.db

20
app/Dockerfile Normal file
View File

@ -0,0 +1,20 @@
FROM ci.svs-tech.pro/library/node:22-bookworm-slim
ENV WORKING_DIR=/app
WORKDIR ${WORKING_DIR}
RUN apt-get update && apt-get install -y \
python3-pip \
python3-poetry \
postgresql-15
RUN poetry -vvv --version
COPY pyproject.toml poetry.lock ./
RUN poetry install
COPY . ${WORKING_DIR}
RUN poetry run python manage.py makemigrations
CMD ["poetry", "run", "task", "app"]

View File

16
app/data_helper/asgi.py Normal file
View File

@ -0,0 +1,16 @@
"""
ASGI config for data_helper 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/3.2/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'data_helper.settings')
application = get_asgi_application()

View File

@ -0,0 +1,2 @@
import logging
logger = logging.getLogger("root")

207
app/data_helper/settings.py Normal file
View File

@ -0,0 +1,207 @@
"""
Django settings for data_helper project.
Generated by 'django-admin startproject' using Django 3.2.12.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
import os
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/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-%erkv*0u@b8jj5=-k5+#e_gvlbdky63n2s(anj9nzu!p^(1fbg"
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
WEB_PORT = os.getenv("WEB_PORT")
BASE_HOST = os.getenv("BASE_HOST", "192.168.88.107")
BASE_HOST_WITH_PORT = f"{BASE_HOST}:{WEB_PORT}"
BASE_HOST_WITH_PORT_DEV = f"{BASE_HOST}:8000"
ALLOWED_HOSTS = [
BASE_HOST,
BASE_HOST_WITH_PORT,
BASE_HOST_WITH_PORT_DEV,
"ecp.svs-tech.pro",
"ecp-dev.svs-tech.pro",
"app",
]
ALLOWED_CLIENT_ORIGINS = [
"http://localhost:3000",
f"http://{BASE_HOST}",
f"http://{BASE_HOST_WITH_PORT}",
f"http://{BASE_HOST_WITH_PORT_DEV}",
"http://ecp.svs-tech.pro",
"http://ecp-dev.svs-tech.pro",
]
CORS_ORIGIN_ALLOW_ALL = False
CSRF_TRUSTED_ORIGINS = ALLOWED_CLIENT_ORIGINS
CORS_ORIGIN_WHITELIST = ALLOWED_CLIENT_ORIGINS
CORS_ALLOW_HEADERS = [
"accept",
"accept-encoding",
"authorization",
"content-type",
"dnt",
"origin",
"user-agent",
"x-csrftoken",
"x-requested-with",
"x-terminal-id",
]
# Application definition
INSTALLED_APPS = [
"daphne",
"admin_interface",
"colorfield",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"corsheaders",
"django_filters",
"django_extensions",
"rest_framework",
"crispy_forms",
"crispy_bootstrap4",
"django_eventstream",
]
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"corsheaders.middleware.CorsMiddleware",
"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 = "data_helper.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 = "data_helper.wsgi.application"
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
# Password validation
# https://docs.djangoproject.com/en/3.2/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/3.2/topics/i18n/
LANGUAGE_CODE = "ru-ru"
TIME_ZONE = "Europe/Moscow"
USE_I18N = True
USE_L10N = True
USE_TZ = True
CELERY_BROKER_URL = f'redis://{os.getenv("REDIS_NAME", "redis")}:6379/0'
CELERY_RESULT_BACKEND = f'redis://{os.getenv("REDIS_NAME", "redis")}:6379/0'
CELERY_ACCEPT_CONTENT = ["json"]
CELERY_TASK_SERIALIZER = "json"
CELERY_RESULT_SERIALIZER = "json"
CELERY_TIMEZONE = "Europe/Moscow"
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = "/static/"
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"verbose": {
"format": "{levelname} {asctime} {module} {process:d} {thread:d} {message}",
"style": "{",
},
"large": {
"format": "%(asctime)s %(levelname)s %(process)d %(filename)s:%(lineno)d "
+ "%(funcName)s %(message)s "
},
"simple": {
"format": "{levelname} {asctime} {module} {message}",
"style": "{",
},
},
"handlers": {
"console": {
"level": "INFO",
"class": "logging.StreamHandler",
"formatter": "large",
},
},
"root": {
"handlers": ["console"],
"level": "INFO",
},
}

21
app/data_helper/urls.py Normal file
View File

@ -0,0 +1,21 @@
"""data_helper URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
]

16
app/data_helper/wsgi.py Normal file
View File

@ -0,0 +1,16 @@
"""
WSGI config for data_helper 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/3.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'data_helper.settings')
application = get_wsgi_application()

22
app/manage.py Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env python3
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'data_helper.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()

41
app/pyproject.toml Normal file
View File

@ -0,0 +1,41 @@
[tool.poetry]
name = "terteh"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.10"
django = "^5.1.3"
djangorestframework = "^3.15.2"
django-cors-headers = "^4.6.0"
django-filter = "^24.3"
django-crispy-forms = "^2.3"
crispy-bootstrap4 = "^2024.10"
django-extensions = "^3.2.3"
redis = "^5.2.0"
celery = "^5.4.0"
flower = "^2.0.1"
requests = "^2.32.3"
psycopg2-binary = "^2.9.10"
python-dotenv = "^1.0.1"
channels = "^4.2.0"
django-eventstream = {extras = ["drf"], version = "^5.3.1"}
daphne = "^4.1.2"
djangorestframework-simplejwt = "^5.4.0"
djangoviz = "^0.1.1"
pytz = "^2025.2"
django-admin-interface = "^0.30.0"
watchdog = "^6.0.0"
django-celery-beat = "^2.8.1"
[tool.poetry.group.dev.dependencies]
taskipy = "^1.14.1"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.taskipy.tasks]
app = "python manage.py runserver 0.0.0.0:8000"

4
compose.db.yaml Normal file
View File

@ -0,0 +1,4 @@
services:
redis:
ports:
- 6379:6379

93
compose.yaml Normal file
View File

@ -0,0 +1,93 @@
x-common-config: &common-config
restart: always
build:
context: ./app
dockerfile: Dockerfile
volumes:
- ./.env:/app/.env
networks:
- deployml_network
services:
redis:
image: redis
restart: always
volumes:
- ./redis:/data
- ./redis.conf:/usr/local/etc/redis/redis.conf
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
networks:
- deployml_network
app:
<<: *common-config
image: ci.svs-tech.pro/ecp-terteh:latest
depends_on:
- redis
worker:
<<: *common-config
command: poetry run celery -A webapp worker --loglevel=info
deploy:
resources:
limits:
cpus: "0.8"
memory: ${MEMORY_LIMIT:-2GB}
depends_on:
- app
- redis
beat:
<<: *common-config
command: poetry run celery -A webapp beat --loglevel=info --scheduler django_celery_beat.schedulers:DatabaseScheduler
depends_on:
- app
- redis
environment:
- DB_NAME=${DB_NAME}
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
- DB_HOST=${DB_HOST}
- DB_PORT=${DB_PORT}
env_file:
- .env
volumes:
- ./celerybeat-schedule:/app/celerybeat-schedule
flower:
<<: *common-config
command: poetry run celery --broker=redis://redis:6379 -A webapp flower --port=5555 --basic-auth=user:pswd
environment:
- FLOWER_PERSISTENT=True
volumes:
- ./flower.db:/app/flower.db
depends_on:
- app
- redis
- worker
front:
build:
context: ./front
dockerfile: Dockerfile
networks:
- deployml_network
depends_on:
- app
nginx:
image: nginx:latest
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
ports:
- "${WEB_PORT:-80}:80"
- "${CELERY_PORT:-8080}:8080"
networks:
- deployml_network
depends_on:
- front
- flower
networks:
deployml_network:
driver: bridge

24
front/.gitignore vendored Normal file
View File

@ -0,0 +1,24 @@
# Nuxt dev/build outputs
.output
.data
.nuxt
.nitro
.cache
dist
# Node dependencies
node_modules
# Logs
logs
*.log
# Misc
.DS_Store
.fleet
.idea
# Local env files
.env
.env.*
!.env.example

14
front/Dockerfile Normal file
View File

@ -0,0 +1,14 @@
FROM ci.svs-tech.pro/library/node:22-bookworm-slim
RUN mkdir -p /src
COPY package.json src/package.json
WORKDIR /src
RUN npm install
COPY . /src
RUN npm run build
CMD npm run preview -- --host

75
front/README.md Normal file
View File

@ -0,0 +1,75 @@
# Nuxt Minimal Starter
Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
## Setup
Make sure to install dependencies:
```bash
# npm
npm install
# pnpm
pnpm install
# yarn
yarn install
# bun
bun install
```
## Development Server
Start the development server on `http://localhost:3000`:
```bash
# npm
npm run dev
# pnpm
pnpm dev
# yarn
yarn dev
# bun
bun run dev
```
## Production
Build the application for production:
```bash
# npm
npm run build
# pnpm
pnpm build
# yarn
yarn build
# bun
bun run build
```
Locally preview production build:
```bash
# npm
npm run preview
# pnpm
pnpm preview
# yarn
yarn preview
# bun
bun run preview
```
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.

6
front/app.vue Normal file
View File

@ -0,0 +1,6 @@
<template>
<div>
<NuxtRouteAnnouncer />
<NuxtWelcome />
</div>
</template>

5
front/nuxt.config.ts Normal file
View File

@ -0,0 +1,5 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
compatibilityDate: '2025-05-15',
devtools: { enabled: true }
})

10730
front/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

17
front/package.json Normal file
View File

@ -0,0 +1,17 @@
{
"name": "nuxt-app",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"dependencies": {
"nuxt": "^3.17.5",
"vue": "^3.5.16",
"vue-router": "^4.5.1"
}
}

BIN
front/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

2
front/public/robots.txt Normal file
View File

@ -0,0 +1,2 @@
User-Agent: *
Disallow:

View File

@ -0,0 +1,3 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}

4
front/tsconfig.json Normal file
View File

@ -0,0 +1,4 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
}