version: "3.9"

services:
  app:
    build:
      context: .
      dockerfile: docker/php/Dockerfile
    container_name: smmstone_app
    restart: unless-stopped
    working_dir: /var/www/html
    volumes:
      - ./:/var/www/html
    depends_on:
      - mysql
      - redis

  nginx:
    image: nginx:1.27-alpine
    container_name: smmstone_nginx
    restart: unless-stopped
    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
    container_name: smmstone_mysql
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: smmstone
      MYSQL_USER: smmstone
      MYSQL_PASSWORD: smmstone
      MYSQL_ROOT_PASSWORD: root
    ports:
      - "3308:3306"
    volumes:
      - mysql_data:/var/lib/mysql

  redis:
    image: redis:7-alpine
    container_name: smmstone_redis
    restart: unless-stopped
    ports:
      - "6380:6379"

  worker:
    build:
      context: .
      dockerfile: docker/php/Dockerfile
    container_name: smmstone_worker
    restart: unless-stopped
    working_dir: /var/www/html
    command: ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]
    volumes:
      - ./:/var/www/html
      - ./docker/supervisor/supervisord.conf:/etc/supervisor/supervisord.conf:ro
      - ./docker/supervisor/worker.conf:/etc/supervisor/conf.d/worker.conf:ro
    depends_on:
      - app
      - redis

volumes:
  mysql_data:
