# Docker Compose for StockSense Agent # Runs both frontend and backend services together services: # FastAPI Backend Service api: build: context: . dockerfile: Dockerfile.backend container_name: stocksense-api ports: - '8000:8000' environment: - GOOGLE_API_KEY=${GOOGLE_API_KEY} - NEWSAPI_KEY=${NEWSAPI_KEY} - DATABASE_URL=sqlite:///data/stocksense.db volumes: - api_data:/app/data healthcheck: test: ['CMD', 'curl', '-f', 'http://localhost:8000/health'] interval: 30s timeout: 10s retries: 3 start_period: 40s networks: - stocksense-network # Streamlit Frontend Service frontend: build: context: . dockerfile: Dockerfile.frontend container_name: stocksense-frontend ports: - '8501:8501' environment: - GOOGLE_API_KEY=${GOOGLE_API_KEY} - NEWSAPI_KEY=${NEWSAPI_KEY} - API_BASE_URL=http://api:8000 depends_on: api: condition: service_healthy healthcheck: test: ['CMD', 'curl', '-f', 'http://localhost:8501/_stcore/health'] interval: 30s timeout: 10s retries: 3 start_period: 40s networks: - stocksense-network # Nginx Reverse Proxy (Optional) nginx: image: nginx:alpine container_name: stocksense-proxy ports: - '80:80' - '443:443' volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro depends_on: - frontend - api networks: - stocksense-network # Named volumes for data persistence volumes: api_data: driver: local # Custom network for service communication networks: stocksense-network: driver: bridge