From 4ab95432fcec34af1eb8335127d0b9f51c0e2b64 Mon Sep 17 00:00:00 2001 From: b1ek Date: Wed, 17 May 2023 07:42:00 +1000 Subject: [PATCH] production ready image --- docker-compose.yml | 7 ++++--- pairent_backend/Dockerfile | 10 ++++++---- pairent_backend/pairent_backend/settings.py | 9 +++++---- pairent_backend/requirements.txt | 4 ++-- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index bc0b466..e5f471d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: depends_on: - db db: - image: mariadb + image: postgres networks: pairent: aliases: @@ -37,8 +37,9 @@ services: volumes: - './data/db:/etc/mysql' environment: - MARIADB_ROOT_PASSWORD: '${DB_PASSWORD}' - MARIADB_DATABASE: 'pairent_db' + POSTGRES_PASSWORD: '${DB_PASSWORD}' + POSTGRES_DB: 'pairent_db' + POSTGRES_USER: 'root' networks: pairent: diff --git a/pairent_backend/Dockerfile b/pairent_backend/Dockerfile index 49f3e5f..98ce58e 100644 --- a/pairent_backend/Dockerfile +++ b/pairent_backend/Dockerfile @@ -1,9 +1,11 @@ FROM python:alpine -RUN apk add --no-cache \ - gcc musl-dev \ - mysql mariadb-connector-c-dev && \ - mkdir /opt/code +# mysql mariadb-connector-c-dev + +RUN apk add --no-cache postgresql-libs && \ + apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev && \ + mkdir /opt/code && \ + apk --purge del .build-deps COPY requirements.txt /opt/code/requirements.txt WORKDIR /opt/code diff --git a/pairent_backend/pairent_backend/settings.py b/pairent_backend/pairent_backend/settings.py index 37fcd3a..4ac650c 100644 --- a/pairent_backend/pairent_backend/settings.py +++ b/pairent_backend/pairent_backend/settings.py @@ -97,15 +97,16 @@ WSGI_APPLICATION = 'pairent_backend.wsgi.application' DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.mysql', + 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'pairent_db', 'USER': DOTENV['DB_USER'], 'PASSWORD': DOTENV['DB_PASSWORD'], 'HOST': DOTENV['DB_HOST'], 'PORT': DOTENV['DB_PORT'], - 'OPTIONS': { - 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'" - } + # 'OPTIONS': { + # 'init_command': "SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci", + # 'charset': 'utf8mb4' + # } } } diff --git a/pairent_backend/requirements.txt b/pairent_backend/requirements.txt index 5b3d1ab..14c096b 100644 --- a/pairent_backend/requirements.txt +++ b/pairent_backend/requirements.txt @@ -1,4 +1,4 @@ -mysqlclient +psycopg2-binary django djangorestframework django-cors-headers @@ -6,4 +6,4 @@ Pillow requests python-ipware python-dotenv -gunicorn \ No newline at end of file +gunicorn