Fixed getting creditionals for postgre from env

This commit is contained in:
ITQ
2024-02-28 00:14:23 +03:00
parent b97672d07c
commit b206a71909
5 changed files with 34 additions and 8 deletions
+2
View File
@@ -1,5 +1,7 @@
.dockerignore .dockerignore
Dockerfile Dockerfile
README.md README.md
ruff.toml
venv/ venv/
__pycache__/ __pycache__/
.ruff_cache/
+2
View File
@@ -158,3 +158,5 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear # and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ #.idea/
static/
+2 -2
View File
@@ -4,8 +4,8 @@ WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1 ENV PYTHONUNBUFFERED 1
ENV SERVER_PORT = 8080 ENV SERVER_PORT=8080
ENV DJANGO_DEBUG = False ENV DJANGO_DEBUG=False
RUN pip3 install --upgrade pip RUN pip3 install --upgrade pip
COPY requirements/prod.txt . COPY requirements/prod.txt .
+18 -2
View File
@@ -63,12 +63,26 @@ WSGI_APPLICATION = "pulse.wsgi.application"
POSTGRES_CONN = os.getenv("POSTGRES_CONN") POSTGRES_CONN = os.getenv("POSTGRES_CONN")
DATABASES = { POSTGRES_JDBC_URL = os.getenv("POSTGRES_JDBC_URL")
if POSTGRES_CONN:
DATABASES = {
"default": { "default": {
"ENGINE": "django.db.backends.postgresql", "ENGINE": "django.db.backends.postgresql",
**dj_database_url.parse(POSTGRES_CONN), **dj_database_url.parse(POSTGRES_CONN),
}, },
} }
else:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": os.getenv("POSTGRES_DATABASE"),
"USER": os.getenv("POSTGRES_USERNAME"),
"PASSWORD": os.getenv("POSTGRES_PASSWORD"),
"HOST": os.getenv("POSTGRES_HOST"),
"PORT": os.getenv("POSTGRES_PORT"),
},
}
AUTH_PASSWORD_VALIDATORS = [ AUTH_PASSWORD_VALIDATORS = [
{ {
@@ -104,6 +118,8 @@ USE_TZ = True
STATIC_URL = "static/" STATIC_URL = "static/"
STATIC_ROOT = BASE_DIR / "static"
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
REST_FRAMEWORK = { REST_FRAMEWORK = {
+6
View File
@@ -3,3 +3,9 @@ SECRET_KEY = secret_key
DJANGO_ALLOWED_HOSTS = 127.0.0.1 DJANGO_ALLOWED_HOSTS = 127.0.0.1
INTERNAL_IPS = 127.0.0.1 INTERNAL_IPS = 127.0.0.1
POSTGRES_CONN = postgres://login:pass@localhost:5432/postgres POSTGRES_CONN = postgres://login:pass@localhost:5432/postgres
POSTGRES_JDBC_URL = jdbc:postgresql://host:port/dbname
POSTGRES_USERNAME = postgres
POSTGRES_PASSWORD = password
POSTGRES_HOST = localhost
POSTGRES_PORT = 5432
POSTGRES_DATABASE = postgres