File size: 3,420 Bytes
2bdf377 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | # ================================================================
# docker-compose.yml β TruthLens / Fake-News Detector
# Open-source stack: FastAPI backend + React/Nginx frontend + MongoDB
# ================================================================
#
# Quick start:
# 1. cp .env.example .env (fill in your API keys)
# 2. docker compose up --build
# 3. Open http://localhost in your browser
# ================================================================
services:
# ββ MongoDB ββββββββββββββββββββββββββββββββββββββββββββββββββ
mongodb:
image: mongo:7.0
container_name: fakenews_mongodb
restart: unless-stopped
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_ROOT_USER:-admin}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD:-changeme}
MONGO_INITDB_DATABASE: ${DATABASE_NAME:-fake_news_detector}
volumes:
- mongo_data:/data/db
ports:
- "27017:27017" # expose only for local development; remove in production
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
start_period: 20s
# ββ FastAPI backend βββββββββββββββββββββββββββββββββββββββββββ
backend:
build:
context: .
dockerfile: Dockerfile
container_name: fakenews_backend
restart: unless-stopped
env_file: .env
environment:
# Overrides anything in .env for the MongoDB URL (uses the container hostname)
MONGODB_URL: mongodb://${MONGO_ROOT_USER:-admin}:${MONGO_ROOT_PASSWORD:-changeme}@mongodb:27017/${DATABASE_NAME:-fake_news_detector}?authSource=admin
DATABASE_NAME: ${DATABASE_NAME:-fake_news_detector}
# Allow requests from Nginx (same-origin in production, localhost during dev)
ALLOWED_ORIGINS: "http://localhost,http://localhost:80,http://127.0.0.1,http://localhost:3000,http://localhost:5173"
volumes:
- ./logs:/app/logs # persist logs on the host
ports:
- "8000:8000" # expose for direct API access / debugging
depends_on:
mongodb:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 5
start_period: 90s # BERT model loading takes ~60 s
# ββ React frontend (Nginx) ββββββββββββββββββββββββββββββββββββ
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
args:
# All /api calls go to the same origin so the browser hits Nginx,
# which proxies to the backend container.
VITE_API_URL: /api
container_name: fakenews_frontend
restart: unless-stopped
ports:
- "80:80" # main entry point for users
depends_on:
backend:
condition: service_healthy
# ββ Named volumes βββββββββββββββββββββββββββββββββββββββββββββ
volumes:
mongo_data:
driver: local
|