services:
  ### The app contains the application and web server ###
  app:
    image: code.caldwell.digital/home/torsearch-app:${TAG}
    ports:
      - "${WEB_PORT}:80"
    env_file: .env
    depends_on:
      database:
        condition: service_healthy
    volumes:
      - ${LOCAL_MOVIES_DIR}:/var/download/movies
      - ${LOCAL_TVSHOWS_DIR}:/var/download/tvshows
      - mercure_data:/data
      - mercure_config:/config


  ### The worker handles downloads and async jobs ###
  worker:
    image: code.caldwell.digital/home/torsearch-worker:${TAG}
    volumes:
      - ${LOCAL_MOVIES_DIR}:/var/download/movies
      - ${LOCAL_TVSHOWS_DIR}:/var/download/tvshows
    env_file: .env
    depends_on:
      - app


  ### The scheduler processes monitored media ###
  scheduler:
    image: code.caldwell.digital/home/torsearch-scheduler:${TAG}
    volumes:
      - ${LOCAL_MOVIES_DIR}:/var/download/movies
      - ${LOCAL_TVSHOWS_DIR}:/var/download/tvshows
    env_file: .env
    depends_on:
      - app


  #!! If using your own database, this can be omitted !!#
  database:
    image: mariadb:10.11.2
    volumes:
      - mysql:/var/lib/mysql
    env_file: .env
    healthcheck:
      test: ["CMD", "mysqladmin", "ping"]
      interval: 5s
      timeout: 5s
      retries: 10


  #!! If using your own redis, this can be omitted !!#
  redis:
    image: redis:latest
    volumes:
      - redis_data:/data
    command: redis-server --maxmemory 512MB
    restart: unless-stopped


volumes:
  mysql:
  mercure_config:
  mercure_data:
  redis_data:
