Files
finance_bot/docker-compose.yml
Andrew K. Choi 23a9d975a9 feat: Complete API authentication system with email & Telegram support
- Add email/password registration endpoint (/api/v1/auth/register)
- Add JWT token endpoints for Telegram users (/api/v1/auth/token/get, /api/v1/auth/token/refresh-telegram)
- Enhance User model to support both email and Telegram authentication
- Fix JWT token handling: convert sub to string (RFC compliance with PyJWT 2.10.1+)
- Fix bot API calls: filter None values from query parameters
- Fix JWT extraction from Redis: handle both bytes and string returns
- Add public endpoints to JWT middleware: /api/v1/auth/register, /api/v1/auth/token/*
- Update bot commands: /register (one-tap), /link (account linking), /start (options)
- Create complete database schema migration with email auth support
- Remove deprecated version attribute from docker-compose.yml
- Add service dependency: bot waits for web service startup

Features:
- Dual authentication: email/password OR Telegram ID
- JWT tokens with 15-min access + 30-day refresh lifetime
- Redis-based token storage with TTL
- Comprehensive API documentation and integration guides
- Test scripts and Python examples
- Full deployment checklist

Database changes:
- User model: added email, password_hash, email_verified (nullable fields)
- telegram_id now nullable to support email-only users
- Complete schema with families, accounts, categories, transactions, budgets, goals

Status: Production-ready with all tests passing
2025-12-11 21:00:34 +09:00

101 lines
2.4 KiB
YAML

services:
postgres:
image: postgres:16-alpine
container_name: finance_bot_postgres
environment:
POSTGRES_USER: ${DB_USER:-finance_user}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_NAME:-finance_db}
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-finance_user}"]
interval: 10s
timeout: 5s
retries: 5
networks:
- finance_network
redis:
image: redis:7-alpine
container_name: finance_bot_redis
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
- finance_network
migrations:
build:
context: .
dockerfile: Dockerfile
container_name: finance_bot_migrations
command: alembic upgrade head
environment:
DATABASE_URL: postgresql+psycopg2://${DB_USER:-finance_user}:${DB_PASSWORD}@postgres:5432/${DB_NAME:-finance_db}
depends_on:
postgres:
condition: service_healthy
networks:
- finance_network
bot:
build:
context: .
dockerfile: Dockerfile
container_name: finance_bot_bot
command: python -m app.bot_main
environment:
BOT_TOKEN: ${BOT_TOKEN}
DATABASE_URL: postgresql+psycopg2://${DB_USER:-finance_user}:${DB_PASSWORD}@postgres:5432/${DB_NAME:-finance_db}
REDIS_URL: redis://redis:6379/0
APP_ENV: production
LOG_LEVEL: INFO
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
web:
condition: service_started
networks:
- finance_network
restart: unless-stopped
web:
build:
context: .
dockerfile: Dockerfile
container_name: finance_bot_web
command: uvicorn app.main:app --host 0.0.0.0 --port 8000
environment:
DATABASE_URL: postgresql+psycopg2://${DB_USER:-finance_user}:${DB_PASSWORD}@postgres:5432/${DB_NAME:-finance_db}
REDIS_URL: redis://redis:6379/0
APP_ENV: production
ports:
- "8000:8000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- finance_network
restart: unless-stopped
volumes:
postgres_data:
redis_data:
networks:
finance_network:
driver: bridge