Files
ServerKit/backend/config.py
T
jhd3197andClaude Opus 4.5 63a04d3319 Fix SQLite database path for Docker volume mount
- Create /app/instance directory in Dockerfile with proper permissions
- Update DATABASE_URL default to use absolute path (/app/instance/serverkit.db)
- Ensures the non-root appuser can write to the database location
- Fixes "unable to open database file" error on fresh installs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 01:47:02 +00:00

55 lines
1.9 KiB
Python

import os
import sys
from datetime import timedelta
# Default insecure keys that must be changed in production
INSECURE_SECRET_KEYS = [
'dev-secret-key-change-in-production',
'jwt-secret-key-change-in-production',
'change-this-to-a-secure-random-string',
'change-this-to-another-secure-random-string',
]
class Config:
SECRET_KEY = os.environ.get('SECRET_KEY', 'dev-secret-key-change-in-production')
# Database - use instance folder for Flask convention
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL', 'sqlite:////app/instance/serverkit.db')
SQLALCHEMY_TRACK_MODIFICATIONS = False
# JWT
JWT_SECRET_KEY = os.environ.get('JWT_SECRET_KEY', 'jwt-secret-key-change-in-production')
JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=1)
JWT_REFRESH_TOKEN_EXPIRES = timedelta(days=30)
# CORS - Allow both dev server and Flask server
CORS_ORIGINS = os.environ.get('CORS_ORIGINS', 'http://localhost:5173,http://localhost:5000,http://127.0.0.1:5173,http://127.0.0.1:5000').split(',')
class DevelopmentConfig(Config):
DEBUG = True
class ProductionConfig(Config):
DEBUG = False
def __init__(self):
# Validate that secret keys are not default values in production
if self.SECRET_KEY in INSECURE_SECRET_KEYS:
print("FATAL: SECRET_KEY is set to a default insecure value in production mode!", file=sys.stderr)
print("Generate a secure key with: python -c \"import secrets; print(secrets.token_hex(32))\"", file=sys.stderr)
sys.exit(1)
if self.JWT_SECRET_KEY in INSECURE_SECRET_KEYS:
print("FATAL: JWT_SECRET_KEY is set to a default insecure value in production mode!", file=sys.stderr)
print("Generate a secure key with: python -c \"import secrets; print(secrets.token_hex(32))\"", file=sys.stderr)
sys.exit(1)
config = {
'development': DevelopmentConfig,
'production': ProductionConfig,
'default': DevelopmentConfig
}