Deployment ready
Running on your laptop is fine for demos. For an assistant you actually rely on, you need a process that restarts on crash, a secret handling story that does not leak your API key, and logs you can read when something breaks at night.
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
# Persist sessions and memory across restarts
VOLUME ['/app/sessions', '/app/memory']
CMD ['python', '-m', 'bot']A minimal image. Sessions and memory live in mounted volumes so they survive container restarts and image rebuilds.
import os, sys, logging
REQUIRED = ['ANTHROPIC_API_KEY', 'TELEGRAM_BOT_TOKEN']
def load_config() -> dict[str, str]:
missing = [k for k in REQUIRED if not os.getenv(k)]
if missing:
sys.exit(f'Missing env vars: {missing}')
return {k: os.environ[k] for k in REQUIRED}
logging.basicConfig(
level=os.getenv('LOG_LEVEL', 'INFO'),
format='%(asctime)s %(levelname)s %(name)s %(message)s',
)Fail loudly on missing secrets at startup instead of silently returning None deep in a request. Structured logs give you something to grep when things go wrong.
No. Private today is public tomorrow, or forked to a teammate, or leaked via a log paste. Keep .env in gitignore forever. Use a secret manager in production and inject at runtime. Treat API keys like the database password they basically are.
Validation checklist: Ready to deploy checklist
Loading practice…
Quiz: Quiz
Loading practice…