fix docker compose file and docker

This commit is contained in:
nabijonovdavronbek619@gmail.com
2025-12-06 19:35:36 +05:00
parent 17c20ddf94
commit 0e40423aba
14 changed files with 206 additions and 9 deletions

View File

@@ -10,7 +10,12 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.2/ref/settings/
"""
import os
from pathlib import Path
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -20,12 +25,12 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-r616b$_bknw-2nh96gbuwe%2l-2o@g3uui747t8jz&nwp&xe_m'
SECRET_KEY = os.getenv('SECRET_KEY', 'django-insecure-r616b$_bknw-2nh96gbuwe%2l-2o@g3uui747t8jz&nwp&xe_m')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = os.getenv('DEBUG', 'False').lower() == 'true'
ALLOWED_HOSTS = []
ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', 'localhost,127.0.0.1').split(',')
# Application definition
@@ -75,12 +80,26 @@ WSGI_APPLICATION = 'portfolio_admin.wsgi.application'
# Database
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
DB_ENGINE = os.getenv('DB_ENGINE', 'sqlite3')
if DB_ENGINE == 'postgresql':
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.getenv('DB_NAME', 'portfolio_admin'),
'USER': os.getenv('DB_USER', 'postgres'),
'PASSWORD': os.getenv('DB_PASSWORD', 'postgres'),
'HOST': os.getenv('DB_HOST', 'db'),
'PORT': os.getenv('DB_PORT', '5432'),
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
}
# Password validation