production ready image

This commit is contained in:
b1ek 2023-05-17 07:42:00 +10:00
parent 02fa61b645
commit 4ab95432fc
Signed by: blek
GPG Key ID: 14546221E3595D0C
4 changed files with 17 additions and 13 deletions

View File

@ -29,7 +29,7 @@ services:
depends_on: depends_on:
- db - db
db: db:
image: mariadb image: postgres
networks: networks:
pairent: pairent:
aliases: aliases:
@ -37,8 +37,9 @@ services:
volumes: volumes:
- './data/db:/etc/mysql' - './data/db:/etc/mysql'
environment: environment:
MARIADB_ROOT_PASSWORD: '${DB_PASSWORD}' POSTGRES_PASSWORD: '${DB_PASSWORD}'
MARIADB_DATABASE: 'pairent_db' POSTGRES_DB: 'pairent_db'
POSTGRES_USER: 'root'
networks: networks:
pairent: pairent:

View File

@ -1,9 +1,11 @@
FROM python:alpine FROM python:alpine
RUN apk add --no-cache \ # mysql mariadb-connector-c-dev
gcc musl-dev \
mysql mariadb-connector-c-dev && \ RUN apk add --no-cache postgresql-libs && \
mkdir /opt/code 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 COPY requirements.txt /opt/code/requirements.txt
WORKDIR /opt/code WORKDIR /opt/code

View File

@ -97,15 +97,16 @@ WSGI_APPLICATION = 'pairent_backend.wsgi.application'
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'django.db.backends.postgresql',
'NAME': 'pairent_db', 'NAME': 'pairent_db',
'USER': DOTENV['DB_USER'], 'USER': DOTENV['DB_USER'],
'PASSWORD': DOTENV['DB_PASSWORD'], 'PASSWORD': DOTENV['DB_PASSWORD'],
'HOST': DOTENV['DB_HOST'], 'HOST': DOTENV['DB_HOST'],
'PORT': DOTENV['DB_PORT'], 'PORT': DOTENV['DB_PORT'],
'OPTIONS': { # 'OPTIONS': {
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'" # 'init_command': "SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci",
} # 'charset': 'utf8mb4'
# }
} }
} }

View File

@ -1,4 +1,4 @@
mysqlclient psycopg2-binary
django django
djangorestframework djangorestframework
django-cors-headers django-cors-headers