version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: crm
    restart: unless-stopped
    # user: www-data  # Run the container as the www-data user
    # user: "${UID}:${GID}"
    user: "root"  # Run the container as root
    env_file:
      - .env
    volumes:
      - .:/var/www/html
    depends_on:
      - db
    healthcheck:
      test: ["CMD-SHELL", "mysqladmin ping -h db -u${DB_USERNAME} -p${DB_PASSWORD} --skip-ssl --silent"]
      interval: 5s
      timeout: 5s
      retries: 5

  db:
    image: mysql:8.0
    container_name: mysql5423_db
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
    command: --default-authentication-plugin=mysql_native_password
    ports:
      - "3307:3306"
    volumes:
      - /home/shariq/backupv/crmvolume_mysql:/var/lib/mysql
    healthcheck:
      test: ["CMD-SHELL", "mysqladmin ping -h localhost -u root -p${MYSQL_ROOT_PASSWORD} --silent"]
      interval: 5s
      timeout: 5s
      retries: 10

  nginx:
    image: nginx:alpine
    container_name: nginx_crm5423
    restart: unless-stopped
    ports:
      - "8004:80"
    volumes:
      - .:/var/www/html
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - app

