services:
  nginx:
    image: nginx:alpine
    container_name: scmedia_nginx
    depends_on:
      - php
    ports:
      - "8088:80"
    volumes:
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
      - ./:/var/www:ro
    networks:
      - scmedia

  php:
    build:
      context: .
      dockerfile: docker/php/Dockerfile
    container_name: scmedia_php
    environment:
      APP_ENV: ${APP_ENV:-production}
      APP_ID: ${APP_ID:-CHANGE_ME_UUID}
      DEBUG_TOOLS_ENABLED: ${DEBUG_TOOLS_ENABLED:-false}
      ALLOW_DB_RESET: ${ALLOW_DB_RESET:-false}
      WORKER_SLEEP_SECONDS: ${WORKER_SLEEP_SECONDS:-2}
      DB_HOST: ${DB_HOST:-db}
      DB_PORT: ${DB_PORT:-3306}
      DB_NAME: ${DB_NAME:-scmedia}
      DB_USER: ${DB_USER:-scmedia}
      DB_PASS: ${DB_PASS:-changeme}
      DB_ROOT_PASS: ${DB_ROOT_PASS:-rootpass}
      PATH_INCOMING: ${PATH_INCOMING:-/data/incoming}
      PATH_MOVIES: ${PATH_MOVIES:-/data/movies}
      PATH_SERIES: ${PATH_SERIES:-/data/series}
      VIDEO_EXT: ${VIDEO_EXT:-mkv,mp4,avi,mov,m4v,ts,m2ts,wmv}
      SCANNER_MAX_DEPTH: ${SCANNER_MAX_DEPTH:-3}
      SCANNER_MAX_FILES_PER_ITEM: ${SCANNER_MAX_FILES_PER_ITEM:-3000}
    volumes:
      - ./:/var/www
      # where scMedia scans media (bind-mount your CephFS path here)
      - ./_data:/data
      # writable storage
      - scmedia_storage:/var/www/storage
    networks:
      - scmedia

  worker:
    build:
      context: .
      dockerfile: docker/php/Dockerfile
    container_name: scmedia_worker
    depends_on:
      - db
    environment:
      APP_ENV: ${APP_ENV:-production}
      APP_ID: ${APP_ID:-CHANGE_ME_UUID}
      DEBUG_TOOLS_ENABLED: ${DEBUG_TOOLS_ENABLED:-false}
      ALLOW_DB_RESET: ${ALLOW_DB_RESET:-false}
      WORKER_SLEEP_SECONDS: ${WORKER_SLEEP_SECONDS:-2}
      DB_HOST: ${DB_HOST:-db}
      DB_PORT: ${DB_PORT:-3306}
      DB_NAME: ${DB_NAME:-scmedia}
      DB_USER: ${DB_USER:-scmedia}
      DB_PASS: ${DB_PASS:-changeme}
      DB_ROOT_PASS: ${DB_ROOT_PASS:-rootpass}
      PATH_INCOMING: ${PATH_INCOMING:-/data/incoming}
      PATH_MOVIES: ${PATH_MOVIES:-/data/movies}
      PATH_SERIES: ${PATH_SERIES:-/data/series}
      VIDEO_EXT: ${VIDEO_EXT:-mkv,mp4,avi,mov,m4v,ts,m2ts,wmv}
      SCANNER_MAX_DEPTH: ${SCANNER_MAX_DEPTH:-3}
      SCANNER_MAX_FILES_PER_ITEM: ${SCANNER_MAX_FILES_PER_ITEM:-3000}
    command: ["php", "cli/worker.php"]
    volumes:
      - ./:/var/www
      - ./_data:/data
      - scmedia_storage:/var/www/storage
    networks:
      - scmedia

  db:
    image: mariadb:11
    container_name: scmedia_db
    environment:
      MARIADB_DATABASE: ${DB_NAME:-scmedia}
      MARIADB_USER: ${DB_USER:-scmedia}
      MARIADB_PASSWORD: ${DB_PASS:-changeme}
      MARIADB_ROOT_PASSWORD: ${DB_ROOT_PASS:-rootpass}
    volumes:
      - scmedia_db:/var/lib/mysql
    networks:
      - scmedia

networks:
  scmedia:

volumes:
  scmedia_db:
  scmedia_storage:
