diff --git a/.env.dev b/.env.dev index ebf3670..7bbda88 100644 --- a/.env.dev +++ b/.env.dev @@ -1,15 +1,17 @@ # Django secrets -SECRET_KEY=super-insecure-django-key +SECRET_KEY=django-insecure-@0apn-lk85pfw=z00x2ib$w9#rwz8%2v4i_n^^9jz-m9b+y55* DEBUG=True -ALLOWED_HOSTS=* +ALLOWED_HOSTS=localhost,127.0.0.1,https://rasadyar.net,https://localhost:9200,https://api.rasadyar.net,*.rasadyar.com,https://dam.rasadyar.net,http://localhost:3000,http://192.168.88.130:3000,https://rasaddam-front.liara.run,ns0ck4ksk0koks8ksw0ss08g.31.7.78.133.sslip.io # noqa ENV_NAME=DEV -# Datbase secrets -DB_HOST=localhost -DB_PORT=5432 -DB_NAME=example_db +# Database secrets +DB_HOST=31.7.78.133 +DB_PORT=14352 +DB_NAME=Development DB_USERNAME=postgres -DB_PASSWORD=12345678 +DB_PASSWORD=pfLIVXupbDetvFMt2gUvxLXUL9b4HIOHaPcKXsBEZ1i8zl0iLUjmhUfXlGfJKcTV + +ENV RUNNING_IN_DOCKER=1 # Super user information -SUPERUSER_EMAIL=superuser@example.com +# SUPERUSER_EMAIL=superuser@example.com diff --git a/.env.local b/.env.local new file mode 100644 index 0000000..8fb72cf --- /dev/null +++ b/.env.local @@ -0,0 +1,17 @@ +# Django secrets +SECRET_KEY=django-insecure-@0apn-lk85pfw=z00x2ib$w9#rwz8%2v4i_n^^9jz-m9b+y55* +DEBUG=True +ALLOWED_HOSTS=localhost,127.0.0.1,https://rasadyar.net/,https://localhost:9200,https://api.rasadyaar.net,https://api.dam.rasadyaar.net',https://dam.rasadyar.net',http://localhost:3000',http://192.168.88.130:3000',https://rasaddam-front.liara.run',ns0ck4ksk0koks8ksw0ss08g.31.7.78.133.sslip.io' # noqa +ENV_NAME=DEV + +# Database secrets +DB_HOST=31.7.78.133 +DB_PORT=14352 +DB_NAME=Development +DB_USERNAME=postgres +DB_PASSWORD=pfLIVXupbDetvFMt2gUvxLXUL9b4HIOHaPcKXsBEZ1i8zl0iLUjmhUfXlGfJKcTV + +ENV RUNNING_IN_DOCKER=0 + +# Super user information +# SUPERUSER_EMAIL=superuser@example.com diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index cf2cf7b..fdacf5f 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -8,5 +8,12 @@ jdbc:postgresql://monte-rosa.liara.cloud:32718/postgres $ProjectFileDir$ + + postgresql + true + org.postgresql.Driver + jdbc:postgresql://31.7.78.133:14352/postgres + $ProjectFileDir$ + \ No newline at end of file diff --git a/Rasaddam_Backend/settings.py b/Rasaddam_Backend/settings.py index 08867c5..16a15d2 100644 --- a/Rasaddam_Backend/settings.py +++ b/Rasaddam_Backend/settings.py @@ -12,7 +12,8 @@ https://docs.djangoproject.com/en/5.2/ref/settings/ import os.path from datetime import timedelta from pathlib import Path - +import os +from dotenv import load_dotenv from django.conf import settings # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -21,27 +22,19 @@ BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/ +if not os.getenv("RUNNING_IN_DOCKER"): + dotenv_path = BASE_DIR / ".env.local" + load_dotenv(dotenv_path) + # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-@0apn-lk85pfw=z00x2ib$w9#rwz8%2v4i_n^^9jz-m9b+y55*' +SECRET_KEY = os.environ.get("SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False +DEBUG = bool(os.environ.get("DEBUG", default=0)) ASGI_APPLICATION = "Rasaddam_Backend.asgi.application" # noqa -ALLOWED_HOSTS = [ - 'localhost', - '127.0.0.1', - 'https://rasadyar.net/', - 'https://localhost:9200', - 'https://api.rasadyaar.net', - 'https://api.dam.rasadyaar.net', - 'https://dam.rasadyar.net' - 'http://localhost:3000', - 'http://192.168.88.130:3000', - 'https://rasaddam-front.liara.run', - 'ns0ck4ksk0koks8ksw0ss08g.31.7.78.133.sslip.io' # noqa -] +ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS").split(",") # Application definition @@ -129,13 +122,22 @@ MONGODB_DATABASES = { } DATABASES = { + # 'default': { + # 'ENGINE': 'django.db.backends.postgresql_psycopg2', + # 'NAME': "postgres", + # 'HOST': "monte-rosa.liara.cloud", + # 'USER': "root", + # 'PASSWORD': "aFC3hqbxxR0SeBPZ6TCZ37my", + # 'PORT': '32718' + # }, + 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': "postgres", - 'HOST': "monte-rosa.liara.cloud", - 'USER': "root", - 'PASSWORD': "aFC3hqbxxR0SeBPZ6TCZ37my", - 'PORT': '32718' + 'NAME': os.environ.get("DB_NAME"), + 'HOST': os.environ.get("DB_HOST"), + 'USER': os.environ.get("DB_USERNAME"), + 'PASSWORD': os.environ.get("DB_PASSWORD"), + 'PORT': os.environ.get("DB_PORT"), }, } diff --git a/docker-compose.yml b/docker-compose.yml index bfd2918..919d88b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,4 +7,6 @@ services: volumes: - ./app/:/usr/src/app/ ports: - - "5000:5000" \ No newline at end of file + - "5000:5000" + env_file: + - ./.env.dev diff --git a/requirements.txt b/requirements.txt index 0a671a4..1bbfcff 100644 --- a/requirements.txt +++ b/requirements.txt @@ -84,3 +84,4 @@ channels channels_redis daphne django-jazzmin +python-dotenv