Remove hardcoded credentials, harden deployment, optimize OCR

Secrets (S3 keys, PG password, DeerMapper API key) were committed in
config.yaml and .env and remain in git history. This removes them from
the tracked tree and moves all secrets to env injection.

Security:
- config.yaml: drop all credentials, keep only non-secret app tunables
- untrack .env, add .env.example template; .gitignore excludes .env
- main.py: tolerant config lookups + fail-fast validation for missing secrets
- docker-compose: env_file injection, no full-repo bind mount, debug port off
- Dockerfile: bake config into image, run as non-root user

Efficiency:
- OCR: run the second (expensive) tesseract pass only when the first
  is unparsable; identical fallback behavior

Docs:
- README with operation + security notes
- MIGRATION.md runbook: secret rotation, server cutover, decommission,
  git history purge

Note: the leaked secrets are compromised and MUST be rotated; removing
them from the tree is not sufficient. See MIGRATION.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-13 21:35:04 +02:00
parent 2e9ee3e014
commit 88ef0d6943
9 changed files with 318 additions and 33 deletions

View File

@@ -1,16 +1,22 @@
# config.yaml (Beispiel)
# config.yaml - Nicht-geheime Konfiguration (App-Tunables + oeffentliche Endpunkte).
#
# WICHTIG: Hier gehoeren KEINE Zugangsdaten hinein.
# Secrets kommen ausschliesslich aus Umgebungsvariablen (.env):
# S3_ACCESS_KEY, S3_SECRET_KEY, PG_DSN, DEERMAPPER_API_KEY
# (optional koennen auch S3_ENDPOINT / S3_BUCKET / DEERMAPPER_API_URL per ENV
# ueberschrieben werden.)
s3:
endpoint: "https://fsn1.your-objectstorage.com/"
access_key: "UG950FCGWFYRXSXXVUAH"
secret_key: "rXpspNhboZY6zNZi7djjq2QaXPA4uwsO9jXf4AXk"
bucket: "trapper-meles"
# access_key / secret_key -> via ENV (.env): S3_ACCESS_KEY / S3_SECRET_KEY
postgres:
dsn: "postgresql://postgres:DFGk5s9H21lKao2K@136.243.41.58:7777/meles"
postgres: {}
# dsn -> via ENV (.env): PG_DSN (inkl. ?sslmode=require)
deermapper-api:
base_url: "https://webapp.deermapper.net/api/icu"
apiKey: "695bc217-3b40-48bb-bb12-17fc5b08b320"
# apiKey -> via ENV (.env): DEERMAPPER_API_KEY
app:
entrance_prefix: "icu/entrance/"