version: '3.8'

services:
  nginx:
    build:
      context: ./docker/nginx
      dockerfile: Dockerfile
    container_name: qwen-php-nginx
    ports:
      - "20001:80"
    volumes:
      - .:/var/www/html
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - php
    networks:
      - moh-network

  php:
    build:
      context: .
      dockerfile: docker/Dockerfile
    container_name: qwen-php-fpm
    volumes:
      - .:/var/www/html
      - ./docker/php.ini:/usr/local/etc/php/conf.d/custom.ini
    environment:
      - APP_ENV=development
      - DB_HOST=postgres
      - DB_PORT=5432
      - DB_NAME=moh_db
      - DB_USER=moh_user
      - DB_PASSWORD=moh_password
    depends_on:
      - postgres
      - redis
    networks:
      - moh-network

  postgres:
    image: postgres:15-alpine
    container_name: qwen-php-postgres
    ports:
      - "5432:5432"
    environment:
      POSTGRES_DB: moh_db
      POSTGRES_USER: moh_user
      POSTGRES_PASSWORD: moh_password
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./docker/init.sql:/docker-entrypoint-initdb.d/init.sql
    networks:
      - moh-network

  redis:
    image: redis:7-alpine
    container_name: qwen-php-redis
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    networks:
      - moh-network

volumes:
  postgres_data:
  redis_data:

networks:
  moh-network:
    driver: bridge