services:
  app:
    build:
      context: .
      dockerfile: docker/php/Dockerfile
    container_name: lifestyle_app
    restart: unless-stopped
    working_dir: /var/www
    volumes:
      - .:/var/www
      - ./docker/php/php.ini:/usr/local/etc/php/conf.d/custom.ini
    environment:
      - PHP_OPCACHE_ENABLE=0
    networks:
      - lifestyle
    depends_on:
      - mysql
      - redis

  nginx:
    image: nginx:alpine
    container_name: lifestyle_nginx
    restart: unless-stopped
    ports:
      - "8080:80"
      - "8443:443"
    volumes:
      - .:/var/www
      - ./docker/nginx/conf.d:/etc/nginx/conf.d
      - ./docker/ssl:/etc/nginx/ssl
    networks:
      - lifestyle
    depends_on:
      - app

  mysql:
    image: mysql:8.4
    container_name: lifestyle_mysql
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-secret}
      MYSQL_DATABASE: ${DB_DATABASE:-lifestyle}
      MYSQL_USER: ${DB_USERNAME:-lifestyle}
      MYSQL_PASSWORD: ${DB_PASSWORD:-secret}
    ports:
      - "3307:3306"
    volumes:
      - lifestyle_mysql:/var/lib/mysql
    networks:
      - lifestyle

  redis:
    image: redis:alpine
    container_name: lifestyle_redis
    restart: unless-stopped
    ports:
      - "6380:6379"
    volumes:
      - lifestyle_redis:/data
    networks:
      - lifestyle

  vite:
    build:
      context: .
      dockerfile: docker/node/Dockerfile
    container_name: lifestyle_vite
    restart: unless-stopped
    working_dir: /var/www
    ports:
      - "5173:5173"
    volumes:
      - .:/var/www
      - /var/www/node_modules
    command: npm run dev -- --host 0.0.0.0
    networks:
      - lifestyle
    profiles:
      - dev

networks:
  lifestyle:
    driver: bridge

volumes:
  lifestyle_mysql:
  lifestyle_redis:
