This commit is contained in:
Andros Fenollosa 2024-09-01 21:36:14 +02:00
parent 5f1f9de569
commit 488bdfe3e2
3 changed files with 24 additions and 8 deletions

View File

@ -6,9 +6,14 @@ services:
restart: ${RESTART_POLICY}
env_file: .env
environment:
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_NAME}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
interval: 30s
timeout: 60s
retries: 5
expose:
- 5432
@ -46,6 +51,11 @@ services:
restart: ${RESTART_POLICY}
container_name: ${PROJECT_NAME}-redis
env_file: .env
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 60s
retries: 5
expose:
- ${REDIS_PORT}

View File

@ -10,7 +10,6 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
import os
import dj_database_url
from pathlib import Path
from django.db.backends.signals import connection_created
@ -75,9 +74,14 @@ TEMPLATES = [
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
"default": dj_database_url.config(
default=f"postgres://{os.environ.get('DB_USER')}:{os.environ.get('DB_PASSWORD')}@{os.environ.get('DB_HOST')}:{os.environ.get('DB_PORT')}/{os.environ.get('DB_NAME')}"
)
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": os.environ.get("POSTGRES_NAME"),
"USER": os.environ.get("POSTGRES_USER"),
"PASSWORD": os.environ.get("POSTGRES_PASSWORD"),
"HOST": os.environ.get("POSTGRES_HOST"),
"PORT": os.environ.get("POSTGRES_PORT"),
}
}
# Password validation

View File

@ -17,9 +17,11 @@ HCAPTCHA_ENABLED=False
HCAPTCHA_SECRET_KEY=0x0000000000000000000000000000000000000000
# Database
POSTGRES_DB=project_db
POSTGRES_HOST=postgresql
POSTGRES_NAME=project_db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_PORT=5432
# Redis
REDIS_URI="redis://:@redis:6379"