# docker-compose.yml version: '3.8' services: barrons-crawler: build: . container_name: barrons-crawler restart: unless-stopped # 將同目錄的 .env 檔注入容器環境變數 env_file: - .env # 所有環境變數由 .env 提供 volumes: - ./data:/app/data # 資料持久化 - ./logs:/app/logs # 日誌持久化 ports: - "8080:8080" # 健康檢查和狀態 API healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8080/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s # 可選:加入 Redis 用於快取 redis: image: redis:7-alpine container_name: barrons-redis restart: unless-stopped volumes: - redis_data:/data command: redis-server --appendonly yes volumes: redis_data: