services:
  mongo:
    image: mongo:7
    container_name: foz-fc-mongo
    restart: unless-stopped
    # Published on 27018 on the host to avoid clashing with other local Mongo
    # instances. Containers still reach it internally as mongo:27017.
    ports:
      - "27018:27017"
    volumes:
      - mongo_data:/data/db
    healthcheck:
      test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
      interval: 10s
      timeout: 5s
      retries: 5

  backend:
    build: ./backend
    container_name: foz-fc-backend
    restart: unless-stopped
    depends_on:
      mongo:
        condition: service_healthy
    ports:
      - "4000:4000"
    environment:
      PORT: 4000
      MONGODB_URI: mongodb://mongo:27017
      MONGODB_DB: foz_fc
      JWT_SECRET: ${JWT_SECRET:-change-me-in-production-please-32chars-min}
      JWT_TTL_SECONDS: 2592000
      CORS_ORIGINS: ${CORS_ORIGINS:-http://localhost:5173,http://localhost:8080,http://localhost:4173}
      FIREBASE_PROJECT_ID: ${FIREBASE_PROJECT_ID:-fc-foz-53e0a}
      PUBLIC_BASE_URL: ${PUBLIC_BASE_URL:-http://localhost:4000}
      ALLOW_UNVERIFIED_GOOGLE: ${ALLOW_UNVERIFIED_GOOGLE:-false}
      SEED_ADMIN_EMAIL: ${SEED_ADMIN_EMAIL:-admin@foz.pt}
      SEED_ADMIN_PASSWORD: ${SEED_ADMIN_PASSWORD:-admin123}
    volumes:
      - uploads_data:/app/uploads

volumes:
  mongo_data:
  uploads_data:
