services:
  app:
    build:
      context: .
      dockerfile: docker/php/Dockerfile
    working_dir: /var/www/html
    volumes:
      - ./:/var/www/html
    environment:
      DB_HOST: mysql
      DB_DATABASE: otomova
      DB_USERNAME: otomova
      DB_PASSWORD: otomova
      REDIS_HOST: redis
    depends_on:
      mysql:
        condition: service_healthy

  web:
    image: nginx:1.27-alpine
    ports:
      - "8080:80"
    volumes:
      - ./:/var/www/html
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      - app

  mysql:
    image: mysql:8.4
    ports:
      - "3307:3306"
    environment:
      MYSQL_DATABASE: otomova
      MYSQL_USER: otomova
      MYSQL_PASSWORD: otomova
      MYSQL_ROOT_PASSWORD: root
    volumes:
      - otomova_mysql:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-proot"]
      interval: 5s
      timeout: 5s
      retries: 20

  redis:
    image: redis:7.4-alpine
    ports:
      - "6380:6379"

  node:
    image: node:22-alpine
    working_dir: /var/www/html
    volumes:
      - ./:/var/www/html
    profiles: ["tools"]

volumes:
  otomova_mysql:
