version: '3.8'

services:
  qrrapido:
    build: 
      context: .
      dockerfile: Dockerfile
    ports:
      - "5000:80"
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ConnectionStrings__MongoDB=mongodb://mongo:27017/qrrapido
      - ConnectionStrings__Redis=redis:6379
      - Authentication__Google__ClientId=${GOOGLE_CLIENT_ID}
      - Authentication__Google__ClientSecret=${GOOGLE_CLIENT_SECRET}
      - Authentication__Microsoft__ClientId=${MICROSOFT_CLIENT_ID}
      - Authentication__Microsoft__ClientSecret=${MICROSOFT_CLIENT_SECRET}
      - Stripe__PublishableKey=${STRIPE_PUBLISHABLE_KEY}
      - Stripe__SecretKey=${STRIPE_SECRET_KEY}
      - Stripe__WebhookSecret=${STRIPE_WEBHOOK_SECRET}
      - Stripe__PriceId=${STRIPE_PRICE_ID}
    depends_on:
      - mongo
      - redis
    volumes:
      - ./logs:/app/logs
    networks:
      - qrrapido-network
    restart: unless-stopped

  mongo:
    image: mongo:7.0
    container_name: qrrapido-mongo
    ports:
      - "27017:27017"
    environment:
      - MONGO_INITDB_DATABASE=qrrapido
      - MONGO_INITDB_ROOT_USERNAME=admin
      - MONGO_INITDB_ROOT_PASSWORD=password123
    volumes:
      - mongo_data:/data/db
      - ./scripts/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
    networks:
      - qrrapido-network
    restart: unless-stopped

  redis:
    image: redis:7.2-alpine
    container_name: qrrapido-redis
    ports:
      - "6379:6379"
    command: redis-server --maxmemory 256mb --maxmemory-policy allkeys-lru --appendonly yes
    volumes:
      - redis_data:/data
    networks:
      - qrrapido-network
    restart: unless-stopped

  nginx:
    image: nginx:alpine
    container_name: qrrapido-nginx
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./nginx/ssl:/etc/nginx/ssl:ro
      - ./logs/nginx:/var/log/nginx
    depends_on:
      - qrrapido
    networks:
      - qrrapido-network
    restart: unless-stopped

volumes:
  mongo_data:
    driver: local
  redis_data:
    driver: local

networks:
  qrrapido-network:
    driver: bridge