db creds: move ClickHouse user/password to gitignored .env via compose env_file; drop hardcoded default from main.py

This commit is contained in:
aaverbitskiy 2026-07-23 05:19:13 +00:00
parent 23f5ce8b1a
commit d04e0ae024
3 changed files with 6 additions and 1 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ __pycache__/
static/assets/
static/index.html
static/next/
.env

View File

@ -5,6 +5,8 @@ services:
container_name: mapdash
restart: unless-stopped
networks: [edge]
env_file:
- .env
volumes:
- ./static:/app/static:ro
networks:

View File

@ -7,7 +7,9 @@ from fastapi.staticfiles import StaticFiles
CH_HOST = os.environ.get("CLICKHOUSE_HOST", "ClickHouse")
CH_PORT = os.environ.get("CLICKHOUSE_PORT", "8123")
CH_USER = os.environ.get("CLICKHOUSE_USER", "default")
CH_PASSWORD = os.environ.get("CLICKHOUSE_PASSWORD", "1234567890")
# Credentials come from the environment (see .env / docker-compose env_file).
# No secret is kept in source; empty default fails fast if the env is missing.
CH_PASSWORD = os.environ.get("CLICKHOUSE_PASSWORD", "")
CH_URL = f"http://{CH_HOST}:{CH_PORT}/"
app = FastAPI()