version: "3.9"

services:
  backend:
    build: ./backend
    container_name: recipes-backend
    restart: unless-stopped
    ports:
      - "8000:8000"
    environment:
      # Database Configuration (RDS)
      DATABASE_URL: postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}
      DB_USER: ${DB_USER}
      DB_PASSWORD: ${DB_PASSWORD}
      DB_NAME: ${DB_NAME}
      DB_HOST: ${DB_HOST}
      DB_PORT: ${DB_PORT:-5432}
      
      # Email Configuration
      SMTP_HOST: ${SMTP_HOST}
      SMTP_PORT: ${SMTP_PORT:-587}
      SMTP_USER: ${SMTP_USER}
      SMTP_PASSWORD: ${SMTP_PASSWORD}
      SMTP_FROM: ${SMTP_FROM}
      
      # Google OAuth
      GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID}
      GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET}
      GOOGLE_REDIRECT_URI: ${GOOGLE_REDIRECT_URI}
      
      # Microsoft Azure OAuth
      AZURE_CLIENT_ID: ${AZURE_CLIENT_ID}
      AZURE_CLIENT_SECRET: ${AZURE_CLIENT_SECRET}
      AZURE_TENANT_ID: ${AZURE_TENANT_ID:-consumers}
      AZURE_REDIRECT_URI: ${AZURE_REDIRECT_URI}
      
      # Frontend URL
      FRONTEND_URL: ${FRONTEND_URL}
      
      # Cloudflare R2 Backup Configuration
      R2_ENDPOINT: ${R2_ENDPOINT}
      R2_ACCESS_KEY: ${R2_ACCESS_KEY}
      R2_SECRET_KEY: ${R2_SECRET_KEY}
      R2_BUCKET_NAME: ${R2_BUCKET_NAME}
      
      # Backup Schedule
      BACKUP_INTERVAL: ${BACKUP_INTERVAL:-weekly}
    env_file:
      - ./backend/.env.aws
    volumes:
      - ./backend/backups:/app/backups
      - ./backend/restores:/app/restores
    networks:
      - recipes-network

  frontend:
    build: ./frontend
    container_name: recipes-frontend
    restart: unless-stopped
    ports:
      - "80:80"
    environment:
      VITE_API_URL: ${VITE_API_URL:-http://localhost:8000}
    depends_on:
      - backend
    networks:
      - recipes-network

networks:
  recipes-network:
    driver: bridge
