Internal
Public Access
Add Docker deployment configuration
- Add Dockerfile for production (multi-stage build) - Add Dockerfile.dev for development with hot reload - Add docker-compose.yml with 5 services (web, mariadb, redis, celery-worker, celery-beat) - Add docker-compose.dev.yml for development overrides - Add .dockerignore for optimized builds - Add docker/entrypoint.sh startup script - Add .env.docker.example template - Add Makefile for common commands - Add deploy.sh for one-command deployment - Update config/settings/selfhosted.py to support MariaDB via DATABASE_URL - Add mysqlclient to requirements.txt for MariaDB support - Update .gitignore to exclude .env.docker 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.5
parent
a2097dcad3
commit
71399e54b8
@@ -6,6 +6,7 @@ Use this for users running their own instance.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import dj_database_url
|
||||
from .base import *
|
||||
|
||||
# Security
|
||||
@@ -28,17 +29,50 @@ if DEBUG:
|
||||
|
||||
ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', 'localhost,127.0.0.1').split(',')
|
||||
|
||||
# Database - PostgreSQL for self-hosted
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': os.environ.get('POSTGRES_DB', 'keepitgoing'),
|
||||
'USER': os.environ.get('POSTGRES_USER', 'keepitgoing'),
|
||||
'PASSWORD': os.environ.get('POSTGRES_PASSWORD', 'keepitgoing'),
|
||||
'HOST': os.environ.get('POSTGRES_HOST', 'db'),
|
||||
'PORT': os.environ.get('POSTGRES_PORT', '5432'),
|
||||
# Database - Support both PostgreSQL and MariaDB/MySQL via DATABASE_URL
|
||||
# DATABASE_URL format examples:
|
||||
# PostgreSQL: postgresql://user:password@host:5432/dbname
|
||||
# MariaDB/MySQL: mysql://user:password@host:3306/dbname
|
||||
database_url = os.environ.get('DATABASE_URL')
|
||||
|
||||
if database_url:
|
||||
# Use DATABASE_URL for flexible database backend (PostgreSQL, MariaDB, MySQL, etc.)
|
||||
DATABASES = {
|
||||
'default': dj_database_url.config(
|
||||
default=database_url,
|
||||
conn_max_age=600,
|
||||
conn_health_checks=True,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
# Add MariaDB/MySQL specific options if using MySQL backend
|
||||
if 'mysql' in database_url.lower():
|
||||
DATABASES['default']['OPTIONS'] = {
|
||||
'charset': 'utf8mb4',
|
||||
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
|
||||
}
|
||||
else:
|
||||
# Fallback to manual configuration (backwards compatibility)
|
||||
# Supports both PostgreSQL and MariaDB/MySQL
|
||||
db_engine = os.environ.get('DB_ENGINE', 'django.db.backends.postgresql')
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': db_engine,
|
||||
'NAME': os.environ.get('DB_NAME', os.environ.get('POSTGRES_DB', 'keepitgoing')),
|
||||
'USER': os.environ.get('DB_USER', os.environ.get('POSTGRES_USER', 'keepitgoing')),
|
||||
'PASSWORD': os.environ.get('DB_PASSWORD', os.environ.get('POSTGRES_PASSWORD', 'keepitgoing')),
|
||||
'HOST': os.environ.get('DB_HOST', os.environ.get('POSTGRES_HOST', 'db')),
|
||||
'PORT': os.environ.get('DB_PORT', os.environ.get('POSTGRES_PORT', '5432')),
|
||||
}
|
||||
}
|
||||
|
||||
# Add MariaDB/MySQL specific options if using MySQL backend
|
||||
if 'mysql' in db_engine:
|
||||
DATABASES['default']['OPTIONS'] = {
|
||||
'charset': 'utf8mb4',
|
||||
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
|
||||
}
|
||||
|
||||
# Redis/Celery
|
||||
REDIS_URL = os.environ.get('REDIS_URL', 'redis://redis:6379/0')
|
||||
|
||||
Reference in New Issue
Block a user