services:
  app:
    image: laravel-master:latest
    container_name: atagaverse72_php
    restart: unless-stopped
    
    # Resource limits for high-scale deployment
    deploy:
      resources:
        limits:
          memory: 256M
          cpus: '0.5'
        reservations:
          memory: 128M
    
    # Security settings
    security_opt:
      - no-new-privileges:true
    read_only: false
    tmpfs:
      - /tmp:noexec,nosuid,size=100m
      - /var/tmp:noexec,nosuid,size=50m
    
    # Volume mounts for data persistence - using bind mounts for real-time local access
    volumes:
      - /var/www/copilot-infra/atagaverse72:/var/www:delegated
      - atagaverse72_logs:/var/log/php
    
    # Network configuration
    networks:
      - laravel_shared_net
    
    # Environment variables
    environment:
      - PROJECT_NAME=atagaverse72
      - CONTAINER_MOUNT_DIR=/var/www
      - HOST_UID=${HOST_UID:-1000}
      - HOST_GID=${HOST_GID:-1000}
      - SKIP_NPM=true
      - PHP_MEMORY_LIMIT=256M
      - PHP_MAX_EXECUTION_TIME=300
      - FPM_MAX_CHILDREN=10
      - FPM_MAX_REQUESTS=500
      - APP_ENV=local
      - APP_DEBUG=true
      - LOG_LEVEL=debug
      - CACHE_DRIVER=file
      - SESSION_DRIVER=file
      - QUEUE_DRIVER=sync
    
    # Health check configuration
    healthcheck:
      test: ["CMD", "/usr/local/bin/healthcheck.sh"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
    
    # Logging configuration
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"
    
    # User and group settings - dynamically set by container
    
    # Process limits
    ulimits:
      nproc: 65535
      nofile:
        soft: 65535
        hard: 65535
    
    # Network optimizations for high-scale deployment
    sysctls:
      - net.core.somaxconn=1024
      - net.ipv4.tcp_keepalive_time=600
      - net.ipv4.tcp_keepalive_intvl=60
      - net.ipv4.tcp_keepalive_probes=3

# Named volumes for logs only (data is now bind mounted)
volumes:
  atagaverse72_logs:
    driver: local

# External shared network
networks:
  laravel_shared_net:
    external: true
