Browse Source

Add invidious app (#47)

Rafael Blumberg 3 years ago
parent
commit
512ed1b128
5 changed files with 281 additions and 0 deletions
  1. 7 0
      build/info.json
  2. BIN
      images/invidious.png
  3. 60 0
      stack/invidious.yml
  4. 171 0
      template/apps/invidious.json
  5. 43 0
      tools/install_invidious.sh

+ 7 - 0
build/info.json

@@ -224,6 +224,13 @@
 			"Exec": "bash",
 			"Description": "PI OS 32 libseccomp2 Repair utility",
 			"wget": "https://git.io/JPXdj"
+		},
+		{
+			"File": "install_invidious.sh",
+			"Type": "Preinstall",
+			"Exec": "bash",
+			"Description": "Install Invidious",
+			"wget": "https://raw.githubusercontent.com/pi-hosted/pi-hosted/master/tools/install_invidious.sh"
 		}
 	]
 }

BIN
images/invidious.png


+ 60 - 0
stack/invidious.yml

@@ -0,0 +1,60 @@
+version: "3"
+services:
+
+  invidious:
+    image: quay.io/invidious/invidious:latest-arm64
+    name: invidious
+    restart: unless-stopped
+    ports:
+      - "${PORT}:3000"
+    environment:
+      INVIDIOUS_CONFIG: |
+        db:
+          dbname: invidious
+          user: kemal
+          password: "${DB_PASSWORD}"
+          host: invidious-db
+          port: 5432
+        check_tables: true
+        domain: "${DOMAIN}"
+        https_only: ${HTTPS_ONLY}
+        external_port: "${EXTERNAL_PORT}"
+        popular_enabled: ${POPULAR_ENABLED}
+        statistics_enabled: ${STATISTICS_ENABLED}
+        registration_enabled: ${REGISTRATION_ENABLED}
+        login_enabled: ${LOGIN_ENABLED}
+        captcha_enabled: ${CAPTCHA_ENABLED}
+        channel_threads: 1
+        feed_threads: 1
+        default_user_preferences:
+          locale: en-US
+          region: "${REGION}"
+          captions: ["", "", ""]
+          dark_mode:
+          thin_mode: false
+          feed_menu: ["Popular", "Trending", "Subscriptions", "Playlists"]
+          default_home: Trending
+          related_videos: ${RELATED_VIDEOS}
+          autoplay: ${AUTOPLAY}
+    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
+    depends_on:
+      - invidious-db
+
+  invidious-db:
+    image: docker.io/library/postgres:14
+    name: invidious-db
+    restart: unless-stopped
+    volumes:
+      - /portainer/Files/AppData/Config/invidious/dbdata:/var/lib/postgresql/data
+      - /portainer/Files/AppData/Config/invidious/config-sql:/config/sql
+      - /portainer/Files/AppData/Config/invidious/init-invidious-db.sh:/docker-entrypoint-initdb.d/init-invidious-db.sh
+    environment:
+      POSTGRES_DB: invidious
+      POSTGRES_USER: kemal
+      POSTGRES_PASSWORD: "${DB_PASSWORD}"
+    healthcheck:
+      test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]

+ 171 - 0
template/apps/invidious.json

@@ -0,0 +1,171 @@
+{
+	"categories": [
+		"Videos",
+		"Music"
+	],
+	"description": "An open source alternative front-end to YouTube",
+	"env": [
+		{
+			"default": "ChangeMeToASecurePassword",
+			"label": "DB_PASSWORD",
+			"name": "DB_PASSWORD"
+		},
+		{
+			"default": "3693",
+			"label": "PORT",
+			"name": "PORT"
+		},
+		{
+			"default": "",
+			"description": "Leave it empty if not using a public instance",
+			"label": "DOMAIN",
+			"name": "DOMAIN"
+		},
+		{
+			"description": "Leave it empty if not using a public instance",
+			"label": "HTTPS_ONLY",
+			"name": "HTTPS_ONLY",
+			"select": [
+				{
+					"default": true,
+					"text": "ALLOW HTTP",
+					"value": "false"
+				},
+				{
+					"text": "FORCE HTTPS (recommended for public instance)",
+					"value": "true"
+				}
+			]
+		},
+		{
+			"default": "",
+			"description": "Use 443 if HTTPS_ONLY is enabled or leave it blank",
+			"label": "EXTERNAL_PORT",
+			"name": "EXTERNAL_PORT"
+		},
+		{
+			"label": "POPULAR_ENABLED",
+			"name": "POPULAR_ENABLED",
+			"select": [
+				{
+					"default": true,
+					"text": "Disable POPULAR page (better for privacy)",
+					"value": "false"
+				},
+				{
+					"text": "Enable POPULAR videos in this instance",
+					"value": "true"
+				}
+			]
+		},
+		{
+			"label": "STATISTICS_ENABLED",
+			"name": "STATISTICS_ENABLED",
+			"select": [
+				{
+					"default": true,
+					"text": "Disable Statistics",
+					"value": "false"
+				},
+				{
+					"text": "Enable Statistics",
+					"value": "true"
+				}
+			]
+		},
+		{
+			"label": "REGISTRATION_ENABLED",
+			"name": "REGISTRATION_ENABLED",
+			"select": [
+				{
+					"default": true,
+					"text": "Allow user registration",
+					"value": "true"
+				},
+				{
+					"text": "User registration not allowed",
+					"value": "false"
+				}
+			]
+		},
+		{
+			"label": "LOGIN_ENABLED",
+			"name": "LOGIN_ENABLED",
+			"select": [
+				{
+					"default": true,
+					"text": "Allow user to login",
+					"value": "true"
+				},
+				{
+					"text": "Only guest users",
+					"value": "false"
+				}
+			]
+		},
+		{
+			"label": "CAPTCHA_ENABLED",
+			"name": "CAPTCHA_ENABLED",
+			"select": [
+				{
+					"default": true,
+					"text": "Use CAPTCHA to prevent bot",
+					"value": "true"
+				},
+				{
+					"text": "Disable CAPTCHA for registration",
+					"value": "false"
+				}
+			]
+		},
+		{
+			"default": "US",
+			"description": "Look in the configuration example (link above) for more codes",
+			"label": "REGION",
+			"name": "REGION"
+		},
+		{
+			"label": "RELATED_VIDEOS",
+			"name": "RELATED_VIDEOS",
+			"select": [
+				{
+					"default": true,
+					"text": "Show related videos",
+					"value": "true"
+				},
+				{
+					"text": "Don't show related videos",
+					"value": "false"
+				}
+			]
+		},
+		{
+			"label": "AUTOPLAY",
+			"name": "AUTOPLAY",
+			"select": [
+				{
+					"default": true,
+					"text": "Don't play video automaticaly",
+					"value": "false"
+				},
+				{
+					"text": "Play video automaticaly",
+					"value": "true"
+				}
+			]
+		}
+	],
+	"logo": "https://raw.githubusercontent.com/pi-hosted/pi-hosted/master/images/invidious.png",
+	"name": "invidious",
+	"note": "Your device should have at least <b>4 GB</b> of memory.<br>If you want to customise even further, the easy way is to <b>Copy as Custom</b> and modify the stack file manually. Look at the <a href=\"https://github.com/iv-org/invidious/blob/master/config/config.example.yml\">official config example</a>.",
+	"officialDoc": "https://docs.invidious.io/installation/#docker",
+	"platform": "linux",
+	"preInstallScript": "install_invidious.sh",
+	"repository": {
+		"stackfile64": "stack/invidious.yml",
+		"url": "https://github.com/pi-hosted/pi-hosted"
+	},
+	"title": "Invidious",
+	"type": 3,
+	"webpage": "https://invidious.io/"
+}

+ 43 - 0
tools/install_invidious.sh

@@ -0,0 +1,43 @@
+#!/bin/bash
+
+function error {
+  echo -e "\\e[91m$1\\e[39m"
+  exit 1
+}
+
+function check_internet() {
+  printf "Checking if you are online..."
+  wget -q --spider http://github.com
+  if [ $? -eq 0 ]; then
+    echo "Online. Continuing."
+  else
+    error "Offline. Go connect to the internet then run the script again."
+  fi
+}
+
+check_internet
+
+BASE_DIR='/portainer/Files/AppData/Config/invidious'
+
+echo "Creating directories..."
+sudo mkdir -p "${BASE_DIR}/config-sql" || error "Failed to create config directory"
+sudo mkdir -p "${BASE_DIR}/dbdata" || error "Failed to create data directory for Invidious!"
+
+echo "Downloading Invidious SQL config files"
+GH_INVIDIOUS_RAW='https://raw.githubusercontent.com/iv-org/invidious/master'
+f='annotations.sql'      ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
+f='channel_videos.sql'   ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
+f='channels.sql'         ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
+f='nonces.sql'           ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
+f='playlist_videos.sql'  ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
+f='playlists.sql'        ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
+f='session_ids.sql'      ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
+f='users.sql'            ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
+f='videos.sql'           ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
+
+echo "Downloading Invidious init script"
+f='init-invidious-db.sh' ; sudo wget -O "${BASE_DIR}/$f" "${GH_INVIDIOUS_RAW}/docker/$f"                || error "Failed to download $f file!"
+sudo chmod +x "${BASE_DIR}/$f"
+
+echo "Preparation completed, proceed installation in portainer"
+echo -e "Suggestion for \\e[1mDB_PASSWORD\\e[39m: \\e[33m$(openssl rand -base64 24)\\e[39m"