version: "3"


services:
  invidious:
    #image: quay.io/invidious/invidious:latest
    image: quay.io/invidious/invidious:latest-arm64 # ARM64/AArch64 devices
    restart: unless-stopped
    ports:
      - "127.0.0.1:4000:3000"
    environment:
      # Please read the following file for a comprehensive list of all available
      # configuration options and their associated syntax:
      # https://github.com/iv-org/invidious/blob/master/config/config.example.yml
      INVIDIOUS_CONFIG: |
        db:
          dbname: invidious
          user: kemal
          password: kemal
          host: invidious-db
          port: 5432
        check_tables: true
        # external_port:
        # domain:
        https_only: false
        # statistics_enabled: false
        hmac_key: "Aigho5thieC0ahng6Ahj"
        locale: zh-CN
        region: US
        captions: ["Chinese (Simplified)", "English", "English (auto-generated)"]
        dark_mode: "auto"
        quality: hd720
        volume: 70
        force_resolve: ipv6
        use_innertube_for_captions: true
    healthcheck:
      test: wget -nv --tries=1 --spider http://127.0.0.1:4000/api/v1/comments/jNQXAC9IVRw || exit 1
      interval: 30s
      timeout: 5s
      retries: 2
    logging:
      options:
        max-size: "1G"
        max-file: "4"
    depends_on:
      - invidious-db

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

volumes:
  postgresdata:


networks:
  default:
    enable_ipv6: true
    ipam:
      config:
        - subnet: 2001:0DB9::/112
          gateway: 2001:0DB9::1

# docker network create --driver bridge --ipv6 --subnet 2001:0DB9::/112 youtube-invidious_invidious_ip6net --attachable
# https://github.com/iv-org/smart-ipv6-rotator.