services:
  insurance_admin_app:
    build:
      context: ./
      dockerfile: Dockerfile
    container_name: insurance_admin_app
    extra_hosts:
      - "mail.thekpj.com:178.156.205.191"
    restart: unless-stopped
    environment:
      PHP_MEMORY_LIMIT: 512M
      PHP_UPLOAD_MAX_FILESIZE: 64M
      PHP_POST_MAX_SIZE: 64M
      PHP_MAX_EXECUTION_TIME: 300
    volumes:
      - .:/var/www/html
      - composer_cache_admin:/root/.composer
      - npm_cache_admin:/root/.npm
    expose:
      - "9000"
    networks:
      - insurance-admin-internal
      - shared-services
    healthcheck:
      test: ["CMD-SHELL", "php-fpm -t || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
    deploy:
      resources:
        limits:
          cpus: "2"
          memory: 1G
        reservations:
          cpus: "0.5"
          memory: 512M

  nginx:
    image: nginx:stable-alpine3.21-perl
    container_name: insurance_admin-nginx
    expose:
      - "80"
    ports:
      - "8002:80"
    depends_on:
      insurance_admin_app:
        condition: service_started
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - .:/var/www/html:ro
    networks:
      - insurance-admin-internal
      - shared-services
      - proxy
    restart: unless-stopped

networks:
  insurance-admin-internal:
    driver: bridge
  shared-services:
    external: true
    name: shared-services
  proxy:
    external: true
    name: nginx-proxy
volumes:
  composer_cache_admin:
    driver: local
  npm_cache_admin:
    driver: local
