From 25c0482d7b3bcf91669d218eae775a6e59cdc4ee Mon Sep 17 00:00:00 2001 From: Jannes Kurth Date: Sun, 25 Feb 2024 00:20:51 +0100 Subject: [PATCH] Setup Postgres for local development. --- db/README.md | 8 ++++++++ db/docker-compose.yml | 14 ++++++++++++++ mixr_api/settings.py | 8 ++++++-- requirements.txt | 3 ++- 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 db/README.md create mode 100644 db/docker-compose.yml diff --git a/db/README.md b/db/README.md new file mode 100644 index 0000000..af61e32 --- /dev/null +++ b/db/README.md @@ -0,0 +1,8 @@ +## Postgres Setup with docker-compose + +Start the postgres container with the following command: +```bash +docker-compose up -d +``` + +Alternatively, you can use a PyCharm configuration to start the container. (Docker > Docker Compose) \ No newline at end of file diff --git a/db/docker-compose.yml b/db/docker-compose.yml new file mode 100644 index 0000000..66c5a2a --- /dev/null +++ b/db/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3.8' + +services: + postgres: + image: postgres:latest + environment: + POSTGRES_DB: mixr-db + POSTGRES_USER: mixr-api + POSTGRES_PASSWORD: mypassword + ports: + - "5432:5432" + # Optional: Uncomment the following line to mount a volume for persistence + # volumes: + # - /path/on/host:/var/lib/postgresql/data diff --git a/mixr_api/settings.py b/mixr_api/settings.py index 3c017d1..48e5b70 100644 --- a/mixr_api/settings.py +++ b/mixr_api/settings.py @@ -75,8 +75,12 @@ WSGI_APPLICATION = 'mixr_api.wsgi.application' DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'mixr-db', + 'USER': 'mixr-api', + 'PASSWORD': 'mypassword', + 'HOST': '127.0.0.1', + 'PORT': '5432', } } diff --git a/requirements.txt b/requirements.txt index a1e13a3..7a8ce49 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -Django~=5.0.2 \ No newline at end of file +Django~=5.0.2 +psycopg2-binary~=2.9.9 \ No newline at end of file