create docker compose setup
This commit is contained in:
parent
f2fd4c8d7c
commit
16e840fb78
9 changed files with 228 additions and 46 deletions
|
|
@ -1,8 +1,29 @@
|
|||
"""
|
||||
Settings configuration that works in both local development and Docker environments.
|
||||
|
||||
In local development:
|
||||
- Loads from .env file if it exists
|
||||
- Environment variables override .env file values
|
||||
|
||||
In Docker:
|
||||
- Reads directly from environment variables (no .env file needed)
|
||||
- Use docker-compose.yml or docker run -e to set environment variables
|
||||
"""
|
||||
|
||||
import os
|
||||
from os import environ
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(env_file='.env', env_file_encoding='utf-8', extra='ignore')
|
||||
model_config = SettingsConfigDict(
|
||||
# Try to load .env file for local development, but don't fail if it doesn't exist
|
||||
env_file='.env' if os.path.exists('.env') else None,
|
||||
env_file_encoding='utf-8',
|
||||
extra='ignore',
|
||||
# Environment variables take precedence over .env file
|
||||
env_ignore_empty=True
|
||||
)
|
||||
airtable_pat: str
|
||||
airtable_base: str
|
||||
slack_signing_secret: str
|
||||
|
|
@ -20,10 +41,21 @@ class Settings(BaseSettings):
|
|||
# Session security
|
||||
session_ttl_hours: int = 24 # Session expires after 24 hours
|
||||
|
||||
# Redis/Valkey settings - prioritize explicit env vars, fall back to container detection
|
||||
redis_host: str = environ.get("REDIS_HOST") or (
|
||||
"valkey" if environ.get("DOCKER_CONTAINER") else "localhost"
|
||||
)
|
||||
redis_port: int = int(environ.get("REDIS_PORT", "6379"))
|
||||
|
||||
@property
|
||||
def is_production(self) -> bool:
|
||||
return self.environment == "production"
|
||||
|
||||
@property
|
||||
def is_container(self) -> bool:
|
||||
"""Detect if running in a container environment."""
|
||||
return bool(environ.get("DOCKER_CONTAINER") or environ.get("REDIS_HOST"))
|
||||
|
||||
@property
|
||||
def origins_list(self) -> list[str]:
|
||||
if self.allowed_origins == "*":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue