feat: Implement Dockerized multi-tenant Django application with initial setup for database, migrations, and superuser creation.

This commit is contained in:
2025-12-12 18:04:36 +03:00
parent 0046b36e89
commit 4cbc5c07b9
7 changed files with 152 additions and 27 deletions

View File

@@ -225,7 +225,8 @@ STATICFILES_DIRS = [BASE_DIR / 'static']
# В production используем внешнюю директорию для nginx
if not DEBUG:
STATIC_ROOT = '/Volume1/DockerAppsData/npm/data/static/'
# Внутри контейнера путь всегда /app/staticfiles (куда мы смонтировали volume)
STATIC_ROOT = BASE_DIR / 'staticfiles'
else:
STATIC_ROOT = BASE_DIR / 'staticfiles'

View File

@@ -97,7 +97,8 @@ class Command(BaseCommand):
self.stdout.write(self.style.SUCCESS(f'✓ Тенант создан (ID: {client.id})'))
# Создаем домен
domain_name = f"{registration.schema_name}.localhost"
domain_base = getattr(settings, 'TENANT_DOMAIN_BASE', 'localhost')
domain_name = f"{registration.schema_name}.{domain_base}"
self.stdout.write(f'Создание домена: {domain_name}')
domain = Domain.objects.create(
domain=domain_name,

View File

@@ -7,6 +7,7 @@ Management команда для создания нового тенанта (
"""
from django.core.management.base import BaseCommand
from django.db import transaction
from django.conf import settings
from tenants.models import Client, Domain
import re
@@ -115,7 +116,8 @@ class Command(BaseCommand):
def get_domain_name(self, default_subdomain):
"""Получить доменное имя"""
while True:
default_domain = f'{default_subdomain}.localhost'
domain_base = getattr(settings, 'TENANT_DOMAIN_BASE', 'localhost')
default_domain = f'{default_subdomain}.{domain_base}'
domain = input(f'Доменное имя [{default_domain}]: ').strip().lower()
if not domain: