services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: bongara_backend_app
    restart: unless-stopped
    volumes:
      - .:/var/www/html
    environment:
      - APP_ENV=${APP_ENV:-production}
      - APP_DEBUG=${APP_DEBUG:-false}
      - APP_KEY=${APP_KEY}
      - DB_CONNECTION=${DB_CONNECTION:-sqlsrv}
      - DB_HOST=${DB_HOST:-host.docker.internal}
      - DB_PORT=${DB_PORT:-1433}
      - DB_DATABASE=${DB_DATABASE}
      - DB_USERNAME=${DB_USERNAME}
      - DB_PASSWORD=${DB_PASSWORD}
      - KAMBIA_ENVIRONMENT=${KAMBIA_ENVIRONMENT:-sandbox}
      - KAMBIA_MERCHANT_ID=${KAMBIA_MERCHANT_ID}
      - KAMBIA_MERCHANT_KEY=${KAMBIA_MERCHANT_KEY}
      - KAMBIA_WEBHOOK_SECRET=${KAMBIA_WEBHOOK_SECRET}
      - BUTTON_BG_COLOR=${BUTTON_BG_COLOR:-#219A5F}
      - BUTTON_TEXT_COLOR=${BUTTON_TEXT_COLOR:-#ffffff}
    # Configuración de red para acceder a base de datos en el host
    extra_hosts:
      - "host.docker.internal:host-gateway"
    networks:
      - bongara_network
    healthcheck:
      test: ["CMD", "php", "artisan", "inspire"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

  nginx:
    image: nginx:alpine
    container_name: bongara_backend_nginx
    restart: unless-stopped
    ports:
      - "${APP_PORT:-8000}:80"
    volumes:
      - .:/var/www/html
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - app
    networks:
      - bongara_network
    healthcheck:
      test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s

networks:
  bongara_network:
    driver: bridge
