services:
  invidious:
    container_name: invidious
    image: quay.io/invidious/invidious:latest
    # image: quay.io/invidious/invidious:latest-arm64 # ARM64/AArch64 devices
    environment:
      # https://github.com/iv-org/invidious/blob/master/config/config.example.yml
      INVIDIOUS_CONFIG: |
        db:
          dbname: invidious
          user: invidious
          password: cheeNahch8Iiph1auchubeLam0iek1
          host: invidious-db
          port: 5432
        check_tables: true
        external_port: 443
        domain: invidious.akanealw.com
        # https_only: false
        # statistics_enabled: false
        hmac_key: "kei4irie3liiqu0ieX3OhJohraW0re"
        popular_enabled: false
        registration_enabled: true
        login_enabled: true
        captcha_enabled: false
        admins: ["akanealw"]
        enable_user_notifications: false
        channel_threads: 1
        channel_refresh_interval: 30m
        full_refresh: false
        feed_threads: 1
      healthcheck:
      test: wget -nv --tries=1 --spider http://127.0.0.1:3000/api/v1/comments/jNQXAC9IVRw || exit 1
      interval: 30s
      timeout: 5s
      retries: 2
    logging:
      options:
        max-size: "1G"
        max-file: "4"
    depends_on:
      - invidious-db
    networks:
      - invidious
      - reverse-proxy
    ports:
      - "3000:3000"
    restart: always


  invidious-db:
    container_name: invidious-db
    image: docker.io/library/postgres:14
    environment:
      POSTGRES_DB: invidious
      POSTGRES_USER: invidious
      POSTGRES_PASSWORD: cheeNahch8Iiph1auchubeLam0iek1
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
    networks:
      - invidious
    restart: always
    volumes:
      - ./postgresdata:/var/lib/postgresql/data
      - ./config/sql:/config/sql
      - ./docker/init-invidious-db.sh:/docker-entrypoint-initdb.d/init-invidious-db.sh


networks:
  invidious:
    name: invidious
  reverse-proxy:
    name: reverse-proxy
    external: true