From c17a6fb209a772d9f66e24987aec4093905907f4 Mon Sep 17 00:00:00 2001 From: altf4arnold Date: Tue, 26 Mar 2024 17:16:10 +0100 Subject: [PATCH] Docker Ok. Testing CI/CD should work --- .gitignore | 1 + config.example.py | 6 +++++- docker-compose.yml | 2 ++ env.prod.db.example | 3 +++ requirements.in | 5 +++-- requirements.txt | 10 ++++++---- tldtest/settings.py | 25 +++++++++++++++++++------ 7 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 env.prod.db.example diff --git a/.gitignore b/.gitignore index 9964af6..8cd46ff 100644 --- a/.gitignore +++ b/.gitignore @@ -175,3 +175,4 @@ cython_debug/ #.idea/ # Avoiding public key leakage /config.py +/env.prod.db \ No newline at end of file diff --git a/config.example.py b/config.example.py index d3091b4..7776b25 100644 --- a/config.example.py +++ b/config.example.py @@ -2,4 +2,8 @@ SECRET_KEY = 'xinxl8xx#j$)#5h#pbv3knyyq2d6o%j125rx==e7vz*#wsd32w' DEBUG = True -ALLOWED_HOSTS = [] \ No newline at end of file +ALLOWED_HOSTS = [] + +DBUSER = "tldtest" + +DBPASSWORD = "clubmate2010" diff --git a/docker-compose.yml b/docker-compose.yml index 4f45b92..e96255b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,5 +14,7 @@ services: image: postgres:15 volumes: - postgres_data:/var/lib/postgresql/data/ + env_file: + - env.prod.db volumes: postgres_data: diff --git a/env.prod.db.example b/env.prod.db.example new file mode 100644 index 0000000..ab3039b --- /dev/null +++ b/env.prod.db.example @@ -0,0 +1,3 @@ +POSTGRES_USER=tldtest +POSTGRES_PASSWORD="clubmate2010" +POSTGRES_DB=tldtest-db diff --git a/requirements.in b/requirements.in index 77f4944..005a9e2 100644 --- a/requirements.in +++ b/requirements.in @@ -1,5 +1,5 @@ asgiref==3.7.2 -build==1.1.1 +build==1.0.3 click==8.1.7 Django==5.0.2 django-admin-extra-buttons==1.5.7 @@ -9,7 +9,8 @@ flake8==7.0.0 gunicorn==21.2.0 mccabe==0.7.0 packaging==23.2 -pip-tools==7.4.0 +pip-tools==7.3.0 +psycopg2-binary==2.9.9 pycodestyle==2.11.1 pyflakes==3.2.0 pyproject_hooks==1.0.0 diff --git a/requirements.txt b/requirements.txt index 3311d14..add2575 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.12 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # pip-compile --output-file=requirements.txt requirements.in @@ -8,7 +8,7 @@ asgiref==3.7.2 # via # -r requirements.in # django -build==1.1.1 +build==1.0.3 # via # -r requirements.in # pip-tools @@ -40,7 +40,10 @@ packaging==23.2 # via # -r requirements.in # build -pip-tools==7.4.0 + # gunicorn +pip-tools==7.3.0 + # via -r requirements.in +psycopg2-binary==2.9.9 # via -r requirements.in pycodestyle==2.11.1 # via @@ -54,7 +57,6 @@ pyproject-hooks==1.0.0 # via # -r requirements.in # build - # pip-tools rcssmin==1.1.1 # via # -r requirements.in diff --git a/tldtest/settings.py b/tldtest/settings.py index a65ef3e..40109e3 100644 --- a/tldtest/settings.py +++ b/tldtest/settings.py @@ -21,7 +21,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SCRET_KEY = config.SECRET_KEY +SECRET_KEY = config.SECRET_KEY # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config.DEBUG @@ -78,12 +78,25 @@ WSGI_APPLICATION = 'tldtest.wsgi.application' # Database # https://docs.djangoproject.com/en/3.1/ref/settings/#databases -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', +if DEBUG is True: + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } } -} +else: + DATABASES = { + "default": { + "ENGINE": ("django.db.backends.postgresql"), + "NAME": ("tldtest-db"), + "USER": (config.DBUSER), + "PASSWORD": (config.DBPASSWORD), + "HOST": ("db"), + "PORT": ("5432"), + } + } + # Password validation